import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


immutable ulong MOD = 1000000007;


auto solve(ulong N, ulong[] A) {
    ulong ans;

    foreach (ulong i; 0 .. 60) {
        ulong bits = A.count!(a => ((a >> i) & 1) == 1);
        ans += (1uL << i) % MOD * (N - bits) % MOD * bits % MOD;
        ans %= MOD;
    }

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    ulong N;
    N = input.front.to!ulong;
    input.popFront;

    ulong[] A = new ulong[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!ulong;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, A);
    else {
        auto ans = solve(N, A);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}
