#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; }
const long long MOD = 1e9 + 7;
int main() {
  vector<int> bit_tbl(61, 0);
  int N;
  cin >> N;
  vector<long long> As(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> As[i];
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int shift = 0;
    while (shift < 61) {
      if ((long long)1 << shift & As[i]) bit_tbl[shift]++;
      shift++;
    }
  }
  long long score = 0;
  for (int shift = 0, shift_len = (61); shift < shift_len; ++shift) {
    for (int i = 0, i_len = (N); i < i_len; ++i) {
      long long now = (long long)1 << shift;
      bool bit = bool(now & As[i]);
      if (bit == 1) bit_tbl[shift]--;
      int last = N - (i + 1);
      int count;
      if (bit == 1)
        count = last - bit_tbl[shift];
      else
        count = bit_tbl[shift];
      if (count != 0) {
      }
      score += ((long long)1 << shift) * count;
      score %= MOD;
    }
    score %= MOD;
  }
  cout << score << endl;
  return 0;
}
