use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<usize>();
    let mut sum = a.iter().sum::<usize>();
    let mut bits = vec![0;64];

    for &x in &a{
        for i in 0..64{
            if (x & (1 << i)) > 0{
                bits[i] += 1;
            }
        }
    }

    let mut ans = 0;
    //for &x in a.iter().take(n-1){
    for i in 0..n-1{
        let x = a[i];
        //remove current
        for j in 0..64{
            if (x & (1 << j)) > 0{
                bits[j] -= 1;
            }
        }
        //println!("x = {}", x);
        //println!("{:?}", bits);
        for j in 0..64{
            if (x & (1 << j)) > 0{
                ans += (1 << j) * (n - i - 1- bits[j]);
            }else{
                ans += (1 << j) * bits[j];
            }

            ans %= 1_000_000_007
        }
        //println!("ans = {}", ans);

    }
    println!("{}", ans);
}
