#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)(1e9 + 7);
long long sum[300007][70];
long long cur[300007][70];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    for (int j = 0; j < 60; j++) {
      if ((v[i] & (1LL << j)) != 0) {
        sum[i][j] = 1;
        cur[i][j] = 1;
      } else {
        sum[i][j] = 0;
        cur[i][j] = 0;
      }
    }
  }
  for (int i = 59; i >= 0; i--) {
    for (int j = n - 2; j >= 0; j--) {
      sum[j][i] = sum[j][i] + sum[j + 1][i];
    }
  }
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < 60; j++) {
      long long cnt = 0;
      if (cur[i][j] == 1) {
        cnt = (n - i - 1) - sum[i + 1][j];
      } else {
        cnt = sum[i + 1][j];
      }
      ans = ans + (cnt * (1LL << j)) % MOD;
      ans = ans % MOD;
    }
  }
  cout << ans << "\n";
  return 0;
}
