#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 1;
int n;
const long long int mod = 1e9 + 7;
long long int a[maxN];
long long int r[60][2][maxN];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for (int bit = 0; bit < 60; bit++) {
      r[bit][0][n] = r[bit][1][n] = 0;
      for (int i = n - 1; i >= 0; i--) {
        r[bit][0][i] = !((a[i] >> bit) & 1LL) + r[bit][0][i + 1];
        r[bit][1][i] = ((a[i] >> bit) & 1LL) + r[bit][1][i + 1];
      }
    }
    long long int ans = 0;
    for (int bit = 0; bit < 60; bit++)
      for (int i = 0; i < n - 1; i++)
        ans =
            (ans + (1LL << bit) * r[bit][!((a[i] >> bit) & 1LL)][i + 1] % mod) %
            mod;
    printf("%lld\n", ans);
  }
  return 0;
}
