#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9;
long long mod(long long n) {
  while (n < MOD) n += MOD;
  return n % MOD;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long one[62] = {0};
  long long ans = 0;
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < 62; j++) {
      if (a[i] & (1ll << j)) one[j]++;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 62; j++) {
      if (a[i] & (1ll << j)) continue;
      ans = mod(ans + mod(mod(1ll << j) * one[j]));
    }
  }
  cout << ans << '\n';
}
