#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll INF = 1LL << 60;
const int INF_INT = 1 << 30;

struct Fast {
	Fast() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast; //cin,cout�������̂��܂��Ȃ��{�����w��

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
struct mll {
	static ll MOD;
	ll val;
	mll(ll v = 0) : val(v % MOD) { if (val < 0) val += MOD; }
	mll operator - () const { return -val; }
	mll operator + (const mll &b) const { return val + b.val; }
	mll operator - (const mll &b) const { return val - b.val; }
	mll operator * (const mll &b) const { return val * b.val; }
	mll operator / (const mll &b) const { return mll(*this) /= b; }
	mll operator + (ll b) const { return *this + mll(b); }
	mll operator - (ll b) const { return *this - mll(b); }
	mll operator * (ll b) const { return *this * mll(b); }
	friend mll operator + (ll a, const mll &b) { return b + a; }
	friend mll operator - (ll a, const mll &b) { return -b + a; }
	friend mll operator * (ll a, const mll &b) { return b * a; }
	mll &operator += (const mll &b) { val = (val + b.val) % MOD; return *this; }
	mll &operator -= (const mll &b) { val = (val + MOD - b.val) % MOD; return *this; }
	mll &operator *= (const mll &b) { val = (val*b.val) % MOD; return *this; }
	mll &operator /= (const mll &b) {
		ll c = b.val, d = MOD, u = 1, v = 0;
		while (d) {
			ll t = c / d;
			c -= t * d; swap(c, d);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	mll &operator += (ll b) { return *this += mll(b); }
	mll &operator -= (ll b) { return *this -= mll(b); }
	mll &operator *= (ll b) { return *this *= mll(b); }
	mll &operator /= (ll b) { return *this /= mll(b); }
	bool operator == (const mll &b) { return val == b.val; }
	bool operator != (const mll &b) { return val != b.val; }
	bool operator == (ll b) { return *this == mll(b); }
	bool operator != (ll b) { return *this != mll(b); }
	friend bool operator == (ll a, const mll &b) { return mll(a) == b.val; }
	friend bool operator != (ll a, const mll &b) { return mll(a) != b.val; }
	friend ostream &operator << (ostream &os, const mll &a) { return os << a.val; }
	friend istream &operator >> (istream &is, mll &a) { return is >> a.val; }
	static mll Combination(ll a, ll b) {
		chmin(b, a - b);
		if (b < 0) return mll(0);
		mll c = 1;
		rep(i, b) c *= a - i;
		rep(i, b) c /= i + 1;
		return c;
	}
};
ll mll::MOD = (ll)(1e9 + 7);// 998244353ll;


//E
/*
int main() {
	ll H;
	scanf("%lld", &H);
	ll W;
	scanf("%lld", &W);
	vvll R(H, vll(W));
	rep(i, H) {
		rep(j, W) {
			ll r;
			scanf("%lld", &r);
			R[i][j] = r;
		}
	}
	vvll B(H, vll(W));
	rep(i, H) {
		rep(j, W) {
			ll b;
			scanf("%lld", &b);
			B[i][j] = b;
		}
	}
	vvll S(H, vll(W));
	rep(i, H) {
		rep(j, W) {
			S[i][j] = abs(R[i][j] - B[i][j]);
		}
	}

	ll result = 0;

	printf("%lld\n", result);
}
*/

//D
int main() {
	mll N;
	cin >> N;
	vector<mll> A(N.val);
	rep(i, N.val) {
		cin >> A[i];
	}

	mll result = 0;
	vector<mll> bitCount(62);

	rep(i, N.val) {
		rep(j, 62) {
			if ((A[i].val & 1ll << j) != 0) {
				bitCount[j] += 1ll;
			}
		}
	}

	rep(i, 62) {
		mll zeros = N - bitCount[i];
		mll ones = bitCount[i];

		mll count = zeros * ones;
		mll base = (1ll << i);

		result += base * count;
	}

	cout << result << endl;
}

//C
/*
struct LLPair {
	ll a = 0;
	ll b = 0;
	LLPair() {}
	LLPair(ll a, ll b) {
		this->a = a;
		this->b = b;
	}
};

ll LLpow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n & 1) {
			ret *= x;
		}
		x *= x;
		n >>= 1;
	}
	return ret;
}

int main() {
	ll N;
	scanf("%lld", &N);
	vector<vector<LLPair>> A(N, vector<LLPair>());
	rep(i, N) {
		ll a;
		scanf("%lld", &a);
		rep(j, a) {
			ll x;
			scanf("%lld", &x);
			ll y;
			scanf("%lld", &y);
			A[i].push_back(LLPair(x - 1, y));
		}
	}

	ll result = INF;

	vll liar(N, 0);
	rep(i, LLpow(2, N)) {
		ll liar_gt = 0;
		rep(j, N) {
			if (liar[j] > 0) {
				liar_gt++;
			}
		}

		//�������Ȃ������ׂ�
		bool ok = true;
		rep(j, N) {
			bool flag_liar = false;

			for (auto item : A[j]) {
				//�������Ă���H
				if (liar[item.a] > 0) {
					//����͂�����
					if (item.b == 0) {
						//ok
					}
					else {
						flag_liar = true;
						break;
					}
				}
				else {
					//����͐���
					if (item.b > 0) {
						//ok
					}
					else {
						flag_liar = true;
						break;
					}
				}
			}

			//j����̖����`�F�b�N
			if (flag_liar == true && liar[j] == 1) {
				//ok
			}
			else if (flag_liar == false && liar[j] == 0) {

			}
			else {
				ok = false;
				break;
			}
		}

		//�����Ȃ�
		if (ok) {
			result = min(result, liar_gt);
		}

		//���̏�Ԃ�
		liar[0]++;
		rep(k, N - 1) {
			if (liar[k] > 1) {
				liar[k + 1]++;
				liar[k] = 0;
			}
		}
	}

	if (result == INF) {
		printf("0\n");
	}
	else {
		printf("%lld\n", N - result);
	}
}
*/

//B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll result = 0;

	rep(i, len / 2) {
		if (s[i] != s[len - 1 - i]) {
			result++;
		}
	}

	printf("%lld\n", result);
}
*/

//A
/*
int main() {
	ll a;
	scanf("%lld", &a);
	ll b;
	scanf("%lld", &b);
	ll c;
	scanf("%lld", &c);

	if (a + b + c >= 22) {
		printf("bust\n");
	}
	else {
		printf("win \n");
	}
}
*/

Measured memory_bytes: 2560