#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  scanf("%lld", &n);
  vector<long long> arr(n);
  for (int i = 0; i < n; i++) scanf("%lld", &arr[i]);
  vector<vector<long long> > sxor;
  for (int i = 0; i < n; i++) {
    vector<long long> tmp;
    long long j = 59;
    long long y = arr[i];
    while (j >= 0) {
      long long x = pow(2, j);
      if (x <= y) {
        y -= x;
        tmp.push_back(1);
      } else
        tmp.push_back(0);
      j--;
    }
    reverse(tmp.begin(), tmp.end());
    sxor.push_back(tmp);
  }
  vector<long long> tmp(60, 0);
  for (int j = 0; j < 60; j++) {
    for (int i = 0; i < n; i++) {
      tmp[j] += sxor[i][j];
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long ans2 = 0;
    for (int j = 0; j < 60; j++) {
      tmp[j] -= sxor[i][j];
      if (sxor[i][j] == 1) {
        ans2 += (pow(2, j) * (n - tmp[j] - (i + 1)));
        ans2 %= 1000000007;
      } else {
        ans2 += (pow(2, j) * tmp[j]);
        ans2 %= 1000000007;
      }
    }
    ans += ans2;
    ans %= 1000000007;
  }
  ans %= 1000000007;
  printf("%lld", ans);
  printf("\n");
  return;
}
int main() {
  solve();
  return 0;
}
