#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 100010;
int a[N];
int miu[N];
int dmiu[N];
int primes[N];
vector<int> fac[N];
bool vis[N];
int phi[N];
void init() {
  int tot = 0;
  miu[1] = phi[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!vis[i]) {
      miu[i] = -1;
      primes[tot++] = i;
      phi[i] = i - 1;
    }
    for (int j = 0; i * primes[j] < N && j < tot; j++) {
      int x = i * primes[j];
      vis[x] = true;
      if (i % primes[j] == 0)
        miu[x] = 0, phi[x] = phi[i] * primes[j];
      else
        miu[x] = -miu[i], phi[x] = phi[i] * (primes[j] - 1);
      if (i % primes[j] == 0) break;
    }
  }
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j += i) {
      dmiu[j] += miu[i] * (j / i);
      fac[j].push_back(i);
    }
  }
}
int _gcd(int a, int b) { return b ? _gcd(b, a % b) : a; }
long long sum[N];
int occ[N];
int times;
int solve(vector<int> &v) {
  long long ans = 0;
  ++times;
  for (int i = 0; i < v.size(); i++) {
    int x = v[i];
    for (int j = 0; j < fac[x].size(); j++) {
      int y = fac[x][j];
      if (occ[y] != times) {
        occ[y] = times;
        sum[y] = phi[y];
      } else {
        sum[y] += phi[y];
      }
    }
  }
  for (int i = 0; i < v.size(); i++) {
    int x = v[i];
    for (int j = 0; j < fac[x].size(); j++) {
      int y = fac[x][j];
      ans += sum[y];
    }
  }
  return ans % mod;
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    vector<int> v;
    for (int j = i; j <= n; j += i) {
      v.push_back(a[j]);
    }
    ans = (ans + 1LL * dmiu[i] * solve(v)) % mod;
  }
  if (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}

### Prompt

Please create a solution in CPP 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 mod = 1000000007;
const int N = 100010;
int a[N];
int miu[N];
int dmiu[N];
int primes[N];
vector<int> fac[N];
bool vis[N];
int phi[N];
void init() {
  int tot = 0;
  miu[1] = phi[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!vis[i]) {
      miu[i] = -1;
      primes[tot++] = i;
      phi[i] = i - 1;
    }
    for (int j = 0; i * primes[j] < N && j < tot; j++) {
      int x = i * primes[j];
      vis[x] = true;
      if (i % primes[j] == 0)
        miu[x] = 0, phi[x] = phi[i] * primes[j];
      else
        miu[x] = -miu[i], phi[x] = phi[i] * (primes[j] - 1);
      if (i % primes[j] == 0) break;
    }
  }
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j += i) {
      dmiu[j] += miu[i] * (j / i);
      fac[j].push_back(i);
    }
  }
}
int _gcd(int a, int b) { return b ? _gcd(b, a % b) : a; }
long long sum[N];
int occ[N];
int times;
int solve(vector<int> &v) {
  long long ans = 0;
  ++times;
  for (int i = 0; i < v.size(); i++) {
    int x = v[i];
    for (int j = 0; j < fac[x].size(); j++) {
      int y = fac[x][j];
      if (occ[y] != times) {
        occ[y] = times;
        sum[y] = phi[y];
      } else {
        sum[y] += phi[y];
      }
    }
  }
  for (int i = 0; i < v.size(); i++) {
    int x = v[i];
    for (int j = 0; j < fac[x].size(); j++) {
      int y = fac[x][j];
      ans += sum[y];
    }
  }
  return ans % mod;
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    vector<int> v;
    for (int j = i; j <= n; j += i) {
      v.push_back(a[j]);
    }
    ans = (ans + 1LL * dmiu[i] * solve(v)) % mod;
  }
  if (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}

```