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();
        Array.Sort(A);
        Array.Reverse(A);
        
        var len = Convert.ToString(A[0],2).Length;
        var sum1 = new long[len];       
        var sum0 = new long[len];
        
        for(int i = 0;i < N;i++){
            var S = Convert.ToString(A[i],2);
            for(int j = S.Length-1;j >= 0;j--){
                
                if(S[j] == '1'){
                    sum1[S.Length-1-j]++;
                }
                            
            }
        }
        
        long ans = 0;
        long mo  = 1000000007;
        for(int i = 0;i < len;i++){
            ans += (sum1[i]*(N-sum1[i])*((long)Math.Pow(2,i)))%mo;
            ans %= mo;
        }
        
        Console.WriteLine(ans);
     }
}
     
     
                   

