#include<bits/stdc++.h>
using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
//#define MOD 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,n) for(int i=1;i<=n;i++)
#define all(c) begin(c), end(c)

//#define int long long 

namespace {
#define __DECLARE__(C)    \
    template <typename T> \
    std::ostream &operator<<(std::ostream &, const C<T> &);

#define __DECLAREM__(C)               \
    template <typename T, typename U> \
    std::ostream &operator<<(std::ostream &, const C<T, U> &);

__DECLARE__(std::vector)
__DECLARE__(std::deque)
__DECLARE__(std::set)
__DECLARE__(std::stack)
__DECLARE__(std::queue)
__DECLARE__(std::priority_queue)
__DECLARE__(std::unordered_set)
__DECLAREM__(std::map)
__DECLAREM__(std::unordered_map)

template <typename T, typename U>
std::ostream &operator<<(std::ostream &, const std::pair<T, U> &);
template <typename... T>
std::ostream &operator<<(std::ostream &, const std::tuple<T...> &);
template <typename T, std::size_t N>
std::ostream &operator<<(std::ostream &, const std::array<T, N> &);

template <typename Tuple, std::size_t N>
struct __TuplePrinter__ {
    static void print(std::ostream &os, const Tuple &t) {
        __TuplePrinter__<Tuple, N - 1>::print(os, t);
        os << ", " << std::get<N - 1>(t);
    }
};

template <typename Tuple>
struct __TuplePrinter__<Tuple, 1> {
    static void print(std::ostream &os, const Tuple &t) { os << std::get<0>(t); }
};

template <typename... T>
std::ostream &operator<<(std::ostream &os, const std::tuple<T...> &t) {
    os << '(';
    __TuplePrinter__<decltype(t), sizeof...(T)>::print(os, t);
    os << ')';
    return os;
}

template <typename T, typename U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &v) {
    return os << '(' << v.first << ", " << v.second << ')';
}

#define __INNER__                             \
    os << '[';                                \
    for (auto it = begin(c); it != end(c);) { \
        os << *it;                            \
        os << (++it != end(c) ? ", " : "");   \
    }                                         \
    return os << ']';

template <typename T, std::size_t N>
std::ostream &operator<<(std::ostream &os, const std::array<T, N> &c) {
    __INNER__
}

#define __DEFINE__(C)                                           \
    template <typename T>                                       \
    std::ostream &operator<<(std::ostream &os, const C<T> &c) { \
        __INNER__                                               \
    }

#define __DEFINEM__(C)                                             \
    template <typename T, typename U>                              \
    std::ostream &operator<<(std::ostream &os, const C<T, U> &c) { \
        __INNER__                                                  \
    }

#define __DEFINEW__(C, M1, M2)                                  \
    template <typename T>                                       \
    std::ostream &operator<<(std::ostream &os, const C<T> &c) { \
        std::deque<T> v;                                        \
        for (auto d = c; !d.empty(); d.pop()) v.M1(d.M2());     \
        return os << v;                                         \
    }

__DEFINE__(std::vector)
__DEFINE__(std::deque)
__DEFINE__(std::set)
__DEFINEW__(std::stack, push_front, top)
__DEFINEW__(std::queue, push_back, front)
__DEFINEW__(std::priority_queue, push_front, top)
__DEFINE__(std::unordered_set)
__DEFINEM__(std::map)
__DEFINEM__(std::unordered_map)
}





#define int long long 

signed main(){
	long long n;
	cin>>n;
	long long cnt[100],cntr[100];
	lp(i,100){
		cnt[i]=0;
		cntr[i]=0;
	}
	vector<long long> v(n);
	lp(i,n){
		long long a;
		cin>>a;
		v[i]=a;
		long long g=1;
		lp(j,60){
			if(a&(1ll<<j))cnt[j]++;
			g*=2;
			if(g>a)break;
		}
	}
	lp(i,60)cntr[i]=n-cnt[i];
	long long ans=0;
	sort(all(v));
	reverse(all(v));
	//lp(i,60)cout<<i<<" "<<cnt[i]<<endl;
	lp(i,n){
		long long a=v[i];
		long long g=1;
		lp(j,60){
			if(a&(1ll<<j)){
				//cout<<a<<" "<<j<<endl;
				cnt[j]--;
				ans+=(g%DEKAI)*cntr[j];
				ans%=DEKAI;
			}
			else{
				cntr[j]--;
				ans+=(g%DEKAI)*cnt[j];
				ans%=DEKAI;
			}
			g*=2;
			//cout<<g<<" "<<a<<endl;
			//if(g>a)break;
		}
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
/*
signed main(){
	int a;
	cin>>a;
		int x;
		cin>>x;
	mint ans=0;
	lp(i,a-1){
		int z;
		cin>>z;
		ans+=(z^x);
	}
	cout<<ans<<endl;
	return 0;
}
*/

Measured memory_bytes: 2560