N = int(input()) P = list(map(int, input().split())) K = 1 for p in P: K *= p if K == 0: print(K) exit() age = list(map(int, str(K))) while len(age) > 1: age[0:2] = list(map(int, str(sum(age[0:2])))) print(age[0])