from functools import reduce MOD = 1000000007 def fact(n): ret = 1 for i in range(n): ret = (ret * (i + 1)) % MOD return ret n = int(input()) a = list(map(int, input().split())) facts = reduce(lambda a, x: ((fact(x) if x > 0 else 1) * a) % MOD, a, 1) sum = sum((i + 1) * c for i, c in enumerate(a)) print(facts, sum) ans = (pow(10, n, MOD) + MOD - 1) * pow(9, MOD - 2, MOD) * fact(n - 1) * pow(facts, MOD - 2, MOD) * sum % MOD print(ans)