#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 5;
int tree[maxn], a[maxn];
int big[maxn][maxn], big2[maxn][maxn];
int n;
int lowbit(int x) { return x & -x; }
int sum(int x) {
  int ans = 0;
  for (int i = x; i > 0; i -= lowbit(i)) {
    ans += tree[i];
  }
  return ans;
}
void add(int x, int val) {
  for (int i = x; i <= n; i += lowbit(i)) {
    tree[i] += val;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d", &u);
    u++;
    a[i] = u;
  }
  int tot = 0;
  for (int i = n; i >= 1; i--) {
    tot += sum(a[i]);
    add(a[i], 1);
  }
  for (int i = n; i > 0; i--) {
    memset(tree, 0, sizeof(tree));
    for (int j = n; j >= i; j--) {
      if (a[j] > a[i]) add(a[j], 1);
      big[i][j] = sum(n) - sum(a[i] - 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(tree, 0, sizeof(tree));
    for (int j = 1; j <= i; j++) {
      if (a[j] > a[i]) add(a[j], 1);
      big2[i][j] = sum(n) - sum(a[i] - 1);
    }
  }
  int mintot = tot;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] < a[j]) continue;
      int t1 = 2 * (big[i][i + 1] - big[i][j]) - (j - (i + 1));
      int t2 = j - (i + 1) - 2 * (big2[j][j - 1] - big2[j][i]);
      int tmp = tot + t1 + t2 - 1;
      if (tmp < mintot)
        cnt = 1, mintot = tmp;
      else if (tmp == mintot)
        cnt++;
    }
  }
  printf("%d %d\n", mintot, cnt);
  return 0;
}
