#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-9;
const long long INF = 10e17;
double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }
std::istream &operator>>(std::istream &in, set<int> &o) {
  int a;
  in >> a;
  o.insert(a);
  return in;
}
std::istream &operator>>(std::istream &in, queue<int> &o) {
  long long a;
  in >> a;
  o.push(a);
  return in;
}
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % mod + mod) % mod) {}
  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 res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend std::istream &operator>>(std::istream &in, mint &o) {
    long long a;
    in >> a;
    o = a;
    return in;
  }
  friend std::ostream &operator<<(std::ostream &out, const mint &o) {
    out << o.x;
    return out;
  }
};
class CumulativeSum {
  vector<long long> numbers;
  vector<long long> sums;

 public:
  CumulativeSum(int n) {
    numbers.resize(n);
    sums.resize(n);
  }
  void set(int i, long long value) { numbers[i] = value; }
  long long getSum(int i) {
    if (i == -1) return 0;
    if (i == sums.size()) return sums.back();
    return sums[i];
  }
  long long getSectionSum(int start, int end) {
    return getSum(end) - getSum(start - 1);
  }
  void build() {
    for (int i = 0; i < numbers.size(); i++) {
      sums[i] = getSum(i - 1) + numbers[i];
    }
  }
};
int main() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < (n); ++i) cin >> v[i];
  vector<CumulativeSum> css(62, CumulativeSum(n));
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (62); ++j) {
      css[j].set(i, (v[i] >> j) & 1);
    }
  }
  for (int j = 0; j < (62); ++j) {
    css[j].build();
  }
  mint ans = 0;
  for (int i = 0; i < (n); ++i) {
    long long l = v[i];
    mint now = 0;
    for (int j = 0; j < (62); ++j) {
      long long c = css[j].getSectionSum(i + 1, n);
      long long one = c;
      long long zero = n - i - 1 - c;
      if ((l >> j) & 1) {
        now += (zero << j);
      } else {
        now += (one << j);
      }
    }
    ans += now;
  }
  cout << ans << endl;
}
