#include using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; long p[n]; unsigned long long total = 1LL; for(int i = 0; i < n; i++) { cin >> p[i]; total *= p[i]; } auto f = [&] (ll c) { ll digit = 0ll; while(c > 0) { digit += c % 10; c = c / 10; } return digit; }; while(true) { if(total <= 9) { break; } total = f(total); } cout << total << endl; }