#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;
const int MOD = 1e9+7;

int ans;
int n;
ll v[MAX], sum[MAX];

void solve() {
	cin >> n;
	for(int i=0; i<n; i++) cin >> v[i];
	ans = 0;
	for(int i=0; i<61; i++) {
		ll c1 = 0;
		for(int j=0; j<n; j++) c1 += (v[j] >> i)&1;
		ll sum = c1*(n-c1);
		for(int j=0; j<i; j++) sum = 2*sum % MOD;
		ans = (ans + sum) % MOD;
	}
	cout << ans%MOD << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

 	solve();

  	return 0;
}


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

int lengths[105];
bool allDifferent(int len1, int len2, int len3)
{
	return (len1 != len2) && (len2 != len3) && (len3 != len1);
}

bool canFormTriangle(int len1, int len2, int len3)
{
	int maxLen = max(max(len1, len2), len3);
	return len1 + len2 + len3 - maxLen > maxLen;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++)
		scanf("%d", &lengths[i]);
	
	int ans = 0;
	for(int i = 1; i <= N; i++)
	{
		for(int j = i + 1; j <= N; j++)
		{
			for(int k = j + 1; k <= N; k++)
			{
				if(allDifferent(lengths[i], lengths[j], lengths[k]) && canFormTriangle(lengths[i], lengths[j], lengths[k]))
					ans++;
			}
		}
	}
	
	printf("%d", ans);
}