#include <bits/stdc++.h>
const int INF = 1e9;
const long long MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
template <typename T>
void print(const vector<T> &x) {
  int n = x.size();
  for (int i = 0; i < (n); ++i) {
    cout << x[i];
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
}
template <typename T>
void print(const vector<vector<T>> &x) {
  int n = x.size();
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (x[i].size()); ++j) {
      cout << x[i][j] << " ";
    }
    cout << endl;
  }
}
template <typename T>
void print(const vector<T> &x, int n) {
  for (int i = 0; i < (n); ++i) {
    cout << x[i];
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
}
template <typename T>
void print(const vector<vector<T>> &x, int n, int m) {
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (m); ++j) {
      cout << x[i][j] << " ";
    }
    cout << endl;
  }
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
void input_init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};
using modint = ModInt<MOD>;
long long mpow(long long x, long long n) {
  long long ans = 1ll;
  while (n != 0) {
    if (n & 1) ans = ans * x % MOD;
    x = x * x % MOD;
    n = n >> 1;
  }
  return ans;
}
int main(int argc, char const *argv[]) {
  input_init();
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<modint> mae(62);
  for (int i = 0; i < (62); ++i) {
    mae[i] = mpow(2, i);
  }
  vector<vector<long long>> c(62, vector<long long>(n));
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    for (long long j = 0; j < 62; ++j)
      if (a[i] & (1ll << j)) c[j][i] = 1;
  }
  vector<long long> s(a);
  for (int i = 0; i < (n - 1); ++i) s[i + 1] += s[i];
  for (int j = 0; j < (62); ++j) {
    for (int i = 0; i < (n - 1); ++i) {
      c[j][i + 1] += c[j][i];
    }
  }
  modint ans = 0;
  for (int i = 0; i < (n - 1); ++i) {
    long long d = a[i];
    vector<long long> b;
    for (long long j = 0; j < 62; ++j) {
      if (d & (1ll << j)) {
        b.push_back(j);
      }
    }
    for (auto &&e : b) {
      modint kieru = c[e][n - 1] - c[e][i];
      modint x = (n - i - 1);
      modint tasu = x - kieru;
      kieru = kieru * mae[e];
      tasu = tasu * mae[e];
      ans += tasu;
      ans -= kieru;
    }
    ans += (s[n - 1] - s[i]);
  }
  cout << ans << endl;
  return 0;
}
