#include <bits/stdc++.h>
using namespace std;
int DP[5000 + 5][5000 + 5];
int DP2[5000 + 5][5000 + 5];
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> A(n);
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    memset(DP, 0, sizeof(DP));
    memset(DP2, 0, sizeof(DP2));
    for (int x = 0; x < n; x++) {
      for (int i = n - 1; i >= 0; --i) {
        DP[x][i] = DP[x][i + 1] + (A[i] < x);
        DP2[x][i] = DP2[x][i + 1] + (A[i] > x);
      }
    }
    int op = 0;
    for (int i = 0; i < n; i++) op += DP[A[i]][i];
    int ans = INT_MAX;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        int temp = 0;
        int x = A[i], y = A[j];
        temp -= (DP[x][i + 1] - DP[x][j]);
        temp -= (DP2[y][i + 1] - DP2[y][j]);
        temp -= (x > y);
        swap(x, y);
        temp += (DP[x][i + 1] - DP[x][j]);
        temp += (DP2[y][i + 1] - DP2[y][j]);
        temp += (x > y);
        if (temp < ans) {
          ans = temp;
          cnt = 1;
        } else if (temp == ans) {
          cnt++;
        }
      }
    }
    printf("%d %d\n", op + ans, cnt);
  }
}
