#include <bits/stdc++.h>
using namespace std;
const int NMax = 5100;
int N, A[NMax], F[NMax], sum[NMax], sum1[NMax];
int T[3][NMax];
void insert(int a, int b, int first, int second, int p, int t) {
  for (int i = a; i <= N; i += (i & (i ^ (i - 1)))) T[t][i] += b;
}
int calc(int a, int b, int first, int second, int p, int t) {
  if (a > b) return 0;
  int ret = 0;
  for (int i = b; i > 0; i -= (i & (i ^ (i - 1)))) ret += T[t][i];
  for (int i = a - 1; i > 0; i -= (i & (i ^ (i - 1)))) ret -= T[t][i];
  return ret;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", A + i), A[i]++;
  for (int i = 2; i <= N; i++) {
    for (int j = 1; j < i; j++)
      if (A[j] > A[i]) F[i]++;
    sum[i] = sum[i - 1] + F[i];
  }
  for (int i = N; i >= 1; i--) sum1[i] = sum1[i + 1] + F[i];
  int minn = 1000000000, ret;
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      int cnt = sum[i - 1] + sum1[j + 1] + sum[j - 1] - sum[i];
      cnt += calc(A[i] + 1, N, 1, N, 1, 0) + calc(A[i] + 1, N, 1, N, 1, 1) +
             calc(A[j] + 1, N, 1, N, 1, 1) +
             calc(A[i] + 1, A[j] - 1, 1, N, 1, 0) -
             calc(A[j] + 1, A[i] - 1, 1, N, 1, 0);
      if (cnt < minn) {
        minn = cnt;
        ret = 1;
      } else if (cnt == minn)
        ret++;
      insert(A[j], 1, 1, N, 1, 0);
    }
    for (int j = i + 1; j <= N; j++) insert(A[j], -1, 1, N, 1, 0);
    insert(A[i], 1, 1, N, 1, 1);
  }
  printf("%d %d\n", minn, ret);
  return 0;
}
