#include <bits/stdc++.h>
using namespace std;
int n, maxk;
long long ans;
long long a[300010];
long long s[300010][70];
bool cmp(long long x, long long y) { return x < y; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    long long cc = a[i];
    int k = 0;
    while (cc) {
      s[i][k] += cc & 1;
      cc >>= 1;
      ++k;
    }
    maxk = k - 1;
  }
  for (int i = 0; i <= 60; i++) {
    for (int j = 1; j <= n; j++) {
      s[j][i] += s[j - 1][i];
    }
  }
  for (int i = 1; i <= n; i++) {
    long long cc = a[i];
    int k = 0;
    while (cc) {
      long long t = 1ll << k;
      t %= 1000000007;
      if (cc & 1) {
        ans += 1ll * t * (n - i - s[n][k] + s[i][k]);
        ans %= 1000000007;
      } else {
        ans += 1ll * t * (s[n][k] - s[i][k]);
        ans %= 1000000007;
      }
      cc >>= 1;
      ++k;
    }
    long long t = 1ll << k;
    t %= 1000000007;
    while (k <= maxk) {
      ans += 1ll * t * (s[n][k] - s[i][k]);
      ans %= 1000000007;
      k++;
    }
  }
  cout << ans % 1000000007 << endl;
  return 0;
}
