#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;
long long a[maxn], b[maxn], n, sum;
int main(void) {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 60; j++) {
      if (a[i] >> j & 1) {
        b[j]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 60; j++) {
      if (a[i] >> j & 1) {
        b[j]--;
      }
    }
    for (int j = 0; j < 60; j++) {
      if (a[i] >> j & 1) {
        sum = (sum + (n - b[j] - i) % mod * (1LL << j) % mod) % mod;
      } else {
        sum = (sum + b[j] % mod * (1LL << j) % mod) % mod;
      }
    }
  }
  cout << sum << endl;
  return 0;
}
