#include <stdio.h>
#include <iostream>
#include <stdint.h>
#include <vector>
#include <deque>
using namespace std;



int main(){
    uint64_t N;
    cin >> N;

    vector<uint64_t> A;
    for(int i=0; i<N; i++){
        uint64_t a;
        cin >> a;
        A.push_back(a);
    }

    uint64_t ans = 0;
    uint64_t M = 1000* 1000* 1000 + 7;
    for(utin64_t i=0; i<60; i++){
        uint64_t m = 1u << i;
        deque<uint64_t> b0;
        deque<int> b1;
        for(int j=0; j<N; j++){
            uint64_t a = A[j];
            if((m & a) > 0){
                b1.push_back(j);
            }else{
                b0.push_back(j);
            }
        }
        for(int j=0; j<N; j++){
            uint64_t a = A[j];
            uint64_t c = m & a;
            uint64_t d =0;
            if(c > 0){
                b1.pop_front();
                d = b0.size();
            }else{
                b0.pop_front();
                d = b1.size();
            }
            ans = (((( d % M) * (m%M))%M) + ans) % M;
        }
    }
    printf("%llu\n", ans);
}
