#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
const int mod = 1e9 + 7;
int n;
long long a[N];
int cnt[70][N];
long long g(int l, int r, int k, bool op) {
  if (op) {
    return (r - l + 1) - (cnt[k][r] - cnt[k][l - 1]);
  }
  return cnt[k][r] - cnt[k][l - 1];
}
int main() {
  ios::sync_with_stdio(false);
  memset(cnt, 0, sizeof(cnt));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= 60; i++) {
    for (int j = 1; j <= n; j++) {
      cnt[i][j] = cnt[i][j - 1] + (a[j] & (1ll << (i - 1)) ? 1 : 0);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= 60; i++) {
    long long sum = 0, t = (1ll << (i - 1));
    for (int j = 1; j < n; j++) {
      sum += g(j + 1, n, i, (a[j] & t ? 1 : 0));
    }
    ans = (ans + sum * t) % mod;
  }
  cout << ans << endl;
  return 0;
}
