#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	const int len = sizeof(char) * 20 * 3 * 100000;
	uint64_t M = 1000000007llu;
	char* buffer = malloc(len);
	fgets(buffer, len, stdin);
	const int N = atoi(buffer);
	fgets(buffer, len, stdin);
	char* p = 0;
	
	uint64_t* A_list = malloc(sizeof(uint64_t) * N);
	
	for(int i = 0; i < N; i ++){
		if(i == 0){
			p = strtok(buffer, " ");
		}else{
			p = strtok(0, " ");
		}
		A_list[i] = strtoull(p, 0, 10);
	}
//	for(int i = 0; i < N; i ++){
//		printf("%llu\n", A_list[i]);
//	}
	
	uint64_t* counts = malloc(sizeof(uint64_t) * N + 1);
	uint64_t total = 0;
	for(int i = 0; i < 60; i ++){
		counts[N] = 0;
		for(int j = N - 1; j >= 0; j --){
			counts[j] = counts[j + 1] + ((A_list[j] >> i) & 1);
		}
		uint64_t count = 0;
		for(int j = 0; j < N - 1; j ++){
			if(((A_list[j] >> i) & 1) == 1){
				count += N - j - counts[j];
			}else{
				count += counts[j];
			}
		}
//		printf("%llu\n", count);
		
		for(int j = 0; j < i; j ++){
			count = (count * 2) % M;
		}
		total = (total + count) % M;
//		total = (total + ((1llu << i) % M) * count) % M;
	}
	
	printf("%llu\n", total);
	
	return 0;
}
