#include #include #include #include #include #include using namespace std; #define maxn 111111 #define INF 1111111 int num[maxn]; int index[maxn]; int main() { int aaa; int n,i, j; while(scanf("%d",&n)!=EOF) { memset(index,-1,sizeof(index)); vector ve; for(i=1;i<=n;i++) { scanf("%d",&num[i]); } index[num[n]] = n; int sum = 0; for(i=n-1;i>=1;i--) { int flag = INF; for(j=num[i];j<=10000;j+=num[i]) { if(index[j]==-1) continue; flag = min(flag,index[j]); } if(flag!=INF) sum+=flag; if(index[num[i]]==-1) index[num[i]] = i; } printf("%d\n",sum); } return 0; }