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()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}
const MODULO: usize = 1_000_000_000 + 7;
fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();

    let mut ans = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            ans += (a[i] ^ a[j]) % MODULO;
        }
    }

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