#!/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] count=list(map(int,list(str(count)))) while len(count)!=1: count = list(map(int, list(str(sum(count))))) print(count[0]) # print(ans)