#include <bits/stdc++.h>
using namespace std;
long long md = 1000000007ll;
long long n;
long long a[300003];
long long b[300003][62];
long long ans = 0ll;
int main() {
  for (long long i = 0ll; i < 61; i++) b[0][i] = 0ll;
  cin >> n;
  for (long long i = 1ll; i <= n; i++) {
    cin >> a[i];
    for (long long j = 0ll; j < 61ll; j++) {
      if ((a[i] & (1ll << j)) != 0ll)
        b[i][j] = b[i - 1][j] + 1ll;
      else
        b[i][j] = b[i - 1][j];
    }
  }
  for (long long i = 1ll; i < n; i++) {
    for (long long j = 0ll; j < 61ll; j++) {
      if ((a[i] & (1ll << j)) == 0ll) {
        ans = (ans + (b[n][j] - b[i][j]) * (1ll << j)) % md;
      } else {
        ans = (ans + ((n - i) - (b[n][j] - b[i][j])) * (1ll << j)) % md;
      }
    }
  }
  cout << ans << endl;
  return (0);
}
