#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
inline int addmod(long long int x, long long int y) {
  return (x % 1000000007 + y % 1000000007) % 1000000007;
}
inline int submod(long long int x, long long int y) {
  return (x % 1000000007 - y % 1000000007 + 1000000007) % 1000000007;
}
inline int mulmod(long long int x, long long int y) {
  return (x % 1000000007 * y % 1000000007) % 1000000007;
}
inline int nextSubMask(int i, int mask) { return (i - 1) & mask; }
template <typename T>
void we_r_done(T mssg) {
  cout << mssg;
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  while (cin >> n) {
    long long int a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long int ans = 0;
    for (int i = 0; i <= 60; i++) {
      long long int cnt = 0, cnt2 = 0;
      for (int j = n; j; j--) {
        if (a[j] & (1LL << i)) {
          ans = addmod(ans, mulmod(cnt, 1LL << i));
          cnt2++;
        } else {
          cnt++;
          ans = addmod(ans, mulmod(cnt2, 1LL << i));
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
