import java.util.Scanner; import java.math.BigInteger; public class Main { public static void main(String args[]){ Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); //int b = stdIn.nextInt(); //long p[] = new long[n]; //String s = stdIn.next(); //char c[] = s.toCharArray(); BigInteger sum = BigInteger.valueOf(1); //boolean flag = true; for(int i = 0; i < n; i++){ long num = stdIn.nextLong(); if(num % 3 == 0){ num = 3; } sum = sum.multiply(BigInteger.valueOf(num)); } long ans = 0; for(int j = 0; j < 1; j++){ String s = String.valueOf(sum); char c[] = s.toCharArray(); for(int i = 0; i < s.length(); i++){ ans += c[i] - 48; } } while(true){ String s = String.valueOf(ans); char c[] = s.toCharArray(); ans = 0; for(int i = 0; i < s.length(); i++){ ans += c[i] - 48; } if(ans <= 9){ break; } } System.out.println(ans); //System.out.println(); //System.out.print(); } }