#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unsigned long long int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  unsigned long long int bit[60];
  int max = 0;
  for (int i = 0; i < 60; i++) bit[i] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 60; j++) {
      if (a[i] & ((unsigned long long int)1 << j)) {
        bit[j]++;
        if (max < j) max = j;
      }
    }
  }
  max++;
  for (int i = 0; i < max; i++) cout << bit[i] << " ";
  cout << endl;
  unsigned long long int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < max; j++) {
      if (a[i] & ((unsigned long long int)1 << j)) {
        bit[j]--;
        ans += (n - 1 - i - bit[j]) * ((1 << j) % 1000000007);
      } else {
        ans += bit[j] * ((1 << j) % 1000000007);
      }
      if (ans >= 1000000007) ans %= 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
