using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
    static void Main(string[] args) {
        var N = long.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        
        var len = Convert.ToString(A.Max(),2).Length;
        var sum1 = new long[len];
        var sum0 = new long[len];
        var til1 = new long[len];
        
        for(long i = N-1;i >= 0;i--){
            var S = Convert.ToString(A[i],2);
            
            for(int j = 0;j < len;j++){
                if(j < S.Length && S[S.Length-j-1] == '1'){
                    til1[j] += sum0[j];
                    sum1[j]++;
                }else{
                    til1[j] += sum1[j];
                    sum0[j]++;
                }
            }
        }
        
        long ans = 0;
        long mo = 1000000007;
        for(int i = 0;i < len;i++){
            //Console.WriteLine(til1[i]);
            ans += til1[i]*((long)Math.Pow(2,i)%)%mo;
            ans %= mo;
        }
        Console.WriteLine(ans);
    }
} 
