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