class Integer def mod_pow(n, mod) x = self res = 1 while n > 0 res = res * x % mod if n[0] == 1 x = x * x % mod n >>= 1 end res end def mod_inverse(mod) mod_pow(mod - 2, mod) end end N = gets.to_i C = gets.split.map(&:to_i) S = C.sum MOD = 10 ** 9 + 7 cache = Array.new(S + 1, 1) mod = Array.new(10, 0) 2.upto(S - 1) do |x| cache[x] = cache[x - 1] * x cache[x] %= MOD end 1.upto(9) do |i| m = cache[S - 1] 1.upto(9) do |j| c = C[j - 1] next if c == 0 if i == j m *= cache[c - 1].mod_inverse(MOD) if c >= 2 else m *= cache[c].mod_inverse(MOD) end m %= MOD end mod[i] = m end ans = 0 base = 1 N.times do C.each.with_index(1) do |c, i| next if c == 0 ans += mod[i] * base * i ans %= MOD end base *= 10 base %= MOD end puts ans