use std::cmp::{max, min};
use std::collections::VecDeque;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let a = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let msb = 60 + 1;
    let mut t = vec![vec![0; msb]; n];

    for s in 0..n {
        t[0][s] = if (a[0] & (1 << s)) > 0 { 1 } else { 0 };
    }

    for i in 1..n {
        for s in 0..msb {
            t[i][s] = t[i - 1][s] + (if a[i] & (1 << s) > 0 { 1 } else { 0 })
        }
    }

    let mut ans = 0;

    for i in 0..(n - 1) {
        for s in 0..msb {
            let stand = t[n - 1][s] - t[i][s];
            if a[i] & (1 << s) == 0 {
                ans += (1 << s) * stand;
                ans %= 1000000007
            } else {
                let no_stand = (n - (i + 1)) - stand;
                ans += (1 << s) * no_stand;
                ans %= 1000000007
            }
        }
    }
    println!("{}", ans)
}
