#include #include #include #include #include #include #include #include #include #include using namespace std; #define next '\n' #define rep(i, n) for(int (i) = (0); (i) < (n); (i++)) using ll = long long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int ans = 1; rep(i, n){ int p; cin >> p; p = p % 9; ans *= p; ans = ans % 9; } if(ans == 0){ cout << 9; }else{ cout << ans; } cout << next; }