#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 3e5 + 5;
long long arr[maxn];
int digit[maxn], bit[maxn][65];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    int j = 0;
    long long tmp = arr[i];
    while (tmp) {
      bit[i][j] = (tmp & 1);
      tmp >>= 1;
      ++j;
    }
  }
  for (int i = n - 1; i >= 0; --i)
    for (int j = 0; j < 65; ++j) bit[i][j] += bit[i + 1][j];
  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    int last = n - i - 1;
    for (int j = 0; j < 65; ++j) {
      int cnt = bit[i + 1][j];
      if (arr[i] & 1)
        ans = (ans + (1LL << j) * (long long)(last - cnt)) % mod;
      else
        ans = (ans + (1LL << j) * (long long)(cnt)) % mod;
      arr[i] >>= 1;
    }
  }
  cout << ans << '\n';
  return 0;
}
