#include <bits/stdc++.h>
int n, s;
int a[5010];
int dp[5010][5010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; scanf("%d", &a[i++]))
    ;
  for (int j = 0; j < n; ++j) {
    for (int i = 1; i < n; ++i) {
      dp[i][j] = dp[i - 1][j];
      if (a[i - 1] > j) ++dp[i][j];
      if (a[i] == j) s += dp[i][j];
    }
  }
  int min = 10000000;
  int c = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int m = dp[i][a[j]] - dp[j][a[j]];
      m += dp[j][a[i]] - dp[i][a[i]];
      int l = j - i - 1;
      int l1 = l - (dp[j][a[i]] - dp[i][a[i]]);
      int l2 = l - (dp[j][a[j]] - dp[i][a[j]] - 1);
      m -= l1 - l2;
      if (m < min)
        min = m, c = 1;
      else if (m == min)
        ++c;
    }
  }
  printf("%d %d\n", s + min, c);
}
