#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O2")
const long long LIM = 3e5 + 5, MOD = 1e9 + 7;
long long t, n, m, k, x, y;
long long arr[LIM][65];
long long sum[LIM][65];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    for (long long j = 0; j < 65; j++) {
      arr[i][j] = x % 2;
      if (i == 0) {
        sum[i][j] = arr[i][j];
      } else {
        sum[i][j] = sum[i - 1][j] + arr[i][j];
      }
      x /= 2;
    }
  }
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < 65; j++) {
      long long f;
      if (arr[i][j]) {
        f = i - sum[i - 1][j];
      } else
        f = sum[i - 1][j];
      ans = (ans + f * (1LL << j)) % MOD;
    }
    cout << "ans"
         << " = " << ans << "\n";
  }
  cout << ans % MOD << "\n";
}
