#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
vector<int> g[maxn];
int n, a[maxn], nxt[maxn], gcd;
long long ans;
void work(int l, int r) {
  for (int i = l; i <= min(r, n); i++)
    if (nxt[i] < r) {
      ans += (long long)gcd * (r - nxt[i]);
      nxt[i] = r;
    } else
      break;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int li = sqrt(a[i]);
    nxt[i] = i;
    for (int j = 1; j <= li; j++)
      if (a[i] % j == 0) {
        g[a[i] / j].push_back(i);
        if (j * j != a[i]) g[j].push_back(i);
      }
  }
  for (gcd = 200000; gcd; gcd--) {
    if (g[gcd].size() < 2) continue;
    work(g[gcd][1] + 1, n + 1);
    work(g[gcd][0] + 1, g[gcd][g[gcd].size() - 1]);
    work(1, g[gcd][g[gcd].size() - 2]);
  }
  cout << ans << endl;
  return 0;
}
