#include <bits/stdc++.h>
using namespace std;
const int Mod = 1E9 + 7;
const int Inf = 1E9 + 7;
const int N = 5E5 + 10;
int n;
long long a[N], Bit[65];
void Input() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
void Solve() {
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 60; j++)
      if (a[i] & (1ll << j)) {
        res = (res + (i - 1 - Bit[j]) * (1ll << j) % Mod) % Mod;
        Bit[j]++;
      } else
        res = (res + (Bit[j]) * (1ll << j) % Mod) % Mod;
  }
  cout << res;
}
int main() {
  if (fopen("test"
            ".inp",
            "r")) {
    freopen(
        "test"
        ".inp",
        "r", stdin);
    freopen(
        "test"
        ".out",
        "w", stdout);
  }
  int testcase = 1;
  while (testcase--) {
    Input();
    Solve();
  }
}
