#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;
const int md = 1e9 + 7;
int add(const int &a, const int &b) { return a + b >= md ? a + b - md : a + b; }
int sub(const int &a, const int &b) { return a - b < 0 ? a - b + md : a - b; }
int mul(const int &a, const int &b) { return (1ll * a * b) % md; }
const int maxN = 1e5 + 5;
int a[maxN];
vi divs[maxN];
int sm[maxN];
int sumg[maxN];
int cnt[maxN];
ll too[maxN];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i < maxN; ++i) {
    for (int j = i; j < maxN; j += i) {
      divs[j].push_back(i);
    }
  }
  for (int i = 1; i < maxN; ++i) {
    sm[i] = add(i, sm[i]);
    for (int j = i * 2; j < maxN; j += i) {
      sm[j] = sub(sm[j], sm[i]);
    }
  }
  int ans = 0;
  for (int g = n; g >= 1; --g) {
    int cur = 0;
    for (int d = g; d <= n; d += g) {
      for (auto &div : divs[a[d]]) {
        cur = add(cur, mul(cnt[div], sm[div]));
        cnt[div]++;
      }
      cur = sub(cur, sumg[d]);
    }
    for (int d = g; d <= n; d += g) {
      for (auto &div : divs[a[d]]) {
        cnt[div]--;
      }
    }
    sumg[g] = cur;
    ans = add(ans, mul(2, mul(cur, g)));
    ans = add(ans, mul(a[g], g));
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  for (int i = 0; i < (t); ++i) {
    solve();
  }
  return 0;
}

### Prompt

Develop a solution in cpp 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;
using ll = long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;
const int md = 1e9 + 7;
int add(const int &a, const int &b) { return a + b >= md ? a + b - md : a + b; }
int sub(const int &a, const int &b) { return a - b < 0 ? a - b + md : a - b; }
int mul(const int &a, const int &b) { return (1ll * a * b) % md; }
const int maxN = 1e5 + 5;
int a[maxN];
vi divs[maxN];
int sm[maxN];
int sumg[maxN];
int cnt[maxN];
ll too[maxN];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i < maxN; ++i) {
    for (int j = i; j < maxN; j += i) {
      divs[j].push_back(i);
    }
  }
  for (int i = 1; i < maxN; ++i) {
    sm[i] = add(i, sm[i]);
    for (int j = i * 2; j < maxN; j += i) {
      sm[j] = sub(sm[j], sm[i]);
    }
  }
  int ans = 0;
  for (int g = n; g >= 1; --g) {
    int cur = 0;
    for (int d = g; d <= n; d += g) {
      for (auto &div : divs[a[d]]) {
        cur = add(cur, mul(cnt[div], sm[div]));
        cnt[div]++;
      }
      cur = sub(cur, sumg[d]);
    }
    for (int d = g; d <= n; d += g) {
      for (auto &div : divs[a[d]]) {
        cnt[div]--;
      }
    }
    sumg[g] = cur;
    ans = add(ans, mul(2, mul(cur, g)));
    ans = add(ans, mul(a[g], g));
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  for (int i = 0; i < (t); ++i) {
    solve();
  }
  return 0;
}

```