#include <bits/stdc++.h>
using namespace std;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<VV<T>>;
template <class T1, class T2>
using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
const int INF = 2e9;
const LL MOD = 1e9 + 7;
template <class T>
using PRIORITY_QUEUE = priority_queue<T, V<T>, greater<T>>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void debug1(V<T> A) {
  for (int i = 0; i < (int)(((int)(A).size())); ++i) {
    if (A[i] == INF)
      cout << "I ";
    else
      cout << A[i] << " ";
  }
  cout << endl;
}
template <class T>
inline void debug2(VV<T> A) {
  for (int i = 0; i < (int)(((int)(A).size())); ++i) {
    for (int j = 0; j < (int)(((int)(A[i]).size())); ++j) {
      if (A[i][j] == INF)
        cout << "I ";
      else
        cout << A[i][j] << " ";
    }
    cout << endl;
  }
}
template <class T>
string D2BC(T d) {
  string res = "";
  while (d > 0) {
    if (d & 1)
      res += "1";
    else
      res += "0";
    d >>= 1;
  }
  reverse(res.begin(), res.end());
  return res;
}
const int mod = 1e9 + 7;
struct mint {
  LL x;
  mint(LL _x = 0) : x((_x % mod + mod) % mod) {}
  mint operator-() const {
    mint tmp(-x);
    return tmp;
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint tmp(x);
    tmp += a.x;
    return tmp;
  }
  mint operator-(const mint& a) const {
    mint tmp(x);
    tmp -= a.x;
    return tmp;
  }
  mint operator*(const mint& a) const {
    mint tmp(x);
    tmp *= a.x;
    return tmp;
  }
  mint pow(LL b) const {
    mint res(1), a = *this;
    while (b > 0) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator/(const mint& a) const {
    mint tmp(x);
    tmp /= a;
    return tmp;
  }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VLL A(n);
  for (auto& x : A) cin >> x;
  ;
  int digit = int(log2(*max_element(A.begin(), A.end()))) + 1;
  VVI ct_1(n + 1, VI(digit, 0)), ct_0(n + 1, VI(digit, 1));
  for (int i = 0; i < (int)(digit); ++i) ct_0[0][i] = 0;
  for (int i = (1); i < (int)(n + 1); ++i) {
    VI tmp_1(digit, 0), tmp_0(digit, 1);
    LL j = A[i - 1], c = 0;
    while (j) {
      if (j & 1) {
        ++tmp_1[c];
        --tmp_0[c];
      }
      j >>= 1;
      ++c;
    }
    for (int j = 0; j < (int)(digit); ++j) {
      ct_1[i][j] = tmp_1[j] + ct_1[i - 1][j];
      ct_0[i][j] = tmp_0[j] + ct_0[i - 1][j];
    }
  }
  mint ans = 0;
  for (int i = (1); i < (int)(n); ++i) {
    VI tmp_1(digit), tmp_0(digit);
    for (int j = 0; j < (int)(digit); ++j) {
      tmp_1[j] = ct_1[n][j] - ct_1[i][j];
      tmp_0[j] = ct_0[n][j] - ct_0[i][j];
    }
    LL j = A[i - 1], c = 0;
    while (j) {
      if (j & 1) tmp_1[c] = tmp_0[c];
      j >>= 1;
      ++c;
    }
    for (int i = 0; i < (int)(digit); ++i) {
      mint x = 2;
      ans += x.pow(i) * tmp_1[i];
    }
  }
  cout << ans << endl;
  return 0;
}
