#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> ruiseki(N + 1);
  for (int i = 1; i <= N; i++) {
    ruiseki[i] = ruiseki[i - 1] + A[i - 1] % (int)(1e9 + 7);
    ruiseki[i] %= (int)(1e9 + 7);
  }
  vector<vector<long long>> cnt0(64, vector<long long>(N + 1));
  vector<vector<long long>> cnt1(64, vector<long long>(N + 1));
  for (int j = 0; j < 63; j++) {
    for (int i = 1; i <= N; i++) {
      cnt0[j][i] = cnt0[j][i - 1] + ((A[i - 1] & (1ll << j)) == 0);
      cnt1[j][i] = cnt1[j][i - 1] + ((A[i - 1] & (1ll << j)) != 0);
    }
  }
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    ans += ruiseki[N] - ruiseki[i];
    for (int j = 0; j < 63; j++) {
      bool flag = (A[i - 1] & (1ll << j)) != 0;
      if (flag == false) continue;
      ans += ((cnt0[j][N] - cnt0[j][i]) << j) % (int)(1e9 + 7);
      ans %= (int)(1e9 + 7);
      ans += (-((cnt1[j][N] - cnt1[j][i]) << j)) % (int)(1e9 + 7);
      ans %= (int)(1e9 + 7);
    }
  }
  cout << ans << endl;
  return 0;
}
