#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1e9 + 1;
const long double EPS = 1e-9;
void precalc() {}
const int maxn = (int)5e3 + 10;
int a[maxn];
int n;
bool read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  return 1;
}
int countLess[maxn][maxn + 1];
void solve() {
  for (int val = 0; val <= n; ++val) {
    countLess[val][0] = 0;
    for (int i = 0; i < n; ++i) {
      countLess[val][i + 1] = countLess[val][i] + (a[i] < val);
    }
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += countLess[n][i] - countLess[a[i]][i];
  }
  int res = sum + 1;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i - 1; j >= 0; --j) {
      int cur = sum +
                2 * (countLess[a[i]][i] - countLess[a[i]][j + 1] -
                     countLess[a[j]][i] + countLess[a[j]][j + 1]) +
                (a[i] > a[j] ? 1 : -1);
      if (res > cur) {
        res = cur;
        cnt = 0;
      }
      if (res == cur) {
        ++cnt;
      }
    }
  }
  assert(cnt);
  printf("%d %d\n", res, cnt);
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
