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