#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int(i) = 0; (i) < (n); ++(i)) cin >> a[i];
  vector<vector<long long>> sum(n + 1, vector<long long>(60, 0));
  for (int(i) = 0; (i) < (n); ++(i))
    for (int(j) = 0; (j) < (60); ++(j)) {
      if ((a[i] >> j) & 1) ++sum[i + 1][j];
      sum[i + 1][j] += sum[i][j];
    }
  long long MOD = 1e9 + 7;
  long long ans = 0;
  for (int(i) = 0; (i) < (n); ++(i))
    for (int(j) = 0; (j) < (60); ++(j)) {
      long long num = j;
      long long tmp = powl(2LL, num);
      tmp %= MOD;
      long long x;
      if ((a[i] >> j) & 1)
        x = n - i - 1 - (sum[n][j] - sum[i + 1][j]);
      else
        x = sum[n][j] - sum[i + 1][j];
      ans += x * tmp;
      ans %= MOD;
    }
  cout << ans << endl;
}
