/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pll;
typedef vector<int> vll;
typedef vector<pll> vpll;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 3e5 + 7;

int fme(int a, int b) {
  if (b == 0)
    rtn 1;
  if (b % 2)
    rtn a * fme(a, b - 1) % MOD;
  rtn fme(a * a % MOD, b / 2);
}

int suf[N][66][2];
int a[N];
int n;

int32_t main() {
  FAST_IO;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }
  per(i, n) {
    rep(j, 61) {
      suf[i][j][0] = suf[i + 1][j][0];
      suf[i][j][1] = suf[i + 1][j][1];
      if (a[i] & (1LL << j)) {
        suf[i][j][1]++;
      } else {
        suf[i][j][0]++;
      }
    }
  }
  int ans = 0;
  rep(i, n) {
    rep(j, 61) {
      if (a[i] & (1LL << j)) {
        ans = ans + (suf[i + 1][j][0] * fme(2, j)) % MOD;
        if (ans >= MOD)
          ans -= MOD;
      } else {
        ans = ans + (suf[i + 1][j][1] * fme(2, j)) % MOD;
        if (ans >= MOD)
          ans -= MOD;
      }
    }
  }
  cout << ans << '\n';
  rtn 0;
}


Measured memory_bytes: 311936