#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long m = 1e6;
long long a[m];
long long b[m][60][2];
signed main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  fill(b[0][0], b[m][0], 0);
  for (long long i = 0; i < (long long)(n); i++)
    for (long long j = 0; j < (long long)(60); j++) {
      if (a[i] & (1LL << j))
        b[i][j][1]++;
      else
        b[i][j][0]++;
    }
  for (long long k = 0; k < (long long)(2); k++)
    for (long long j = 0; j < (long long)(60); j++)
      for (long long i = n - 2; i >= 0; i--) b[i][j][k] += b[i + 1][j][k];
  long long ans = 0;
  for (long long i = 0; i < (long long)(n - 1); i++)
    for (long long j = 0; j < (long long)(60); j++)
      for (long long k = 0; k < (long long)(2); k++)
        if ((a[i] & (1LL << j)) ^ (k << j)) {
          ans += b[i + 1][j][k] % mod * (1 << j) % mod;
          ans %= mod;
        }
  cout << ans << endl;
}
