import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] p = new long[n]; for (int i = 0; i < p.length; i++) { p[i] = sc.nextLong(); } sc.close(); if (n == 0) { System.out.println(0); return; } long ans = 1; for (int i = 0; i < n; i++) { if (p[i] == 0) { System.out.println(0); return; } ans *= p[i]; ans %= 9; } if (ans == 0) { System.out.println(9); } else { System.out.println(ans); } } }