#include<bits/stdc++.h>
using namespace std;
int Find(vector < int > & v, int n) {
vector < int > bit(32, 0);
for (int i = 0; i < n; i++)
for (int j = 0; j < 32; j++)
if ((v[i] >> j) & 1)
bit[j]++;
long long ans = 0;
int M = 1e9 + 7;
for (int i = 0; i < n / 2; i++) {
long long val = 0;
for (int j = 0; j < 32; j++) {
if (bit[j]) {
val = (val | (1 << j));
bit[j]--;
}
}
ans += (val * val);
ans %= M;
}
return ans;
}
main(){
int N ;
cin >> N ;
vector<int> arr(N + 1) ;
for(int i = 0; i < N; ++i)cin >> arr[i] ;
cout << Find(arr, N) ;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsgCgppbnQgRmluZCh2ZWN0b3IgPCBpbnQgPiAmIHYsIGludCBuKSB7CgogIHZlY3RvciA8IGludCA+IGJpdCgzMiwgMCk7CgogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgZm9yIChpbnQgaiA9IDA7IGogPCAzMjsgaisrKQogICAgICBpZiAoKHZbaV0gPj4gaikgJiAxKQogICAgICAgIGJpdFtqXSsrOwoKICBsb25nIGxvbmcgYW5zID0gMDsKCiAgaW50IE0gPSAxZTkgKyA3OwogIGZvciAoaW50IGkgPSAwOyBpIDwgbiAvIDI7IGkrKykgewoKICAgIGxvbmcgbG9uZyB2YWwgPSAwOwoKICAgIGZvciAoaW50IGogPSAwOyBqIDwgMzI7IGorKykgewogICAgICBpZiAoYml0W2pdKSB7CiAgICAgICAgdmFsID0gKHZhbCB8ICgxIDw8IGopKTsKICAgICAgICBiaXRbal0tLTsKICAgICAgfQogICAgfQoKICAgIGFucyArPSAodmFsICogdmFsKTsKICAgIGFucyAlPSBNOwoKICB9CgogIHJldHVybiBhbnM7Cgp9CgptYWluKCl7CglpbnQgTiA7IAoJY2luID4+IE4gOyAKCQoJdmVjdG9yPGludD4gYXJyKE4gKyAxKSA7IAoJCglmb3IoaW50IGkgPSAwOyBpIDwgTjsgKytpKWNpbiA+PiBhcnJbaV0gOyAKCQoJY291dCA8PCBGaW5kKGFyciwgTikgOyAKfQ==