#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
void file() {}
int tc;
const int N = 1e6 + 7, M = 3e5 + 5, MOD = 1e9 + 7;
int n;
long long a[N];
int cnt[2][62];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 61; j++) {
      if (a[i] & (1LL << j)) {
        ans += (1LL << j) * cnt[0][j];
        ans %= MOD;
      } else {
        ans += (1LL << j) * cnt[1][j];
        ans %= MOD;
      }
    }
    for (int j = 0; j < 61; j++) {
      if (a[i] & (1LL << j))
        cnt[1][j]++;
      else
        cnt[0][j]++;
    }
  }
  printf("%lld\n", ans);
}
