Yasin has an array *a* containing *n* integers. Yasin is a 5 year old, so he loves ultimate weird things.

Yasin denotes weirdness of an array as maximum *gcd*(*a*<sub class="lower-index">*i*</sub>,  *a*<sub class="lower-index">*j*</sub>) value among all 1 ≤ *i* &lt; *j* ≤ *n*. For *n* ≤ 1 weirdness is equal to 0, *gcd*(*x*,  *y*) is the greatest common divisor of integers *x* and *y*.

He also defines the ultimate weirdness of an array. Ultimate weirdness is <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/6ef04f31fc88d23b93e68a317d597db92d1375da.png" style="max-width: 100.0%;max-height: 100.0%;"/> where *f*(*i*,  *j*) is weirdness of the new array *a* obtained by removing all elements between *i* and *j* inclusive, so new array is [*a*<sub class="lower-index">1</sub>... *a*<sub class="lower-index">*i* - 1</sub>, *a*<sub class="lower-index">*j* + 1</sub>... *a*<sub class="lower-index">*n*</sub>].

Since 5 year old boys can't code, Yasin asks for your help to find the value of ultimate weirdness of the given array *a*!
The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 200 000) — the number of elements in *a*.

The next line contains *n* integers *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 200 000), where the *i*-th number is equal to the *i*-th element of the array *a*. It is guaranteed that all *a*<sub class="lower-index">*i*</sub> are distinct.
Consider the first sample.
 -  *f*(1,  1) is equal to 3. -  *f*(2,  2) is equal to 1. -  *f*(3,  3) is equal to 2. -  *f*(1,  2), *f*(1,  3) and *f*(2,  3) are equal to 0.
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef unsigned int ui;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
const int maxn = 200010;
int n, st, ed, value, maxv, a[maxn];
vector<int> b[maxn], v[maxn];
LL H[maxn];
struct seg {
	int len, minv, tag;
	LL sum;
} seg[maxn * 4];
void prepare() {
	scanf("%d", &n);
	maxv = 1;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		maxv = max(maxv, a[i]);
		v[a[i]].PB(i);
	}
	for (int i = 1; i <= maxv; ++i) {
		for (int j = i; j <= maxv; j += i)
			for (auto k : v[j])
				b[i].PB(k);
	}
	
	for (int i = 1; i <= maxv; ++i)
		sort(b[i].begin(), b[i].end());
}
inline void update(int tot) {
	seg[tot].sum = seg[tot * 2].sum + seg[tot * 2 + 1].sum;
	seg[tot].minv = min(seg[tot * 2].minv, seg[tot * 2 + 1].minv);
}
inline void calc(int tot, int v) {
	seg[tot].minv = seg[tot].tag = v;
	seg[tot].sum = 1LL * seg[tot].len * v;
}
inline void down(int tot) {
	if (seg[tot].tag) {
		calc(tot * 2, seg[tot].tag);
		calc(tot * 2 + 1, seg[tot].tag);
		seg[tot].tag = 0;
	}
}
void build(int tot, int l, int r) {
	seg[tot].len = r - l + 1;
	if (l == r) {
		seg[tot].minv = seg[tot].sum = l;
		return;
	}
	int mid = (l + r) / 2;
	build(tot * 2, l, mid);
	build(tot * 2 + 1, mid + 1, r);
	update(tot);
}
int bound(int tot, int l, int r) {
	if (l == r) {
		return seg[tot].minv < value ? l : 0;
	}
	down(tot);
	int mid = (l + r) / 2;
	if (seg[tot * 2 + 1].minv < value) return bound(tot * 2 + 1, mid + 1, r);
	else return bound(tot * 2, l, mid); 
}
void modify(int tot, int l, int r) {
	if (st <= l && ed <= r) {
		calc(tot, value);
		return;
	}
	down(tot);
	int mid = (l + r) / 2;
	if (st <= mid) modify(tot * 2, l, mid);
	if (mid < ed) modify(tot * 2 + 1, mid + 1, r);
	update(tot);
}
void calc(int l, int r, int v) {
	value = v;
	int p = bound(1, 1, n);
	if (p >= l) {
		st = l; ed = min(p, r);
		modify(1, 1, n);
	}
}
int main() {
	prepare();
	build(1, 1, n);
	
	for (int i = maxv + 1; i >= 1; --i) {
		int k = b[i].size();
		if (k > 1) {
			calc(1, b[i][0], b[i][k - 2]);
			calc(b[i][0] + 1, b[i][1], b[i][k - 1]);
			if (b[i][k - 1] < n) calc(b[i][k - 1] + 1, n, n + 1); 
		}
		H[i] = 1LL * (n + 1) * n - seg[1].sum;
	}
	LL ans = 0;
	for (int i = 1; i <= maxv; ++i) 
		ans += 1LL * (H[i + 1] - H[i]) * i;
	cout << ans << endl;	
	return 0;
}