#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 3e5 + 10;
long long a[N], res, count_ones[65], count_zeros[65];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i >= 1; i--) {
    long long cur = a[i];
    for (long long j = 0; j <= 62; j++) {
      if ((1ll << j) & cur) {
        (res += (long long)count_zeros[j] * (1ll << j)) %= mod;
      } else {
        (res += (long long)count_ones[j] * (1ll << j)) %= mod;
      }
    }
    for (long long j = 0; j <= 62; j++) {
      if ((1ll << j) & cur)
        count_ones[j]++;
      else
        count_zeros[j]++;
    }
  }
  cout << res << '\n';
}
