#include <bits/stdc++.h>
using namespace std;
const int maxl = 5005;
int n, cnt = 0, minv = 1e9 + 7, len = 0;
int a[maxl], pre[maxl][maxl], tmp[maxl][maxl];
int query_less(int l, int r, int x) {
  return pre[r][x - 1] - pre[l - 1][x - 1];
}
int query_equal(int l, int r, int x) { return tmp[r][x] - tmp[l - 1][x]; }
int query_more(int l, int r, int x) {
  return (r - l + 1) - query_less(l, r, x) - query_equal(l, r, x);
}
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) tmp[i][j] = tmp[i - 1][j];
    tmp[i][a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) pre[i][j] = pre[i][j - 1] + tmp[i][j];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (a[i] > a[j]) cnt++;
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    for (int j = i + 1; j <= n; j++) {
      int now = cnt, x = a[i], y = a[j];
      now -= query_less(i + 1, j, x);
      now += query_more(i + 1, j, x);
      now -= query_more(i, j - 1, y);
      now += query_less(i, j - 1, y);
      if (now < minv)
        minv = now, len = 1;
      else if (now == minv)
        len++;
    }
  }
  cout << minv + 1 << ' ' << len << endl;
  return 0;
}
