const MOD: usize = 1000000007;
fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = read_vec();
    a.sort_by(|a, b| b.cmp(a));
    let maxl = format!("{:b}", a[0]).len();
    let mut sum: usize = 0;
    let mut base = 1;
    // for i in 0..n {
    //     println!("{:060b}", a[i]);
    // }
    for d in 0..(maxl + 1) {
        let mut onenum = 0;
        for i in 0..n {
            if a[i] & (1 << d) != 0 {
                onenum += 1;
            }
        }
        sum += (base * onenum * (n - onenum)) % MOD;
        sum %= MOD;
        base *= 2;
    }
    println!("{}", sum % MOD);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
