#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
#ifdef _MSC_VER
#include <intrin.h>
#define popcount __popcnt
#else
#define popcount __builtin_popcount
#endif
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
for (auto&& v : a) {
std::cin >> v;
v--;
}
unsigned edge_count = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (a[i] < a[j])
edge_count++;
}
}
auto bitsize = (edge_count + 31) >> 5;
std::vector<std::vector<unsigned>> g(n, std::vector<unsigned>(bitsize));
edge_count = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (a[i] < a[j]) {
g[i][edge_count >> 5] |= 1u << (edge_count & 31);
g[j][edge_count >> 5] |= 1u << (edge_count & 31);
edge_count++;
}
}
}
std::vector<unsigned> bor(bitsize);
std::vector<unsigned> bxor(bitsize);
std::vector<std::pair<int, long long>> r(n, std::make_pair(n * n, 0));
for (unsigned long long i = 1; i < 1uLL << n; i++) {
std::fill(bor.begin(), bor.end(), 0);
std::fill(bxor.begin(), bxor.end(), ~0u);
auto it = g.begin();
int size = -1;
for (unsigned long long j = i; j; j >>= 1, ++it) {
if (j & 1) {
size++;
std::transform(bor.begin(), bor.end(), it->begin(), bor.begin(), std::bit_or<unsigned> {});
std::transform(bxor.begin(), bxor.end(), it->begin(), bxor.begin(), std::bit_xor<unsigned> {});
}
}
std::transform(bor.begin(), bor.end(), bxor.begin(), bor.begin(), std::bit_and<unsigned> {});
int val = std::accumulate(bor.begin(), bor.end(), 0, [](int lhs, unsigned rhs) {
return lhs + popcount(rhs);
});
auto& [min_val, count] = r[size];
if (val < min_val) {
min_val = val;
count = 1;
} else if (val == min_val) {
count++;
}
}
for (const auto& [min_val, count] : r) {
std::cout << min_val << ' ' << count << '\n';
}
return 0;
}