import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,*A = map(int,read().split()) x = 1 for a in A: x *= a; x %= 9 if x == 0: x = 9 print(x)