QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB
[0]

# 3735. Reverse

Statistics

Bobo has a n digits decimal number D=d1d2dn (It may have leading zeros).

Let R(i,j) denotes number D with digits between the i-th position and j-th position reversed. That is, R(i,j)=d1di1djdj1didj+1dj+2dn.

Bobo would like to find ni=1nj=iR(i,j) modulo (109+7).

Input

The input contains at most 30 sets. For each set:

The first line contains an integer n (1n105).

The second line contains n digits d1d2dn (0di9).

Output

For each set, an integer denotes the result.

Sample Input

2
12
3
012
10
0123456789

Sample Output

45
369
733424314