#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){ ll tmp = 0; while(K > 0){ tmp += K % 10; K /= 10; } K = tmp; } cout << K << endl; }