Happy and Sets
Practice
4.2 (29 votes)
Approved
Combinatorics
Easy
Math
Problem
47% Success 4573 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Once Happy was playing with his friends during his maths class. Seeing this, his teacher asked him to solve a problem. The teacher gave him a set of n positive integers and asked him to tell the sum of the product of elements of all the possible subsets.

For e.g. Say, the teacher gave him a set {2, 3, 5}. The possible subsets of this set are {2}, {3}, {5}, {2, 3}, {2, 5}, {3, 5} and {2, 3, 5}. So Happy should report the answer as the sum of 2, 3, 5, 6 (2 * 3), \(10\) (2 * 5), \(15\) (3 * 5) and \(30\) (2 * 3 * 5) i.e., \(71\) to the teacher.

As the output of the problem can be large, so the teacher asked happy to report the answer modulo \(10^9\)+7 (\(1000000007\)).

INPUT:

The first line of input contains an integer n denoting the number of elements in the set and the next line consists of n space separated integers. The ith integer is denoted by a_i.

OUTPUT:

Print the answer modulo \(10^9\)+7 (\(1000000007\)).

Constraints:

1n\(10^5\)
0a_i\(10^7\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
14 votes
Tags:
CombinatoricsEasyMath
Points:20
23 votes
Tags:
Ad-HocCombinatoricsEasyImplementationMath
Points:20
8 votes
Tags:
CombinatoricsEasyMath