from functools import reduce from operator import mul from sys import stdin def main(): input = lambda: stdin.readline()[:-1] N = int(input()) P = map(int, input().split()) k = reduce(mul, P) ans, d = 0, 1 while 1: while d > 0: d, m = divmod(k, 10) ans += m k = d if ans < 10: break d, k = 1, ans ans = 0 print(ans) main()