#include using namespace std; #define ll long long #define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define mp make_pair #define cps CLOCKS_PER_SEC #define mod (ll)1000000007 #define f first #define s second #define debug1(x) cout< #define pii pair #define pb push_back #define mxn 1000005 vector a(mxn); vector b(mxn); void sieve(){ b[0]=b[1]=1; for(int i=4; i>1; } return r; } ll modexp(ll x,ll n,ll m){ ll r=1; while(n){ if(n&1) r=mulmod(r,x,m); x=mulmod(x,x,m); n=n>>1; } return r; } bool millerrabin(ll d,ll n){ ll a=1+rand()%(n-1); ll x=modexp(a,d,n); if(x==1||x==n-1) return true; while(d!=n-1&&x!=n-1){ x=mulmod(x,x,n); d*=2; } if(x!=n-1) return false; return true; } bool isprime(ll n){ if(n==2||n==3) return true; if(n<=1||(n&1)==0) return false; ll d=n-1; while(d%2==0) d>>=1; for(int i=0; i<4; ++i){ if(!millerrabin(d,n)) return false; } return true; } ll mv(ll x){ ll y=0; while(x){ if(x==1){ ++y; break; } if(isprime(x)){ y+=x+1; return y; } if(x%2==0){ y+=x; x>>=1LL; } else{ for(ll i=3;i*i<=x; i+=2) if(x%i==0){ y+=x; x/=i; break;}}} return y; } int main(){ //sp; pre(); ll moves=0; ll n,x; cin>>n; while(n--){ cin>>x; if(x