#include int main() { int n, ans = 1; long long int tmp; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &tmp); tmp %= 9; ans = ans * tmp % 9; } if (ans == 0) ans = 9; printf("%d\n", ans); }