P21057 [HackerRank] Manasa and pizza
普及
题目描述

With the college fest approaching soon, Manasa is following a strict dieting regime . Today, she just cannot resist her temptation for having a pizza. An inner conflict ensues, and she decides that she will have a pizza, only if she comes up with a solution to the problem stated below. Help her get the pizza for herself.

Given a list L of N numbers, where

L = { a_{1}, a_{2}, a_{3}, a_{4} .... , a_{N}}

Find the value of M that is computed as described below.

Input Format

The first line contains an integer N i.e. size of the list L.

The next line contains N space separated integers, each representing an element of the list L.

Output Format

Print the value of M modulo (10^{9} + 7).

Constraints

1 ≤ N ≤ 5100

0 ≤ a_{i} ≤ 10^{15} , where i ∈ [1 .. N]

Sample Input 00

3
1 2 3

Sample Output 00

40392

Explanation

There are 8 subsets of given set,

S = {1,2,3} and L - S ={0} value of F(6) = 19601
S = {1,2} and L - S ={3} value of F(0) = 1
S = {1,3} and L - S ={2} value of F(2) = 17
S = {2,3} and L - S ={1} value of F(4) = 577
S = {1} and L - S ={2,3} value of F(4) = 577
S = {2} and L - S ={1,3} value of F(2) = 17
S = {3} and L - S ={1,2} value of F(0) = 1
S = {} and L - S ={1,2,3} value of F(6) = 19601

Adding all these values, we get M = 40392.

输入格式

见题面

输出格式

见题面

样例输入
3 1 2 3
样例输出
40392