#include <bits/stdc++.h>
using namespace std;
#define int int64_t
const int maxn = 1 << 17, mod = 1e9 + 7;
int cnt[maxn], pows[maxn];
int n;
int calc(int k)
{
return pows[n - k] * (pows[k] - 1) % mod;
}
int get(int x, int y, int z)
{
int sum = 0;
sum += calc(cnt[x]) + calc(cnt[y]) + calc(cnt[z]);
sum -= calc(cnt[x | y]) + calc(cnt[y | z]) + calc(cnt[x | z]);
sum += calc(cnt[x | y | z]);
sum = (sum + mod) % mod;
return x * y * z % mod * sum;
}
main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
pows[0] = 1;
for(int i = 1; i < maxn; i++)
pows[i] = 2 * pows[i - 1] % mod;
cin >> n;
for(int i = 0; i < n; i++)
{
int a;
cin >> a;
for(int x = 1; x < maxn; x <<= 1)
for(int y = x; y < maxn; y <<= 1)
for(int z = y; z < maxn; z <<= 1)
{
if(y == z && y != x)
continue;
int num = x | y | z;
if((a & num) != 0)
cnt[num]++;
}
}
int ans = 0;
for(int x = 1; x < maxn; x <<= 1)
for(int y = 1; y < maxn; y <<= 1)
for(int z = 1; z < maxn; z <<= 1)
ans = (ans + get(x, y, z)) % mod;
cout << ans << "\n";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBpbnQgaW50NjRfdApjb25zdCBpbnQgbWF4biA9IDEgPDwgMTcsIG1vZCA9IDFlOSArIDc7CmludCBjbnRbbWF4bl0sIHBvd3NbbWF4bl07CmludCBuOwoKaW50IGNhbGMoaW50IGspCnsKICAgIHJldHVybiBwb3dzW24gLSBrXSAqIChwb3dzW2tdIC0gMSkgJSBtb2Q7Cn0KCmludCBnZXQoaW50IHgsIGludCB5LCBpbnQgeikKewogICAgaW50IHN1bSA9IDA7CiAgICBzdW0gKz0gY2FsYyhjbnRbeF0pICsgY2FsYyhjbnRbeV0pICsgY2FsYyhjbnRbel0pOwogICAgc3VtIC09IGNhbGMoY250W3ggfCB5XSkgKyBjYWxjKGNudFt5IHwgel0pICsgY2FsYyhjbnRbeCB8IHpdKTsKICAgIHN1bSArPSBjYWxjKGNudFt4IHwgeSB8IHpdKTsKICAgIHN1bSA9IChzdW0gKyBtb2QpICUgbW9kOwogICAgcmV0dXJuIHggKiB5ICogeiAlIG1vZCAqIHN1bTsKfQoKbWFpbigpCnsKICAgIC8vZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICAvL2ZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBwb3dzWzBdID0gMTsKICAgIGZvcihpbnQgaSA9IDE7IGkgPCBtYXhuOyBpKyspCiAgICAgICAgcG93c1tpXSA9IDIgKiBwb3dzW2kgLSAxXSAlIG1vZDsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgIHsKICAgICAgICBpbnQgYTsKICAgICAgICBjaW4gPj4gYTsKICAgICAgICBmb3IoaW50IHggPSAxOyB4IDwgbWF4bjsgeCA8PD0gMSkKICAgICAgICAgICAgZm9yKGludCB5ID0geDsgeSA8IG1heG47IHkgPDw9IDEpCiAgICAgICAgICAgICAgICBmb3IoaW50IHogPSB5OyB6IDwgbWF4bjsgeiA8PD0gMSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZih5ID09IHogJiYgeSAhPSB4KQogICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICBpbnQgbnVtID0geCB8IHkgfCB6OwogICAgICAgICAgICAgICAgICAgIGlmKChhICYgbnVtKSAhPSAwKQogICAgICAgICAgICAgICAgICAgICAgICBjbnRbbnVtXSsrOwogICAgICAgICAgICAgICAgfQogICAgfQogICAgaW50IGFucyA9IDA7CiAgICBmb3IoaW50IHggPSAxOyB4IDwgbWF4bjsgeCA8PD0gMSkKICAgICAgICBmb3IoaW50IHkgPSAxOyB5IDwgbWF4bjsgeSA8PD0gMSkKICAgICAgICAgICAgZm9yKGludCB6ID0gMTsgeiA8IG1heG47IHogPDw9IDEpCiAgICAgICAgICAgICAgICBhbnMgPSAoYW5zICsgZ2V0KHgsIHksIHopKSAlIG1vZDsKICAgIGNvdXQgPDwgYW5zIDw8ICJcbiI7Cgp9