#include <bits/stdc++.h>
using namespace std;
long long suff[300005][62];
long long arr[300005], po[62];
int main() {
  po[0] = 1LL;
  for (int i = 1; i < 62; i++) po[i] = po[i - 1] * 2;
  long long n;
  scanf("%lld", &n);
  memset(suff, 0, sizeof suff);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
    for (long long j = 0; j < 62; j++) {
      if (arr[i] & po[j]) suff[i][j]++;
    }
  }
  for (long long i = n; i >= 1; i--) {
    for (long long j = 0; j < 62; j++) {
      suff[i][j] += suff[i + 1][j];
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n - 1; i++) {
    for (long long j = 0; j < 62; j++) {
      if (arr[i] & po[j]) {
        long long cnt = suff[i + 1][j];
        cnt = (n - i) - cnt;
        ans += (po[j] * cnt) % 1000000007;
        ans = ans % 1000000007;
      } else {
        long long cnt = suff[i + 1][j];
        ans += (po[j] * cnt) % 1000000007;
        ans = ans % 1000000007;
      }
    }
  }
  cout << ans;
}
