#include <bits/stdc++.h>
using namespace std;
long long n, s[310000], r[310000][70], ans;
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = 0; j < 70; j++) r[i][j] += r[i + 1][j];
    long long now = s[i], pos = 0;
    while (now > 0) {
      if (now % 2 == 1) r[i][pos]++;
      now /= 2;
      pos++;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 61; j++) {
      if ((1ll << j) & s[i])
        ans += (1ll << j) * (n - i - 1 - r[i + 1][j]);
      else
        ans += (1ll << j) * r[i + 1][j];
      ans %= 1000000007;
    }
  }
  cout << ans << endl;
}
