#include <bits/stdc++.h>
using namespace std;
long long solve() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<vector<long long>> C(N + 1, vector<long long>(61, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 61; j++) {
      if (A[i] & ((long long)1 << j)) {
        C[i + 1][j] = C[i][j] + 1;
      } else {
        C[i + 1][j] = C[i][j];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int k = 0; k < 61; k++) {
      long long c = C[N][k] - C[i + 1][k];
      if (A[i] & ((long long)1 << k)) {
        c = (long long)(N - i - 1) - c;
      }
      ans += (((long long)1 << k) * c) % 1000000007;
      ans = ans % 1000000007;
    }
  }
  return ans % 1000000007;
}
int main() {
  cout << solve() << endl;
  return 0;
}
