Misha's Product
InterviewTime limit1sMemory limit512 MB
Given n distinct integers, concatenate every ordered pair of them and report the sum of all these concatenations modulo 1e9+7.
- Level
Medium4 of 10
- Topics
- Math, Array, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
Misha really loves inventing new operations. Recently he invented a new operation, which he named Misha's product after himself.
Misha's product of a set of distinct integers is defined as follows. Consider all ordered pairs of distinct numbers from this set. For each pair, write the two numbers one after another with no space to get a new number . Misha's product of the initial set is the sum of all values .
Help Misha calculate Misha's product for the given set of integers. Misha wants to compute it modulo .
Input
The first line contains one integer , the number of elements in the set ().
The second line contains distinct integers , the numbers in the set ().
Output
Output one number: Misha's product of the given set of numbers, modulo .
Hint
There are six possible pairs in the sample test, and the following values are obtained: 13, 31, 101, 103, 110, 310. Their sum is 668.