1 #include<cstdio>
2 #include<algorithm>
3 #include<cstring>
4 using namespace std;
5 const int maxn = 10050;
6 int num[maxn]; int vis[maxn];
7 int main()
8 {
9 int n;
10 while(scanf("%d", &n) == 1) {
11 int maxnum = 0;
12 for(int i = 0 ; i < n ; i++) scanf("%d", &num[i]), maxnum = max(maxnum, num[i]);
13 memset(vis, 0, sizeof(vis));
14 int ans = 0;
15 for(int i = n - 1 ; i >= 0 ;i--) {
16 vis[num[i]] = i + 1; int id = 0x3f3f3f3f;
17 for(int j = num[i] * 2 ; j <= maxnum ; j += num[i]) {
18 if(vis[j])
19 id = min(id, vis[j]);
20 }
21 if(id != 0x3f3f3f3f) ans += id;
22 ///printf("%d\n", ans);
23 }
24 printf("%d\n", ans);
25 }
26 return 0;
27 }