#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int LOG = 61;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<unsigned long long> a(n + 1, 0LL);
  vector<vector<int> > dp(n + 1, vector<int>(LOG, 0));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (int j = 0; j < LOG; j++) {
      unsigned long long st = 1LL << j;
      bool bit = (a[i] / st) & 1LL;
      if (bit) dp[i][j]++;
    }
  }
  for (int i = n - 1; i >= 1; i--) {
    for (int j = 0; j < LOG; j++) {
      dp[i][j] += dp[i + 1][j];
    }
  }
  unsigned long long ans = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < LOG; j++) {
      unsigned long long st = (1LL << j);
      bool bit = (a[i] / st) & 1LL;
      if (bit == 1) {
        unsigned long long p = (((n - i) - dp[i + 1][j]) * 1ull * st) % MOD;
        ans += p;
        ans %= MOD;
      }
      if (bit == 0) {
        unsigned long long p = (dp[i + 1][j] * 1ull * st) % MOD;
        ans += p;
        ans %= MOD;
      }
    }
  }
  cout << ans % MOD << '\n';
  return 0;
}
