from functools import reduce N, *P = map(int, open(0).read().split()) print(reduce(lambda x, y: x * y % 9, P))