from fractions import gcd from datetime import date, timedelta from heapq import* import math from collections import defaultdict, Counter, deque import sys from bisect import * import itertools import copy sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 def main(): n = int(input()) p = list(map(int, input().split())) v = 1 def f(s): ret = 0 for i in range(len(str(v))): ret += int(str(v)[i]) return str(ret) t = 1 for i in range(n): v = str(p[i]) while True: s = f(v) if len(s) == 1: #print(s) break v = s t *= int(s) t = str(t) while True: s = f(t) if len(s) == 1: print(s) break v = s if __name__ == '__main__': main()