#include <bits/stdc++.h>
using namespace std;
int n;
long long f[300005], ans = 0;
const long long mod = 1e9 + 7;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &f[i]);
  for (int i = 0; i <= 60; i++) {
    long long x = 0, y = 0, cnt = 0;
    for (int j = 1; j <= n; j++)
      if (f[j] & (1ll << i))
        x++;
      else
        y++;
    for (int j = 1; j <= n; j++)
      if (f[j] & (1ll << i))
        cnt = (cnt + y) % mod, x--;
      else
        cnt = (cnt + x) % mod, y--;
    ans = (ans + cnt * (1ll << i) % mod + mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
