from functools import reduce N = int(input()) print(reduce(lambda x, y: x * y % 9, map(int, input().split()), 1) or 9)