#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**8) inf = float('inf') ans =tmp=0 count = 1 n=int(input()) P=list(map(int,input().split())) for i in range(n): count*=P[i] while len(str(count))!=1: tmp=0 for si in str(count): tmp+=int(si) count=tmp print(count) # print(ans)