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