#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<long long> A;
  long long a;
  int counter[100];
  memset(counter, 0, sizeof(counter));
  long long base[100];
  memset(base, 0, sizeof(base));
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
    for (int j = 0; j < 63; ++j) {
      base[j] = pow(2, j);
      if (((a >> j) & 1) == 1) {
        ++counter[j];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    int remain = N - (i + 1);
    a = A[i];
    for (int j = 0; j < 63; ++j) {
      if (((a >> j) & 1) == 1) {
        --counter[j];
      }
    }
    for (int j = 0; j < 63; ++j) {
      if (((a >> j) & 1) == 1) {
        ans += (base[j] * (remain - counter[j])) % MOD;
      } else {
        ans += (base[j] * counter[j]) % MOD;
      }
    }
  }
  cout << ans % MOD << endl;
  return 0;
}
