#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; void solve(){ int n; cin>>n; ll sum=1LL,ans=0; vectorp(n); rep(i,n)cin>>p[i]; rep(i,n){ sum*=p[i]; } ans=sum; string s=to_string(sum); ll t=s.size(); while(t>1){ ans=0; rep(i,s.size()){ ans+=s[i]-'0'; } s=to_string(ans); t=s.size(); } cout<