Sublist - Cal special sum
Dữ liệu vào: Standard input
Dữ liệu ra: Standard output
Giới hạn thời gian: 1.0 giây
Giới hạn bộ nhớ: 128 megabyte

MrBon is a newbie to mathematics, and he is very excited after knowing that a given l of cardinality N has (2N - 1) non-empty sublist. He writes down all the non-empty sublists for a given set A. For each sublist, he calculates sublist_sum, which is the sum of elements and denotes them by S1, S2, S3, ... , S(2N-1).

He then defines a special_sum, P.

\(P=2^{S_1}+2^{S_2}+...+2^{S_{(2^N-1)}}\)  and reports P % (109 + 7).

Input:
The first line contains an integer N, i.e., the size of list A.
The next line will contain N integers, each representing an element of list A.

Output:
Print special_sum, P modulo (109 + 7).

Constraints
1 ≤ N ≤ 105
0 ≤ ai ≤ 1010 , where i ∈ [1 .. N]

 

 

Ví dụ

  • input
    3
    1 1 2
    output
    44

Explanation

For given list, sublist and calculations are given below
1. {1} and 21 = 2
2. {1} and 21 = 2
3. {2} and 22 = 4
4. {1,1} and 22 = 4
5. {1,2} and 23 = 8
6. {1,2} and 23 = 8
7. {1,1,2} and 24 = 16
So total sum will be 44.

Back to Top