const MOD_N: u64 = 1000000007;

fn bit_cnt_add(bit_cnt: &mut Vec<Vec<u32>>, x: u64) {
    for i in 0..64 {
        let bit_x = ((x >> i) & 1) as usize;
        bit_cnt[i][bit_x] += 1;
    }
}

fn xor_add_bits(bit_cnt: &Vec<Vec<u32>>, xor_x: u64) -> u64 {
    let mut result = 0u64;
    let mut carry = 0u32;

    for i in 0..64 {
        let bit_x = (((xor_x >> i) & 1) ^ 1) as usize;

        let nr_one = bit_cnt[i][bit_x] + carry;

        carry = nr_one/2;
        let set_bit = (nr_one%2) as u64;

        result |= set_bit << i;
    }

    result
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let a_s = buf.split_whitespace()
        .map(|x| x.parse::<u64>().unwrap())
        .collect::<Vec<_>>();

    let mut bit_cnt = vec![vec![0u32; 2]; 64];

    let mut ans = 0u64;

    for i in (1..n).rev() {
        bit_cnt_add(&mut bit_cnt, a_s[i]);
        ans += xor_add_bits(&bit_cnt, a_s[i-1]);
        ans %= MOD_N;
    }

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