#include <bits/stdc++.h>
const long long MOD = 1e9;
int main() {
  int n;
  std::cin >> n;
  std::vector<long long> a(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  long long res = 0;
  for (int k = 0; k < 60; ++k) {
    long long one = 0;
    long long zero = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] & (1LL << k))
        ++one;
      else
        ++zero;
    }
    long long tmp = one * zero;
    tmp %= MOD;
    tmp *= ((1LL << k) % MOD);
    tmp %= MOD;
    res += tmp;
    res %= MOD;
  }
  std::cout << res << std::endl;
}
