
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC147D();

int main()
{
	ABC147D();
	fflush(stdout);
	return 0;
}

static void ABC147D()
{
	int N;
	getint(N);

	std::vector<LLONG> ai(N);
	std::vector<std::vector<int>> bits(N, std::vector<int>(60, 0));
	for (int i = 0; i < N; i++) {
		if (i) bits[i] = bits[i - 1];

		getint(ai[i]);

		int bit = 0;
		LLONG tmp = ai[i];
		while (tmp) {
			if (tmp & 0x1) bits[i][bit]++;
			tmp >>= 1;
			bit++;
		}
	}

	std::vector<int> sum(60, 0);
	for (int i = 0; i < N - 1; i++) {
		for (int bit = 0; bit < 60; bit++) {
			int on = bits[N - 1][bit] - bits[i][bit];
			if ((ai[i] >> bit) & 0x1) {
				sum[bit] += (N - i - 1) - on;
			}
			else {
				sum[bit] += on;
			}
		}
	}

	LLONG ans = 0;
	for (int bit = 0; bit < 60; bit++) {
		ans += sum[bit] * tp_modpow<LLONG>(2, bit, MOD_NUM);
		ans %= MOD_NUM;
	}
	printf("%lld\n", ans);
}
