#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int r(long long int x, long long int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return r(x, y / 2) * r(x, y / 2);
  else
    return x * r(x, (y - 1) / 2) * r(x, (y - 1) / 2);
}
int main() {
  long long int n;
  cin >> n;
  vector<long long int> p(n);
  long long int M = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    M = max(M, p[i]);
  }
  long long int count = 0;
  long long int c = 0;
  while (M > 1) {
    M /= 2;
    c++;
  }
  c = r(2, c);
  while (c > 1) {
    long long int c1 = 0;
    long long int c0 = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] >= c) {
        c1++;
        p[i] -= c;
      } else {
        c0++;
      }
    }
    long long int c3 = c0 * c1 % mod;
    c3 *= c;
    c3 %= mod;
    count += c3;
    count %= mod;
    c /= 2;
  }
  long long int c1 = 0;
  long long int c0 = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] == 1) {
      c1++;
    } else {
      c0++;
    }
  }
  long long int c3 = c1 * c0 % mod;
  count += c3;
  count %= mod;
  printf("%lld\n", count);
}
