import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!long).array;
    
    immutable int MD = 10 ^^ 9 + 7;
    immutable int MXB = 60;
    
    int ans = 0;
    int[MXB] cnt;
    cnt[] = 0;
    foreach_reverse (i, e; arr) {
        foreach (bt; 0 .. MXB) {
            int totake;
            if ((e & (1L << bt)) > 0) {
                totake = (n-1 - i.to!int) - cnt[bt];
            } else {
                totake = cnt[bt];
            }
            
            auto cur = (1L << bt) * totake % MD;
            ans = (ans + cur) % MD;
        }
        
        foreach (bt; 0 .. MXB) {
            if ((e & (1L << bt)) > 0) { ++cnt[bt]; }
        }
    }
 
    ans.writeln;
}