#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e6 + 5);
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e9 + 11);
long long a[N];
long long pref[65][N];
long long pref1[65][N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    for (long long j = 0; j <= 60; ++j) {
      if (((a[i] >> j) & 1)) {
        pref[j][i] = pref[j][i - 1] + 1;
        pref1[j][i] = pref1[j][i - 1];
      } else {
        pref[j][i] = pref[j][i - 1];
        pref1[j][i] = pref1[j][i - 1] + 1;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n - 1; ++i) {
    for (long long j = 0; j <= 60; ++j) {
      if (!((a[i] >> j) & 1)) {
        ans += ((1 << j) % MOD) * (pref[j][n] - pref[j][i]) % MOD, ans %= MOD;
      } else {
        ans += ((1 << j) % MOD) * (pref1[j][n] - pref1[j][i]) % MOD, ans %= MOD;
      }
    }
  }
  cout << ans;
  return 0;
}
