#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5 + 10;
const int MAX_D = 65;
const unsigned long long MOD = 1e9 + 7;
unsigned long long a[MAX_N], N, ans = 0ll;
unsigned long long sum[MAX_N][MAX_D];
unsigned long long d[MAX_N][MAX_D];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 61; j++) {
      unsigned long long now = (1ll << j);
      unsigned long long flag = unsigned long long(a[i]) & now;
      if (flag)
        d[i][j] = 1;
      else
        d[i][j] = 0;
    }
  for (int i = N - 1; i >= 0; i--)
    for (int j = 0; j < 61; j++) {
      sum[i][j] += sum[i + 1][j];
      sum[i][j] += d[i][j];
    }
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < 61; j++) {
      unsigned long long now = (1ll << j);
      if (d[i][j]) {
        ans = (ans +
               (unsigned long long(N - 1ll - i - sum[i + 1][j]) * now) % MOD) %
              MOD;
      } else {
        ans = (ans + unsigned long long(sum[i + 1][j] * now) % MOD) % MOD;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
