#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool Min(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
inline ll nl() {
  ll a;
  scanf("%lld", &a);
  return a;
}
inline double nd() {
  double a;
  scanf("%lf", &a);
  return a;
}
inline void pi(int a) { printf("%d ", a); }
inline void pl(ll a) { printf("%lld ", a); }
inline void pd(double a) { printf("%.12lf ", a); }
const int N = 5005;
int n;
int a[N];
int l[N][N], r[N][N];
int cnt[N];
void solve() {
  n = ni();
  for (int i = 0; i < (int)(n); ++i) a[i] = ni();
  for (int i = 0; i < n; i++) {
    for (int j = n; j >= 0; j--) l[i][j] = l[i][j + 1] + cnt[j + 1];
    cnt[a[i]]++;
  }
  fill(cnt, cnt + n, 0);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 1; j <= n; j++) r[i][j] = r[i][j - 1] + cnt[j - 1];
    cnt[a[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans += r[i][a[i]];
  int ansCnt = 1;
  int total = ans;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] < a[j]) continue;
      int cur = total;
      cur -= r[j][a[j]] + r[i][a[i]] + l[i][a[i]] + l[j][a[j]] - 1;
      cur += r[i][a[j]] + l[i][a[j]] + r[j][a[i]] + l[j][a[i]];
      if (Min(ans, cur))
        ansCnt = 1;
      else if (ans == cur)
        ansCnt++;
    }
  }
  cout << ans << " " << ansCnt << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
