#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int MOD = (int)1e9 + 7;
const int N = (int)2e5;
const long long INF = (long long)1e18;
int T;
int n;
int v[100005], w[100005];
int dp[100005], dp2[100005];
int f[100005];
vector<int> divs[100005];
int lgput(int n, long long p) {
  int ans = 1, first = n;
  while (p) {
    if (p & 1) ans = 1LL * ans * first % MOD;
    first = 1LL * first * first % MOD;
    p >>= 1;
  }
  return ans;
}
void precalc() {
  for (int i = 1; i <= 100000; i++) {
    for (int j = i; j <= 100000; j += i) divs[j].push_back(i);
  }
}
int solve(int v[], int n) {
  int ans = 0;
  vector<int> vals;
  for (int i = 1; i <= n; i++) {
    for (auto &d : divs[v[i]]) {
      if (!f[d]) vals.push_back(d);
      f[d]++;
    }
  }
  for (int i = (int)vals.size() - 1; i >= 0; i--) {
    int nr = vals[i];
    dp2[nr] = (dp2[nr] + 1LL * f[nr] * f[nr]) % MOD;
    ans = (ans + 1LL * nr * dp2[nr]) % MOD;
    for (auto &d : divs[nr]) {
      dp2[d] = (dp2[d] - dp2[nr] + MOD) % MOD;
    }
  }
  for (auto &d : vals) f[d] = dp2[d] = 0;
  return ans;
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  int ans = 0;
  for (int d = n; d >= 1; d--) {
    int m = 0;
    for (int i = d; i <= n; i += d) {
      w[++m] = v[i];
    }
    dp[d] = solve(w, m);
    for (int i = 2 * d; i <= n; i += d) {
      dp[d] = (dp[d] - dp[i] + MOD) % MOD;
    }
    ans = (ans + 1LL * d * dp[d]) % MOD;
  }
  cout << ans << "\n";
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  T = 1;
  precalc();
  for (; T; T--) {
    solve();
  }
  return 0;
}

### Prompt

Create a solution in CPP for 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>
#pragma GCC optimize("Ofast")
using namespace std;
const int MOD = (int)1e9 + 7;
const int N = (int)2e5;
const long long INF = (long long)1e18;
int T;
int n;
int v[100005], w[100005];
int dp[100005], dp2[100005];
int f[100005];
vector<int> divs[100005];
int lgput(int n, long long p) {
  int ans = 1, first = n;
  while (p) {
    if (p & 1) ans = 1LL * ans * first % MOD;
    first = 1LL * first * first % MOD;
    p >>= 1;
  }
  return ans;
}
void precalc() {
  for (int i = 1; i <= 100000; i++) {
    for (int j = i; j <= 100000; j += i) divs[j].push_back(i);
  }
}
int solve(int v[], int n) {
  int ans = 0;
  vector<int> vals;
  for (int i = 1; i <= n; i++) {
    for (auto &d : divs[v[i]]) {
      if (!f[d]) vals.push_back(d);
      f[d]++;
    }
  }
  for (int i = (int)vals.size() - 1; i >= 0; i--) {
    int nr = vals[i];
    dp2[nr] = (dp2[nr] + 1LL * f[nr] * f[nr]) % MOD;
    ans = (ans + 1LL * nr * dp2[nr]) % MOD;
    for (auto &d : divs[nr]) {
      dp2[d] = (dp2[d] - dp2[nr] + MOD) % MOD;
    }
  }
  for (auto &d : vals) f[d] = dp2[d] = 0;
  return ans;
}
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  int ans = 0;
  for (int d = n; d >= 1; d--) {
    int m = 0;
    for (int i = d; i <= n; i += d) {
      w[++m] = v[i];
    }
    dp[d] = solve(w, m);
    for (int i = 2 * d; i <= n; i += d) {
      dp[d] = (dp[d] - dp[i] + MOD) % MOD;
    }
    ans = (ans + 1LL * d * dp[d]) % MOD;
  }
  cout << ans << "\n";
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  T = 1;
  precalc();
  for (; T; T--) {
    solve();
  }
  return 0;
}

```