#include <bits/stdc++.h>
unsigned long long int power(long long int a, long long int k) {
  if (k == 0) return 1;
  if (k % 2 == 1) return a * power(a, k - 1);
  if (k % 2 == 0) return power(a, k / 2) * power(a, k / 2);
}
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<long long int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  unsigned long long int num[60] = {};
  unsigned long long int ret = 0;
  for (int j = 1; j < n; j++) {
    for (int k = 0; k < 60; k++) {
      num[k] += ((a[j - 1] >> k) & 0x01);
      if ((a[j] >> k) & 0x01)
        ret = (ret + (j - num[k]) * power(2, k)) % 1000000007;
      else
        ret = (ret + num[k] * power(2, k)) % 1000000007;
    }
  }
  cout << ret << endl;
  return 0;
}
