#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;
mt19937 gen(time(0));
int rdint(int l, int r) { return uniform_int_distribution<int>(l, r)(gen); }
int n, a[N], res[N], tot, b[N];
vector<int> fac[N];
int vis[N], d[N], vd[N];
int sol(int n, int *a) {
  vector<int> vc;
  for (int i = 1; i <= n; i++)
    for (int x : fac[a[i]]) {
      if (!vis[x]) vc.push_back(x);
      vis[x] += vd[b[i]];
    }
  sort(vc.begin(), vc.end());
  reverse(vc.begin(), vc.end());
  int ans = 0;
  for (int x : vc) {
    int sum = 1ll * vis[x] * (vis[x] - 1) / 2 % mod;
    sum = (sum + mod - d[x]) % mod;
    for (int y : fac[x])
      if (y != x) d[y] = (d[y] + sum) % mod;
    ans = (ans + 1ll * sum * x % mod) % mod;
    vis[x] = d[x] = 0;
  }
  return ans;
}
int main() {
  for (int i = 1; i <= 100000; i++)
    for (int j = i; j <= 100000; j += i) fac[j].push_back(i);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int d = n; d >= 1; d--) {
    tot = 0;
    for (int i = d; i <= n; i += d) {
      if (!vd[a[i]]) b[++tot] = a[i];
      vd[a[i]]++;
    }
    res[d] = sol(tot, b);
    for (int i = d; i <= n; i += d) vd[a[i]] = 0;
    for (int i = d + d; i <= n; i += d) res[d] = (res[d] + mod - res[i]) % mod;
    ans = (ans + 1ll * d * res[d]) % mod;
  }
  ans = ans * 2 % mod;
  for (int i = 1; i <= n; i++) ans = (ans + 1ll * a[i] * i % mod) % mod;
  printf("%d\n", ans);
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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 N = 1e5 + 5, mod = 1e9 + 7;
mt19937 gen(time(0));
int rdint(int l, int r) { return uniform_int_distribution<int>(l, r)(gen); }
int n, a[N], res[N], tot, b[N];
vector<int> fac[N];
int vis[N], d[N], vd[N];
int sol(int n, int *a) {
  vector<int> vc;
  for (int i = 1; i <= n; i++)
    for (int x : fac[a[i]]) {
      if (!vis[x]) vc.push_back(x);
      vis[x] += vd[b[i]];
    }
  sort(vc.begin(), vc.end());
  reverse(vc.begin(), vc.end());
  int ans = 0;
  for (int x : vc) {
    int sum = 1ll * vis[x] * (vis[x] - 1) / 2 % mod;
    sum = (sum + mod - d[x]) % mod;
    for (int y : fac[x])
      if (y != x) d[y] = (d[y] + sum) % mod;
    ans = (ans + 1ll * sum * x % mod) % mod;
    vis[x] = d[x] = 0;
  }
  return ans;
}
int main() {
  for (int i = 1; i <= 100000; i++)
    for (int j = i; j <= 100000; j += i) fac[j].push_back(i);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int d = n; d >= 1; d--) {
    tot = 0;
    for (int i = d; i <= n; i += d) {
      if (!vd[a[i]]) b[++tot] = a[i];
      vd[a[i]]++;
    }
    res[d] = sol(tot, b);
    for (int i = d; i <= n; i += d) vd[a[i]] = 0;
    for (int i = d + d; i <= n; i += d) res[d] = (res[d] + mod - res[i]) % mod;
    ans = (ans + 1ll * d * res[d]) % mod;
  }
  ans = ans * 2 % mod;
  for (int i = 1; i <= n; i++) ans = (ans + 1ll * a[i] * i % mod) % mod;
  printf("%d\n", ans);
}

```