using System;
using System.Linq;
 
public class Program {
	public static void Main() {
		Console.ReadLine();
 
		var numbers = Console.ReadLine().Split(' ')
			.Select(x => ulong.Parse(x))
			.ToArray();
		ulong divisor = (ulong)Math.Pow(10, 9) + 7; 

		ulong result = 0;
		for(int i = 0; i < numbers.Length - 1; i++) {
			ulong temp = 0;
			for(int j = i + 1; j < numbers.Length; j++) {
				ulong value = numbers[i] ^ numbers[j];

				if(temp > ulong.MaxValue - value) {
					temp %= divisor;
				}
				temp += value;
			}

			if(result > ulong.MaxValue - temp) {
				result %= divisor;
			}
			result += temp;
		}
 
		Console.WriteLine(result % divisor);
	}
}
