#include <bits/stdc++.h>
using namespace std;
const long long limit = 1e5 + 1;
const long long inf = 1e7;
const long long mod = 1e9 + 7;
long long modExpItr(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b = b >> 1;
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<vector<long long>> v(n, vector<long long>(62, 0));
  vector<vector<long long>> postv(n, vector<long long>(62, 0));
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    long long x = a[i];
    long long j = 0;
    while (x) {
      v[i][j] = x & 1;
      x /= 2;
      j++;
    }
  }
  vector<long long> postSum(n, 0);
  for (long long i = n - 2; i >= 0; i--) {
    postSum[i] = (postSum[i + 1] + (a[i + 1] % mod)) % mod;
    for (long long j = 0; j < 62; j++) {
      postv[i][j] = postv[i + 1][j] + v[i + 1][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans = (ans % mod + postSum[i] % mod) % mod;
    for (long long j = 0; j < 62; j++) {
      if (a[i] & 1LL << j) {
        ans = (ans % mod + (((n - 1 - i - 2 * postv[i][j]) % mod) *
                            (modExpItr(2, j) % mod)) %
                               mod) %
              mod;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
