#include using namespace std; template long long SumDigit(T N) { long long res = 0; while(N > 0) { res += (N % 10); N /= 10; } return res; } int main(){ int N; cin >> N; long long ans = 1; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; A[i] = SumDigit(A[i]); A[i] = SumDigit(A[i]); A[i] = SumDigit(A[i]); ans *= A[i]; } while(to_string(ans).length() > 1) { ans = SumDigit(ans); } cout << ans << endl; return 0; }