/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;

namespace ModFunctions {
	inline int add(int a, int b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
        return a;
	}

	inline int sub(int a, int b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
        return a;
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, long long b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;
		}
		return u;
	}
}

using namespace ModFunctions;

void test() {
    int n;
    cin >> n;
    int cnt[61] = {0};
    long long a[n];
    int tot = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < 60; ++j) {
            if (a[i] & (1ll << j)) {
                ++cnt[j];
            }
        }
        tot = add(tot, int(a[i] % MOD));
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int lo = tot, hi = 0;
        for (int j = 0; j < 60; ++j) {
            if (a[i] & (1ll << j)) {
                int mask = (1ll << j) % MOD;
                lo = add(lo, mul(mask, n - cnt[j]));
                hi = add(hi, mul(mask, cnt[j]));
            }
        }
        ans = add(ans, mul(lo, hi));
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}
