#include #include #include #include using namespace std; using ll = long long int; int main() { ll n, ans = 1; cin >> n; for(int i=0;i> a; ans *= a; ans %= 9; } if(ans == 0) ans = 9; cout << ans << endl; return 0; }