#include <bits/stdc++.h>
const long long int MOD = 1e9 + 7;
const long long int INF = 1011111111;
const long long int LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long int power(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return power((x * x) % MOD, n / 2) % MOD;
  else
    return (x % MOD * power((x * x) % MOD, (n - 1) / 2)) % MOD;
}
long long int ans = 0;
long long int ar[300005][64];
long long int dpz[300005][64];
long long int dpo[300005][64];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m, i, j, k;
  cin >> n;
  memset(ar, 0, sizeof ar);
  for (i = 0; i < n; i++) {
    long long int num;
    cin >> num;
    k = log2(num);
    long long int id = 0;
    while (num != 0) {
      ar[i][id++] = num % 2;
      num /= 2;
    }
  }
  k += 2;
  for (j = 0; j < k; j++) {
    dpz[n - 1][j] = 0;
    dpo[n - 1][j] = 0;
    for (i = n - 2; i >= 0; i--) {
      dpz[i][j] = dpz[i + 1][j] + 1 - ar[i + 1][j];
      dpo[i][j] = dpo[i + 1][j] + ar[i + 1][j];
    }
  }
  for (j = 0; j < k; j++) {
    for (i = 0; i < n; i++) {
      if (ar[i][j] == 1) {
        ans = (ans + dpz[i][j] % MOD * power(2LL, j)) % MOD;
      } else {
        ans = (ans + dpo[i][j] % MOD * power(2LL, j)) % MOD;
      }
    }
  }
  cout << ans;
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
