Logo
(追記) (追記ここまで)

17933번 - Logland 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB75383153.448%

문제

Two thieves (who strongly "recommended" us not to reveal their names) has broken into the central bank of Logland, where the country's cash reserve is stored. In Logland, the currency has the $k$ denominations 1,ドル 2, 4, 8, \ldots, 2^{k - 1},ドル and the bank currently stores $x_i$ coins of denominations 2ドル^i$.

Thieves live by a very strict honor code, which stipulates that any loot grabbed must be divided evenly between the theives. Unfortunately (for the thieves), this may mean that some loot must be left behind. For example, if the bank contained a single coin of denomination 8ドル,ドル and two coins of denomination 2ドル,ドル there is no way they could bring the 8ドル$ coin. Instead, they would have to take one coin of value 2ドル$ each, leaving more than half of the possible loot!

Since neither leaving loot nor solving NP-hard problems are things thieves like to do, they have asked you to compute the minimum value of the loot they must leave behind, in order to be able to split the remaining loot evenly.

입력

The first line of input contains the integer 1ドル \le k \le 10^6$ -- the number of denominations in Logland. The next line contains the $k$ integers 0ドル \le x_0, x_1, \dots, x_{k-1} \le 2^{30},ドル the number of coins of the denominations 2ドル^0, 2^1, \dots, 2^{k - 1}$.

출력

Output a single line, the minimum amount of money the thieves must leave behind. Since this number may be very large, output it modulo the prime number 10ドル^9 + 7$.

제한

예제 입력 1

4
0 2 0 1

예제 출력 1

8

예제 입력 2

5
1000000 1 1 1 1

예제 출력 2

0

예제 입력 3

5
3 3 3 3 3

예제 출력 3

1

힌트

출처

Contest > Swedish Coding Cup > HiQ Challenge 2017 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /