#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define dep(i, l, r) for (int i = r; i >= l; --i)
const int N = 5e3 + 5;
const int P = 998244353;
int n, r, c, ans, a[N], b[N], fac[N], inv[N], f[N][N];
int inc (int a, int b) { return (a += b) >= P ? a - P : a; }
int dec (int a, int b) { return (a -= b) < 0 ? a + P : a; }
int mul (int a, int b) { return 1ll * a * b % P; }
int fpow (int a, int b) { int ans = 1; for ( ; b; a = mul(a, a), b >>= 1) if(b & 1) ans = mul(ans, a); return ans; }
void init (int n) {
fac[0] = inv[0] = 1;
rep(i, 1, n) fac[i] = mul(fac[i - 1], i), inv[i] = fpow(fac[i], P - 2);
}
int calc () {
rep(i, 1, n) if(a[i] >= i) r = i;
c = a[r + 1];
memset(f, 0, sizeof(f));
f[0][0] = 1;
rep(i, 1, r) rep(j, 0, min(i, c)) {
f[i][j] = mul(f[i - 1][j], a[i] - (c - j));
if(j) f[i][j] = inc(f[i][j], mul(f[i - 1][j - 1], c - j + 1));
}
return f[r][c];
}
int main () {
ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n, init(n);
rep(i, 1, n) cin >> a[i];
reverse(a + 1, a + n + 1);
ans = inc(ans, calc());
rep(i, 1, n) ++b[a[i]];
dep(i, 1, n) b[i] += b[i + 1], a[i] = b[i];
ans = inc(ans, calc());
ans = dec(ans, fac[r]);
cout << r << ' ' << ans << '\n';
return 0;
}