#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")
using namespace std;
mt19937 gen(34);
int n;
const long long MOD = 1e9 + 7;
long long a[300000], cnt[60];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < 60; j++) cnt[j] += ((a[i] & (1ll << j)) != 0);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) cnt[j] -= ((a[i] & (1ll << j)) != 0);
    long long ost = n - 1 - i;
    for (int j = 0; j < 60; j++)
      if (a[i] & (1ll << j))
        ans += (ost - cnt[j]) * (1ll << j);
      else
        ans += cnt[j] * (1ll << j);
    ans %= MOD;
  }
  cout << ans;
  return 0;
}
