#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAX = 1e6;
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
long long int one[40], zero[40];
bool check(long long int n, long long int pos) { return n & (1ll << pos); }
long long int arr[MAX];
long long int Bigmod(long long int a, long long int b) {
  if (b == 0) return 1 % MOD;
  long long int x = Bigmod(a, b / 2ll);
  x = (x * x) % MOD;
  if (b % 2ll == 1ll) x = (x * a) % MOD;
  return x;
}
long long int MOD_INV(long long int a, long long int b) {
  long long int x = Bigmod(b, MOD - 2);
  return (a * x) % MOD;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    for (int j = 0; j < 40; j++) {
      if (check(arr[i], j))
        one[j]++;
      else
        zero[j]++;
    }
  }
  long long int temp = n, sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 40; j++) {
      if (check(arr[i], j))
        one[j]--;
      else
        zero[j]--;
    }
    for (int j = 0; j < 40; j++) {
      if (check(arr[i], j)) {
        sum += (zero[j] * 2 << j) % MOD;
        sum %= MOD;
      } else {
        sum += (one[j] * 2 << j) % MOD;
        sum %= MOD;
      }
    }
  }
  cout << MOD_INV(sum, 2) << endl;
  return 0;
}
