#include #include #include #define ll long long #define eps 1e-9 #define PI 2 * acos (0.0) #define mod 1000000007 using namespace std; int bs(int *st,int *en,int val,char c) // en = size+1 { int k; //first element not less than val,else returns last if(c=='l') k=lower_bound(st,en,val)-st; //first element greater than val,else returns last if(c=='u') k=upper_bound(st,en,val)-st; return k; } int prime[78500]; int sieve() // RETURNS ACTUAL SIZE!!! NOT SIZE+1!!!! REMEMBER WELL!! >_< { int a,b,c; c=0; prime[c]=2; bool *m=(bool *)calloc(1000006,sizeof(bool)); for(a=3;a<=1000000;a=a+2) { if(!m[a]) { prime[++c]=a; for(b=2*a;b<=1000000;b=b+a) m[b]=true; } } free(m); return c; } // inverse mod of i%prime = bigmod(i,prime-2) ll bigmod(ll i,ll pow) { if(pow<1) return 1; if(pow==1) return i%mod; ll j; if(pow%2) { j=(i*bigmod(i,pow-1))%mod; } else { j=bigmod(i,pow/2); j=(j*j)%mod; } return j; } int cnt[100005]; int ar[100005]; int main() { // freopen("0.in","r",stdin); // freopen("0.out","w",stdout); /* cout << fixed << setprecision(4); std::ios::sync_with_stdio(false); */ int a,b,c,d,e,x,y,z,n,t; while(scanf("%d",&n)==1) { //cin>>n; x=0; for(a=0;a<=10000;a++) cnt[a]=0; for(a=1;a<=n;a++) { cin>>ar[a]; cnt[ ar[a] ]=a; } for(a=1;a<=10000;a++) { if(!cnt[a]) continue; y=n+5; for(b=2*a;b<=100000;b=b+a) { if(cnt[b]>cnt[a]) y=min(y,cnt[b]); } if(y!=n+5){ x=x+y; } } cout<