#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
const int mo = 1000000007;
int n, a[100010], phi[100010], num[100010], po[100010], tot;
long long res, ans;
vector<int> ys[100010];
void init() {
  for (int i = 1; i <= maxn; i++)
    for (int j = i; j <= maxn; j += i) ys[j].push_back(i);
  phi[1] = 1;
  for (int i = 2; i <= maxn; i++) {
    int tmp = 1, tmpp = i;
    while (tmpp % ys[i][1] == 0) {
      tmpp /= ys[i][1];
      tmp *= ys[i][1];
    }
    if (tmpp == 1)
      phi[i] = (ys[i][1] - 1) * (i / ys[i][1]);
    else
      phi[i] = phi[tmp] * phi[tmpp];
  }
}
void ins(int x, int y) {
  for (int i = 0; i < ys[x].size(); i++) {
    res = (res - 1ll * phi[ys[x][i]] * num[ys[x][i]] * num[ys[x][i]]) % mo;
    num[ys[x][i]] += y;
    res = (res + 1ll * phi[ys[x][i]] * num[ys[x][i]] * num[ys[x][i]]) % mo;
  }
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    tot = 0;
    for (int j = i; j <= n; j += i) po[tot++] = a[j];
    sort(po, po + tot);
    int k = 0;
    for (int j = 0; j < tot; j = k) {
      while (k < tot && po[k] == po[j]) k++;
      ins(po[j], k - j);
    }
    ans = (ans + res * phi[i]) % mo;
    k = 0;
    for (int j = 0; j < tot; j = k) {
      while (k < tot && po[k] == po[j]) k++;
      ins(po[j], j - k);
    }
  }
  ans = (ans + mo) % mo;
  printf("%lld\n", ans);
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

Mr. Chanek has an array a of n integers. The prettiness value of a is denoted as:

$$$∑_{i=1}^{n} {∑_{j=1}^{n} {\gcd(a_i, a_j) ⋅ \gcd(i, j)}}$$$

where \gcd(x, y) denotes the greatest common divisor (GCD) of integers x and y.

In other words, the prettiness value of an array a is the total sum of \gcd(a_i, a_j) ⋅ \gcd(i, j) for all pairs (i, j).

Help Mr. Chanek find the prettiness value of a, and output the result modulo 10^9 + 7!

Input

The first line contains an integer n (2 ≤ n ≤ 10^5).

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^5).

Output

Output an integer denoting the prettiness value of a modulo 10^9 + 7.

Example

Input


5
3 6 2 1 4


Output


77

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
const int mo = 1000000007;
int n, a[100010], phi[100010], num[100010], po[100010], tot;
long long res, ans;
vector<int> ys[100010];
void init() {
  for (int i = 1; i <= maxn; i++)
    for (int j = i; j <= maxn; j += i) ys[j].push_back(i);
  phi[1] = 1;
  for (int i = 2; i <= maxn; i++) {
    int tmp = 1, tmpp = i;
    while (tmpp % ys[i][1] == 0) {
      tmpp /= ys[i][1];
      tmp *= ys[i][1];
    }
    if (tmpp == 1)
      phi[i] = (ys[i][1] - 1) * (i / ys[i][1]);
    else
      phi[i] = phi[tmp] * phi[tmpp];
  }
}
void ins(int x, int y) {
  for (int i = 0; i < ys[x].size(); i++) {
    res = (res - 1ll * phi[ys[x][i]] * num[ys[x][i]] * num[ys[x][i]]) % mo;
    num[ys[x][i]] += y;
    res = (res + 1ll * phi[ys[x][i]] * num[ys[x][i]] * num[ys[x][i]]) % mo;
  }
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    tot = 0;
    for (int j = i; j <= n; j += i) po[tot++] = a[j];
    sort(po, po + tot);
    int k = 0;
    for (int j = 0; j < tot; j = k) {
      while (k < tot && po[k] == po[j]) k++;
      ins(po[j], k - j);
    }
    ans = (ans + res * phi[i]) % mo;
    k = 0;
    for (int j = 0; j < tot; j = k) {
      while (k < tot && po[k] == po[j]) k++;
      ins(po[j], j - k);
    }
  }
  ans = (ans + mo) % mo;
  printf("%lld\n", ans);
}

```