import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 10^^9 + 7;
immutable int M = 62;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto B = new long[][](N, M);

    foreach (i; 0..N) foreach (j; 0..M) {
        B[i][j] = (A[i] >> j) & 1;
    }

    auto S = new long[](M);
    foreach (j; 0..M) foreach (i; 0..N) S[j] += B[i][j];
    long ans = 0;

    foreach (i; 0..N) {
        long cnt = N - i - 1;
        long carry = 0;

        foreach (j; 0..M) {
            S[j] -= B[i][j];

            long one = S[j];
            long zero = cnt - S[j];
            if (B[i][j]) swap(one, zero);

            ulong s = (one + carry) % MOD;
            ans += ((s & 1) << j) % MOD;
            ans %= MOD;

            carry = (s >> 1) % MOD;
        }
    }

    ans.writeln;
}