#include <bits/stdc++.h>
using namespace std;
const long long N = 1000010;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 0; i < 40; i++) {
    long long d[n];
    for (long long j = 0; j < n; j++) {
      d[j] = a[j] & (1LL << i);
    }
    long long z[n];
    for (long long j = n - 1; j >= 0; j--) {
      if (j == n - 1)
        z[j] = 0;
      else
        z[j] = z[j + 1];
      if (d[j] == 0) z[j]++;
    }
    for (long long j = 0; j < n - 1; j++) {
      if (d[j] == (1LL << i)) {
        long long rr = (z[j + 1] * (d[j] % (1000000007))) % (1000000007);
        ans = (ans + rr) % (1000000007);
      } else {
        long long rr = ((n - j - 1 - z[j + 1]) * ((1LL << i) % (1000000007))) %
                       (1000000007);
        ans = (ans + rr) % (1000000007);
      }
    }
  }
  cout << ans << endl;
}
