#include using namespace std; int main() { int n, ans = 1; scanf("%d", &n); for (int i = 0; i < n; i++) { int64_t p; scanf("%ld", &p); if (p == 0) { puts("0"); return 0; } (ans *= p % 9) %= 9; } if (ans == 0) ans = 9; printf("%d\n", ans); }