// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
const int MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;
    vector<ll> values(n);
    rep(i, 0, n)
        cin >> values[i];

    ll res = 0;
    ll base = 1;
    for(;;)
    {
      bool go_next = false;

      // count one and zeros
      ll ones = 0;
      for (auto& value: values)
      {
          if (value&1)
            ++ones;
          if (value > 0)
            go_next = true;
          value >>= 1;
      }
      // update
      res += (ll)((base%MOD)*ones*(n-ones))%MOD;
      res %= MOD;

      if (res<0)
        res += MOD;

      base <<= 1;
      base %= MOD;
      // break check
      if (!go_next)
        break;
    }

    cout << res << endl;
    return 0;
}
