#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  vector<vector<long long int> > sum(N + 1, vector<long long int>(62, 0));
  for (int i = 0; i < (N); ++i) {
    for (int j = 0; j < (62); ++j) {
      sum[i + 1][j] = sum[i][j] + ((A[i] >> j) & 1);
    }
  }
  long long int ans = 0;
  for (int i = 0; i < (N - 1); ++i) {
    long long int tmp = 0;
    for (int j = 0; j < (62); ++j) {
      long long int a = (A[i] >> j) & 1;
      long long int b = sum[N][j] - sum[i + 1][j];
      if (a == 1) {
        tmp += ((N - i - 1) - b) * (1ll << j);
      } else {
        tmp += b * (1ll << j);
      }
      tmp %= MOD;
    }
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
