N = int(input()) P = list(map(int, input().split())) ans = 1 for x in P: ans *= x ans %= 9 print((ans - 1) % 9 + 1)