SUM OF SQUARES

Given an array of integers A of size N.

Value of a subset of array A is defined as sum of squares of all numbers in that subset.

Calculate and return Sum of values of all possible non-empty subsets of array A % (10^9 + 7).



Input Format

The first and only argument given is the integer array A.

Output Format

Calculate and return Sum of values of all possible non-empty subsets of array A% (10^9+ 7).

Constraints

1 <= N <= 10^5
1 <= A[i] < 2^31

For Example

Input 1:
    A = [3, 7]
Output 1:
    116
Explaination 1:
    Value ( [3] ) = 9
    value ( [7] ) = 49
    value ( [3, 7] ) = 9 + 49 = 58
    answer = (9 + 49 + 58) % 1000000007 = 116

Input 2:
    A = [4]
Output 2:
    16
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving SUM OF SQUARES on Interview Code Editor
Sign Up
to access hints and editorial solutions for SUM OF SQUARES

Discussion


Loading...
Click here to start solving coding interview questions