#include #define REP(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); int N, P; ll K = 1; cin >> N; REP(i, N){ cin >> P; K *= P; } while(K > 9){ int s = to_string(K).size(); ll ans = 0; REP(i, s){ ans += K % 10; K /= 10; } K = ans; } cout << K << endl; }