import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; immutable long MOD = 10^^9 + 7; auto P = new long[](N+5); P[0] = P[1] = 1; foreach (i; 1..N+4) { P[i+1] = P[i] * (i + 1) % MOD; } long ans = 0; long base = 0; long tmp = 1; foreach (i; 0..N) { (base += tmp) %= MOD; tmp = tmp * 10 % MOD; } foreach (i, a; A) { long n = (i + 1).to!long; long c = P[N-1]; if (A[i] == 0) continue; foreach (j; 0..9) { if (j == i) { c = c * powmod(P[A[j]-1], MOD-2, MOD) % MOD; } else { c = c * powmod(P[A[j]], MOD-2, MOD) % MOD; } } (ans += base * n % MOD * c % MOD) %= MOD; } ans.writeln; } long powmod(long a, long x, long m) { long ret = 1; while (x) { if (x % 2) ret = ret * a % m; a = a * a % m; x /= 2; } return ret; }