import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static void myout(Object t){System.out.println(t);} static String getStr(){return sc.next();} static int getInt(){return sc.nextInt();} static Long getLong(){return sc.nextLong();} static boolean isNext(){return sc.hasNext();} public static void main(String[] args){ int N = getInt(); long[] list = new long[N]; long output = 1; for(int i = 0; i < N; i++){ long p = getLong() % 9; if(p == 0){ p = 9; } list[i] = p; } for(int i = 0; i < N; i++){ output = (output * list[i]) % 9; if(output == 0){ output = 9; } } myout(output); } //便利メソッド追加枠ここから //便利メソッド追加枠ここまで }