#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <cmath>
#include <set>
#include <stack>
#include <cmath>
using namespace std;
#define MAXN 100005
int a[MAXN],b[MAXN],c[MAXN];
vector<int> d[MAXN];
void gen(){
for (int i = 1; i < MAXN; i++) {
for (int j = 1; i * j < MAXN; j++) {
d[i*j].push_back(i);
}
}
}
int vis[MAXN];
void solve(int n){
//->
memset(vis, -1, sizeof(vis));
for (int i = 1;i <= n; i++) {
int now = a[i];
if (vis[now] != -1) {
b[i] = vis[now];
}
for (int j = 0;j < d[now].size(); j++) {
vis[d[now][j]] = now;
}
if (b[i] == -1) {
b[i] = now;
}
}
//<-
memset(vis, -1, sizeof(vis));
for (int i = n; i >= 1; i--) {
int now = a[i];
if (vis[now] != -1) {
c[i] = vis[now];
}
for (int j = 0; j < d[now].size(); j++) {
vis[d[now][j]] = now;
}
if (c[i] == -1) {
c[i] = now;
}
}
}
int main(){
gen();
int n = 0;
while(scanf(" %d",&n) != EOF && n){
memset(a, -1, sizeof(a));
memset(b, -1, sizeof(b));
memset(c, -1, sizeof(c));
for (int i = 1; i <= n; i++) {
scanf(" %d",&a[i]);
}
solve(n);
long long res = 0;
for (int i = 1; i <= n; i++) {
res += (long long)b[i] * (long long)c[i];
}
printf("%lldn",res);
}
return 0;
}