#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, mod = 998244353;
int n, p[N], cntMinus1, fact[N], invFact[N], ans, nonEx[N];
int binPow(int _a, int _m) {
  int ret = 1;
  for (; _m; _m >>= 1, _a = 1LL * _a * _a % mod)
    if (_m & 1) ret = 1LL * ret * _a % mod;
  return ret;
}
int C(int _k, int _n) {
  if (_k > _n || _k < 0) return 0;
  return 1LL * fact[_n] * invFact[_k] % mod * invFact[_n - _k] % mod;
}
int get(int _n) {
  return 1LL * C(2, _n) * binPow(2, mod - 2) % mod * fact[n] % mod;
}
struct Bit {
  int cnt[N];
  void update(int pos, int val) {
    for (; pos < N; pos += pos & -pos) cnt[pos] += val;
  }
  int get(int pos) {
    int ret = 0;
    for (; pos > 0; pos -= pos & -pos) ret += cnt[pos];
    return ret;
  }
} bit;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) nonEx[i] = 1;
  for (int i = 1; i <= n; ++i) scanf("%d", p + i), cntMinus1 += (p[i] == -1);
  for (int i = 1; i <= n; ++i)
    if (p[i] != -1) nonEx[p[i]] = 0;
  for (int i = 1; i <= n; ++i) nonEx[i] += nonEx[i - 1];
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = 1LL * fact[i - 1] * i % mod;
  invFact[n] = binPow(fact[n], mod - 2);
  for (int i = n - 1; i >= 0; --i)
    invFact[i] = 1LL * invFact[i + 1] * (i + 1) % mod;
  int cnt = 0;
  for (int i = n; i > 0; --i) {
    if (p[i] != -1)
      cnt = (cnt + nonEx[n] - nonEx[p[i]]) % mod;
    else {
      ans =
          (ans + 1LL * cnt * fact[n] % mod * binPow(cntMinus1, mod - 2)) % mod;
    }
  }
  cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (p[i] != -1)
      cnt = (cnt + nonEx[p[i] - 1]) % mod;
    else {
      ans =
          (ans + 1LL * cnt * fact[n] % mod * binPow(cntMinus1, mod - 2)) % mod;
    }
  }
  ans = (ans + get(cntMinus1)) % mod;
  for (int i = n; i > 0; --i)
    if (p[i] != -1) {
      bit.update(p[i], 1);
      ans = (ans + 1LL * bit.get(p[i] - 1) * fact[n]) % mod;
    }
  cout << 1LL * ans * invFact[n] % mod;
  return 0;
}
