#include <bits/stdc++.h>
using namespace std;
int tree[5555], n, c[5555], g[5555][5555];
void update(int idx, int val) {
  for (; idx <= n + 10; idx += (idx & -idx)) tree[idx] += val;
}
int read(int idx) {
  int sum = 0;
  for (; idx; idx -= (idx & -idx)) sum += tree[idx];
  return sum;
}
int main() {
  int i, j, inv = 0, ans = 1000000000, cont;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    c[i]++;
  }
  for (i = n; i >= 1; i--) {
    update(c[i], 1);
    inv += read(c[i] - 1);
    for (j = 1; j <= n; j++) {
      g[i][j] = read(j - 1);
    }
  }
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) {
      int lij = g[j][c[i]];
      int lji = g[i][c[j]];
      int lii = g[i][c[i]];
      int ljj = g[j][c[j]];
      int gii = n - lii;
      int gjj = n - lij;
      int gi = gii - gjj;
      int gii1 = n - lji;
      int gjj1 = n - ljj;
      int gj = gii1 - gjj1;
      int tot = inv - lii + lij + gi - ljj + lji - gj;
      if (tot < ans) {
        ans = tot;
        cont = 1;
      } else if (tot == ans)
        cont++;
    }
  printf("%d %d", ans - 1, cont);
  return 0;
}
