// 解説を見て実装
//
// modintを導入する前、
//       local_ans *= (1ULL << idx);
//       local_ans %= MOD;
// という行でオーバーフローしていたのになかなか気付けなかった。
// 正しくは、
//       local_ans *= ((1ULL << idx) % MOD);
//       local_ans %= MOD;
// としなければいけなかった。         


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <random>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

constexpr ll MOD = ll(1e9) + 7;

ll solve_olphe(int N, vector<ll> &v) {
    ll K = 0;
    ll M = 0;

	for (int i = 0; i < 60; i++) {
		long long int odd = 0,even = 0;
		for (auto j : v) {
			if ((j >> i) & 1)odd++;
			else even++;
		}
		K = 1LL << i;
		K %= MOD;
		K *= (odd*even) % MOD;
		M += K;
		M %= MOD;
        cout << "bit " << i << ": " << M << endl;
	}
    return M;
}

template<int MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

ll solve(int N, vector<ll> &As) {
    mint ans = 0;
    REP(idx, 60) {
        ll cnt0 = 0;
        ll cnt1 = 0;

        mint local_ans = 0;
        REP(j, N) {
            bool has_bit =  bool(As[j] & (1ULL << idx));

            if (has_bit) local_ans += cnt0;
            else local_ans += cnt1;

            cnt0 += !has_bit;
            cnt1 += has_bit;
        }

        local_ans *= (1ULL << idx);
        ans += local_ans;
    }
    return ans.val;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> As(N);
    REP(n, N) cin >> As[n];
    cout << solve(N, As) << endl;

    return 0;
}


Measured memory_bytes: 2560