#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int const MAXN = 300100, MOD = 1e9 + 7;
int suff[MAXN][62], scomp[MAXN][62];
long long int ans = 0;
void my_pow(int base, int esp, int times) {
  if (times == 0) return;
  long long int val = 1;
  for (int i = 0; i < esp; i++) val = (val * base) % MOD;
  ans = (ans + (val * times) % MOD) % MOD;
}
int main() {
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    long long int esp = 1, p = 0;
    while (esp <= v[i]) {
      esp *= 2;
      p++;
    }
    long long int copy = v[i];
    while (copy) {
      if (copy >= esp) {
        copy -= esp;
        scomp[i][p] = 1;
      }
      esp /= 2;
      p--;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 62; j++) suff[i][j] = suff[i + 1][j] + scomp[i][j];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 60; j++) {
      if (scomp[i][j]) {
        int times = n - i - suff[i][j];
        my_pow(2, j, times);
      } else {
        int times = suff[i][j];
        my_pow(2, j, times);
      }
    }
  cout << ans;
}
