#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; ll P, K = 1; cin >> N; REP(i, N){ cin >> P; K *= P; } while(K > 9){ int s = (int)log10(K) + 1; ll tmp = 0; REP(i, s){ tmp += K % 10; K /= 10; } K = tmp; } cout << K << endl; }