from functools import reduce from operator import mul N = int(input()) P = list(map(int, input().split())) K = reduce(mul, P) while K >= 10: t = 0 while K != 0: t += K % 10 K //= 10 K = t print(K)