#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
const int MOD = 1e9 + 7;
const long long INF = 1e+14;
const double PI = 3.14159265349;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long(i) = 0; (i) < (N); (i)++) {
    cin >> A[i];
  }
  long long ans = 0;
  for (long long(b) = 0; (b) < (60); (b)++) {
    vector<long long> B(N);
    for (long long(i) = 0; (i) < (N); (i)++) {
      B[i] = ((A[i] >> b) & 1);
    }
    vector<long long> dp(2);
    long long sum_b = 0;
    if (B[N - 1] == 1) {
      dp[0] = 1;
    } else {
      dp[1] = 1;
    }
    for (long long i = N - 2; i >= 0; i--) {
      if (B[i] == 0) {
        sum_b += dp[0];
        dp[1]++;
      } else {
        sum_b += dp[1];
        dp[0]++;
      }
    }
    ans += (sum_b * ((long long)1 << b)) % MOD;
    ans %= MOD;
  }
  cout << ans << "\n";
  return 0;
}
