from functools import reduce def f(x, y): t = x * y % 9 if t == 0: return 9 return t N, *P = map(int, open(0).read().split()) print(reduce(f, P, 1))