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);

            long s = one + carry;
            if (s & 1) ans += powmod(2, j, MOD) % MOD;
            ans %= MOD;

            carry = s >> 1;
        }

        int j = M;
        while (carry) {
            if (carry & 1) ans += powmod(2, j, MOD) % MOD;
            j += 1;
            carry >>= 1;
        }
    }

    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
