#include <bits/stdc++.h>
using namespace std;
bool LT(double a, double b) { return !(fabs((a) - (b)) < (1e-9)) && a < b; }
bool LTE(double a, double b) { return (fabs((a) - (b)) < (1e-9)) || a < b; }
const string YES = "";
const string NO = "";
long long mod = 1000000007LL;
long long sum[63][2], A[300010];
long long modmultiply(long long a, long long b, long long c) {
  long long x = 0, y = a % c;
  while (b > 0) {
    if (b % 2 == 1) x = (x + y) % c;
    y = (y * 2) % c;
    b /= 2;
  }
  return x % c;
}
inline void update(int i, int cost) {
  for (int j = 0; j < 62; ++j) {
    int key = 0;
    if (A[i] & (1LL << j)) key = 1;
    sum[j][key] += cost;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> A[i];
  for (int i = 0; i < n; ++i) update(i, +1);
  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    update(i, -1);
    for (int j = 0; j < 62; ++j) {
      int key = 0;
      if (A[i] & (1LL << j)) key = 1;
      key = ((key == 1) ? 0 : 1);
      long long cost = modmultiply(sum[j][key], (1LL << j), mod);
      (ans += cost) %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
