use proconio::input;

fn main() {
    input! {
        n:i64,
        a:[i64; n],
    };

    let m = 1000000007;
    let mut cnt = vec![0i64; 63];

    let mut ans = 0;

    for v in &a {
        for i in 0..63 {
            if (v >> i) & 1 == 1 {
                cnt[i] += 1;
            }
        }
    }

    let mut x = n;
    for v in &a {
        for i in 0..63 {
            if (v >> i) & 1 == 1 {
                ans += (1i64 << i) * (x - cnt[i]);
            }
            else {
                ans += (1i64 << i) * cnt[i];
            }
            ans %= m;
        }
        for i in 0..63 {
            if (v >> i) & 1 == 1 {
                cnt[i] -= 1;
            }
        }
        x -= 1;
    }

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