#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long Mod = 1000000007LL;
const int N = 1e5 + 10;
const long long Inf = 2242545357980376863LL;
const long long Log = 30;
long long a[N], u[N], c[N], cnt[N], c2[N];
vector<int> D[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i < N; i++)
    for (int j = i; j < N; j += i) D[j].push_back(i);
  int mx = 0;
  for (int i = 1; i < N; i++) {
    for (auto x : D[i])
      if (x < i) u[i] -= u[x];
    if (i == 1) u[i] = 1;
    mx = max(mx, (int)D[i].size());
  }
  for (int i = 1; i < N; i++)
    for (auto x : D[i]) c[i] += x * u[i / x];
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int g = 1; g <= n; g++) {
    for (int i = g; i <= n; i += g)
      for (auto x : D[a[i]]) cnt[x]++;
    for (int i = g; i <= n; i += g) {
      for (auto x : D[a[i]]) {
        c2[x] += cnt[x] * c[g];
        c2[x] %= Mod;
      }
    }
    for (int i = g; i <= n; i += g)
      for (auto x : D[a[i]]) cnt[x]--;
  }
  long long ans = 0;
  for (int i = N - 1; i >= 1; i--) {
    for (auto x : D[i]) {
      if (x < i) (c2[x] -= c2[i]) %= Mod;
    }
    c2[i] %= Mod;
    ans += (c2[i] * i);
    ans %= Mod;
  }
  ans += Mod;
  cout << ans % Mod << '\n';
  return 0;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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 long double pi = acos(-1);
const long long Mod = 1000000007LL;
const int N = 1e5 + 10;
const long long Inf = 2242545357980376863LL;
const long long Log = 30;
long long a[N], u[N], c[N], cnt[N], c2[N];
vector<int> D[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i < N; i++)
    for (int j = i; j < N; j += i) D[j].push_back(i);
  int mx = 0;
  for (int i = 1; i < N; i++) {
    for (auto x : D[i])
      if (x < i) u[i] -= u[x];
    if (i == 1) u[i] = 1;
    mx = max(mx, (int)D[i].size());
  }
  for (int i = 1; i < N; i++)
    for (auto x : D[i]) c[i] += x * u[i / x];
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int g = 1; g <= n; g++) {
    for (int i = g; i <= n; i += g)
      for (auto x : D[a[i]]) cnt[x]++;
    for (int i = g; i <= n; i += g) {
      for (auto x : D[a[i]]) {
        c2[x] += cnt[x] * c[g];
        c2[x] %= Mod;
      }
    }
    for (int i = g; i <= n; i += g)
      for (auto x : D[a[i]]) cnt[x]--;
  }
  long long ans = 0;
  for (int i = N - 1; i >= 1; i--) {
    for (auto x : D[i]) {
      if (x < i) (c2[x] -= c2[i]) %= Mod;
    }
    c2[i] %= Mod;
    ans += (c2[i] * i);
    ans %= Mod;
  }
  ans += Mod;
  cout << ans % Mod << '\n';
  return 0;
}

```