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