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 mod = Array.new(10, 0) b = 1 2.upto(S - 1) do |x| b *= x b %= MOD end 1.upto(9) do |i| m = b 1.upto(9) do |j| next if i == j next if C[j - 1] == 0 m *= C[j - 1].mod_inverse(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