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