#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1000000;
const long long mod = 1e9 + 7LL;
int n;
long long num[Nmax + 10];
long long powe[Nmax + 10];
void init() {
  powe[0] = 1LL;
  for (int i = 1; i <= Nmax; i++) powe[i] = (powe[i - 1] << 1) % mod;
}
int main() {
  init();
  scanf("%d", &n);
  int x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    num[x]++;
  }
  for (int i = 1; i <= Nmax; i++)
    for (int j = i << 1; j <= Nmax; j += i) num[i] += num[j];
  for (int i = 1; i <= Nmax; i++)
    if (num[i]) num[i] = num[i] * powe[num[i] - 1] % mod;
  long long ans = 0LL;
  for (int i = Nmax; i > 1; i--) {
    for (int j = i << 1; j <= Nmax; j += i)
      num[i] = (num[i] - num[j] + mod) % mod;
    ans = (ans + num[i] * i % mod) % mod;
  }
  printf("%lld\n", (ans + mod) % mod);
  return 0;
}
