#include <bits/stdc++.h>
using namespace std;
long long int x[300000 + 10];
long long int sum1[300000 + 10], sum0[300000 + 10];
const int mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  long long int ans = 0;
  for (int i = 0; i <= 60; i++) {
    long long int temp;
    memset(sum1, 0, sizeof(sum1));
    memset(sum0, 0, sizeof(sum0));
    for (int j = 1; j <= n; j++) {
      sum1[j] = sum1[j - 1];
      sum0[j] = sum0[j - 1];
      if ((x[j] >> i) & 1)
        sum1[j]++;
      else
        sum0[j]++;
    }
    for (int j = 1; j <= n; j++) {
      if (x[j] >> i & 1)
        ans += (sum0[n] - sum0[j]) * pow(2, i);
      else
        ans += (sum1[n] - sum1[j]) * pow(2, i);
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
