#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LINF = 1ll << 55;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
template <typename T>
ostream& operator<<(ostream& out, vector<T>& vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    out << *it << " ";
  }
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, pair<T, T>& P) {
  out << P.first << " " << P.second;
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    in >> *it;
  }
  return in;
}
template <typename T>
istream& operator>>(istream& in, pair<T, T>& P) {
  in >> P.first >> P.second;
  return in;
}
struct Edge {
  int to;
  ll weight;
  int next;
  bool operator<(const Edge& rhs) { return weight < rhs.weight; }
};
template <typename T>
struct Edge2 {
  T from, to, weight;
  Edge2(T from_, T to_, T weight_) : from(from_), to(to_), weight(weight_) {}
  Edge2() : from(T(0)), to(T(0)), weight(T(0)) {}
  bool operator<(const Edge2& rhs) { return weight < rhs.weight; }
};
class UnionFind {
  vector<ll> par;

 public:
  explicit UnionFind(ll n) : par(n, -1) {}
  ll root(ll a) {
    if (par[a] < 0) {
      return a;
    }
    return par[a] = root(par[a]);
  }
  ll size(ll a) { return -par[root(a)]; }
  void unite(ll a, ll b) {
    a = root(a);
    b = root(b);
    if (a != b) {
      if (size(a) < size(b)) {
        swap(a, b);
      }
      par[a] += par[b];
      par[b] = a;
    }
  }
};
struct SegmentTreeNode {
  ll maxVal;
  ll minVal;
  ll sum;
  ll len;
  ll lazy;
  ll left, right;
  SegmentTreeNode() {}
};
class SegmentTree {
 public:
  explicit SegmentTree(size_t size, const vll& nums)
      : tree(size << 2), nums(nums) {}
  void build(ll root, ll left, ll right) {
    tree[root].lazy = 0;
    tree[root].left = left;
    tree[root].right = right;
    tree[root].len = right - left + 1;
    if (left == right) {
      tree[root].maxVal = nums[left];
      tree[root].minVal = nums[left];
      tree[root].sum = nums[left];
    } else {
      ll mid = (right - left) / 2 + left;
      build(root * 2, left, mid);
      build(root * 2 + 1, mid + 1, right);
      tree[root].minVal = min(tree[root * 2].minVal, tree[root * 2 + 1].minVal);
      tree[root].maxVal = max(tree[root * 2].maxVal, tree[root * 2 + 1].maxVal);
      tree[root].sum = tree[root * 2].sum + tree[root * 2 + 1].sum;
    }
  }
  void pushup(ll root) {
    tree[root].minVal = min(tree[root * 2].minVal, tree[root * 2 + 1].minVal);
    tree[root].maxVal = max(tree[root * 2].maxVal, tree[root * 2 + 1].maxVal);
    tree[root].sum = tree[root * 2].sum + tree[root * 2 + 1].sum;
  }
  void add(ll root, ll id, ll addVal) {
    if (tree[root].left == tree[root].right) {
      tree[root].maxVal += addVal;
      tree[root].minVal += addVal;
      tree[root].sum += addVal;
      return;
    }
    ll mid = (tree[root].right - tree[root].left) / 2 + tree[root].left;
    if (id <= mid) {
      add(root * 2, id, addVal);
    } else {
      add(root * 2 + 1, id, addVal);
    }
    pushup(root);
  }
  void pushdown(ll root) {
    if (tree[root].lazy) {
      tree[root * 2].lazy += tree[root].lazy;
      tree[root * 2 + 1].lazy += tree[root].lazy;
      tree[root * 2].sum += tree[root * 2].len * tree[root].lazy;
      tree[root * 2 + 1].sum += tree[root * 2 + 1].len * tree[root].lazy;
      tree[root * 2].maxVal += tree[root].lazy;
      tree[root * 2 + 1].maxVal += tree[root].lazy;
      tree[root * 2].minVal += tree[root].lazy;
      tree[root * 2 + 1].minVal += tree[root].lazy;
      tree[root].lazy = 0;
    }
  }
  ll querySum(ll root, ll left, ll right) {
    if (tree[root].left >= left && tree[root].right <= right) {
      return tree[root].sum;
    }
    if (tree[root].left > right || tree[root].right < left) {
      return 0;
    }
    if (tree[root].lazy) {
      pushdown(root);
    }
    return querySum(root * 2, left, right) +
           querySum(root * 2 + 1, left, right);
  }
  ll queryMax(ll root, ll left, ll right) {
    if (tree[root].left >= left && tree[root].right <= right) {
      return tree[root].maxVal;
    }
    if (tree[root].left > right || tree[root].right < left) {
      return -INF;
    }
    if (tree[root].lazy) {
      pushdown(root);
    }
    return max(queryMax(root * 2, left, right),
               queryMax(root * 2 + 1, left, right));
  }
  ll queryMin(ll root, ll left, ll right) {
    if (tree[root].left >= left && tree[root].right <= right) {
      return tree[root].minVal;
    }
    if (tree[root].left > right || tree[root].right < left) {
      return INF;
    }
    if (tree[root].lazy) {
      pushdown(root);
    }
    return min(queryMin(root * 2, left, right),
               queryMin(root * 2 + 1, left, right));
  }
  void update(ll root, ll left, ll right, ll addVal) {
    if (tree[root].left >= left && tree[root].right <= right) {
      tree[root].lazy += addVal;
      tree[root].sum += tree[root].len * addVal;
      tree[root].maxVal += addVal;
      tree[root].minVal += addVal;
      return;
    }
    if (tree[root].left > right || tree[root].right < left) {
      return;
    }
    if (tree[root].lazy) {
      pushdown(root);
    }
    update(root * 2, left, right, addVal);
    update(root * 2 + 1, left, right, addVal);
    pushup(root);
  }

 private:
  vector<SegmentTreeNode> tree;
  const vll& nums;
};
ll factorial(ll n) {
  ll ret = 1;
  for (ll i = 1; i <= n; ++i) {
    ret = (ret * i) % MOD;
  }
  return ret;
}
ll inv_mod(ll n) {
  ll a = n % MOD, b = MOD - 2, ret = 1;
  while (b > 0) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}
ll nPr(ll n, ll r) {
  ll ret = 1;
  for (ll i = n; i >= n - r + 1; --i) {
    ret = ret * (i % MOD) % MOD;
  }
  return ret;
}
ll nCr(ll n, ll r) {
  if (r > n - r) {
    return nCr(n, n - r);
  }
  return nPr(n, r) * inv_mod(factorial(r)) % MOD;
}
inline ll ADD(ll a, ll b) { return (a + b) % MOD; }
inline ll MUL(ll a, ll b) { return (a % MOD) * (b % MOD) % MOD; }
inline ll SUB(ll a, ll b) { return (a + MOD - b) % MOD; }
inline ll POW(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}
int main() {
  int N;
  cin >> N;
  vll A(N);
  vll count_bits(70);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    for (int k = 0; k < 60; ++k) {
      if (A[i] & (1ll << k)) {
        count_bits[k]++;
      }
    }
  }
  vll ans(70);
  for (int k = 0; k < 60; ++k) {
    for (int i = 0; i < N; ++i) {
      if (A[i] & (1ll << k)) {
        ans[k] += N - i - count_bits[k];
        count_bits[k]--;
      } else {
        ans[k] += count_bits[k];
      }
    }
  }
  ll res = 0;
  for (int k = 0; k < 70; ++k) {
    if (ans[k] > 0) {
      ans[k + 1] += ans[k] / 2;
    }
    ans[k] %= 2;
    res = res | (ans[k] << k);
  }
  res %= MOD;
  cout << (res) << endl;
  return 0;
}
