#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int N;
long long int A[300005];
long long int B[300005][65][2];
long long int d[61];
long long int Pow(long long int x, long long int n) {
  long long int res = 1;
  for (int i = 0; i < n; ++i) res *= x;
  return res;
}
int main() {
  for (int i = 0; i < 61; ++i) d[i] = Pow(2, i);
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) {
    for (int k = 0; k < 61; ++k) {
      int b = ((A[i] & d[k]) == d[k]);
      B[i][k][b]++;
      if (i != 0) {
        B[i][k][0] += B[i - 1][k][0];
        B[i][k][1] += B[i - 1][k][1];
        B[i][k][0] %= mod;
        B[i][k][1] %= mod;
      }
    }
  }
  long long int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int k = 0; k < 60; ++k) {
      int b = ((A[i] & d[k]) == d[k]);
      ans += d[k] * (B[N - 1][k][!b] - B[i][k][!b]);
      ans %= mod;
    }
  }
  cout << ans << endl;
}
