Under construction

Still being built. Things may change

Misha's Product

Interview

Time limit1sMemory limit512 MB

Summary
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 a1,a2,…,ana_1, a_2, \ldots, a_n is defined as follows. Consider all ordered pairs (ai,aj)(a_i, a_j) of distinct numbers from this set. For each pair, write the two numbers one after another with no space to get a new number bijb_{ij}. Misha's product of the initial set is the sum of all values bijb_{ij}.

Help Misha calculate Misha's product for the given set of integers. Misha wants to compute it modulo 109+710^9 + 7.

Input

The first line contains one integer nn, the number of elements in the set (2≤n≤1052 \le n \le 10^5).

The second line contains nn distinct integers a1,a2,…,ana_1, a_2, \ldots, a_n, the numbers in the set (1≤ai≤1081 \le a_i \le 10^8).

Output

Output one number: Misha's product of the given set of numbers, modulo 109+710^9 + 7.

Hint

There are six possible pairs in the sample test, and the following values bijb_{ij} are obtained: 13, 31, 101, 103, 110, 310. Their sum is 668.

Examples1

  1. Example 1

    Input
    3
    1 3 10
    
    Expected output
    668