//GNC #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; ll gcd(ll x, ll y) { if(y == 0) return x; return gcd(y, x%y); } ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } ll exgcd(ll a, ll b, ll& x, ll& y) { if(b == 0LL){ x = 1LL; y = 0LL; return a; }else{ ll d = exgcd(b, a%b, y, x); y -= a / b * x; return d; } } /* bool isprime(int p) { switch (p) { case 2: case 3: case 5: case 7: case 11: case 13: case 17: case 19: case 23: case 29: case 31: case 37: return true; default: return false; } } ll chinese_remainder(ll a, ll cur_lcm, ll remind, ll modulo) { ll a = exgcd( } */ int main(void) { int N; ifstream cin("moduloscope.in"); while(cin >> N && N){ ll current = 0; ll curlcm = 1; for(int i = 1; i <= N; ++i){ ll mod; cin >> mod; for(;;){ if(current % (ll)i == mod) break; current += curlcm; } curlcm = lcm(curlcm, (ll)i); } cout << current << endl; } return 0; }