1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* Dejwo to ziomal ®© */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
typedef tuple <int, int, int> ti;
typedef vector < pl > vpl;
typedef vector < pi > vpi;
typedef vector < ti > vti;

//double t = clock();
//cout << (clock() - t) / CLOCKS_PER_SEC <<endl;
bool debug = false;
#define deb if(debug)
#define pb push_back
#define FOR(i,x,n) for(int i = x; i < n; i++)
#define SIZE (3 * 1e5 + 42)
#define MAX (1000000 + 42)
#define MOD (1000000000 + 9)
#define DRZ (2<<21)
#define PI 3.14159265

map < int, pi > M;
void foo(vi &V)
{
  int n = (int)V.size();
  if(n == 0) return;
  int ile = 0;
  FOR(i, 0, n)
  {
    FOR(j, i + 1, n)
      if(V[j] < V[i]) ile ++;
  }
  int best = M[n].first;
  if(ile < best) {
    M[n].second = 1;
    M[n].first = ile;
  }
  else if(ile == best){
    M[n].second ++;
  }

  // cout << n << " -- " << ile << endl;
}

void solve()
{
  int n;
  cin >> n;
  vi V(n);
  FOR(i, 0, n){
    cin >> V[i];
    M[i + 1] = {1000, 1000};
  }

  FOR(i, 0, 1 << n){
    vi tmp;
    FOR(j, 0, n){
      if((1 << j) & i)
        tmp.pb(V[j]);
    }
    foo(tmp);
  }

  for(auto a: M)
    cout << a.second.first << " " << a.second.second << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    FOR(i, 0, 1)
      solve();


    return 0;
}