#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
int mulmd(long long a, long long b) {
  long long ret = (a * b) % 1000000007;
  return (int)ret;
}
inline int power(long long x, long long y, int p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = mulmd(res, x);
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int)res;
}
int submd(long long a, long long b) {
  long long ret = a - b;
  if (ret < 0) {
    ret += 1000000007;
  }
  return (int)ret;
}
int addmd(long long a, long long b) {
  long long ret = (a + b) % 1000000007;
  return (int)ret;
}
int invPow(long long a) { return power(a, 1000000007 - 2, 1000000007); }
const int N = 3e5 + 5;
long long arr[N];
long long sufSum[N];
long long bitsSum[N][65];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> arr[i];
  for (int i = (n - 1); i >= (1); i--) {
    if (i == n - 1)
      sufSum[i] = arr[i];
    else {
      sufSum[i] = addmd(arr[i], sufSum[i + 1]);
    }
  }
  for (int i = (n - 1); i >= (0); i--) {
    for (int j = 0; j < 60; j++) {
      if (arr[i] & (1LL << j)) {
        bitsSum[i][j] = bitsSum[i + 1][j] + 1;
      } else {
        bitsSum[i][j] = bitsSum[i + 1][j];
      }
    }
  }
  long long s = 0;
  for (int i = n - 2; i >= 0; i--) {
    s = addmd(s, sufSum[i + 1]);
    for (int j = 0; j < 60; j++) {
      if (arr[i] & (1LL << j)) {
        int cnt = bitsSum[i + 1][j];
        long long tmp = 0;
        if (mulmd(n - i - 1 - cnt, (1LL << j)) >= mulmd(cnt, (1LL << j))) {
          tmp =
              submd(mulmd(n - i - 1 - cnt, (1LL << j)), mulmd(cnt, (1LL << j)));
          s = addmd(s, tmp);
        } else {
          tmp =
              submd(mulmd(cnt, (1LL << j)), mulmd(n - i - 1 - cnt, (1LL << j)));
          s = submd(s, tmp);
        }
      }
    }
  }
  cout << s;
}
