#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  vector<int> tbl(62, 0);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> A[i];
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int shift = 0;
    while (shift < 62) {
      if (((long long)1 << shift) & A[i]) {
        tbl[shift]++;
      }
      shift++;
    }
  }
  long long ans = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int shift = 0;
    while (shift < 62) {
      int f;
      if (((long long)1 << shift) & A[i]) {
        tbl[shift]--;
        f = (N - (i + 1)) - tbl[shift];
      } else
        f = tbl[shift];
      ans += (f * ((long long)1 << shift)) % ((long long)1e9 + 7);
      shift++;
    }
    ans %= (long long)1e9 + 7;
  }
  cout << ans << endl;
  return 0;
}
