import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) p = list(map(int, readline().split())) k = 1 for pp in p: k *= pp k = str(sum(map(int, str(k)))) while len(k) != 1: k = str(sum(map(int, str(k)))) print(k)