Sum of Digits

0

0 votes
Ad-Hoc, approved, Easy, Approved
Problem

You are given an array of N distinct numbers. Now, we call the Digit Value of a number to be the sum of its digits..

Now, a subset is a set of not-necessarily-contiguous array elements. We call the value of a set to be the the maximum over the Digit Value of all elements it contains.

Now, you need to find the summation of the values of all 2N1 non-empty subsets of this array. As the answer can be rather large, print it Modulo 109+7. Can you do it ?

Input Format :

The first line contains a single integer N. The next line contains N space separated integers, where the ith integer denotes A[i].

Output Format :

Print the summation of the value of each non-empty subset of the given array Modulo 109+7.

Constraints :

1N105

0A[i]1018

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The subsets of this array and their values are :

  1. (10) : 1

  2. (20) : 2

  3. (30) : 3

  4. (10,20) : 2

  5. (10, 30) : 3

  6. (20,30) : 3

  7. (10,20,30 ) : 3

Thus, the final answer is (1+2+3+2+3+3+3) = 17

Editor Image

?