A Math Contest P2 - Subsequence Sum

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

You are given an array of N integers, a1,a2,,aN. Find the sum of all of its subsequence sums modulo 109+7.

Constraints

1N106

1ai109

Input Specification

The first line contains an integer, N.

The next line contains N space-separated integers, a1,a2,,aN.

Output Specification

Output the sum of all subsequence sums modulo 109+7.

Sample Input

Copy
3
1 2 3

Sample Output

Copy
24

Explanation for Sample

The subsequence sums are

  • 1=1
  • 1+2=3
  • 1+3=4
  • 1+2+3=6
  • 2=2
  • 2+3=5
  • 3=3

The sum of all subsequence sums is 1+3+4+6+2+5+3=24.


Comments

There are no comments at the moment.