#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int64 max(int64 a, int64 b) {
  if (b > a)
    return b;
  else
    return a;
}
int64 min(int64 a, int64 b) {
  if (b < a)
    return b;
  else
    return a;
}
const int64 MOD = 1e9 + 7;
signed main() {
  int64 N;
  cin >> N;
  vector<int64> A(N);
  for (int64 i = 0; i < N; i++) cin >> A[i];
  vector<vector<int64> > bits(N + 1, vector<int64>(62, 0));
  for (int64 i = 0; i < N; i++) {
    int64 a = A[N - 1 - i];
    for (int64 j = 0; j < 61; j++) {
      bits[N - 1 - i][j] = bits[N - i][j];
      if ((a >> j) & 1) {
        bits[N - 1 - i][j]++;
      }
    }
  }
  int64 res = 0;
  for (int64 i = 0; i < N - 1; i++) {
    int64 a = A[i];
    int64 cnt = 0;
    for (int64 j = 0; j < 61; j++) {
      int64 t = pow(2, j);
      if (!((a >> j) & 1)) {
        res += t * (bits[i + 1][j]);
        res %= MOD;
      } else {
        res += t * (N - i - 1 - bits[i + 1][j]);
        res %= MOD;
      }
    }
  }
  cout << res << endl;
  return 0;
}
