import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long ans = 1; for (int i = 0; i < n; i++) { ans = getOne(ans * getOne(sc.nextLong())); } System.out.println(ans); } static long getOne(long x) { while (x >= 10) { long y = 0; while (x > 0) { y += x % 10; x /= 10; } x = y; } return x; } }