#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200100, md = 998244353;
long long t[MAXN];
long long a[MAXN], g[MAXN];
bool used[MAXN];
long long get(long long r) {
  long long ans = 0;
  while (r > 0) {
    ans += t[r];
    r = (r & (r + 1)) - 1;
  }
  return ans;
}
long long get(long long l, long long r) { return get(r) - get(l - 1); }
void update(long long pos, long long val) {
  while (pos < MAXN) {
    t[pos] += val;
    pos = (pos | (pos + 1));
  }
}
long long binpow(long long a, long long n) {
  long long rez = 1;
  while (n) {
    if (n & 1) rez = rez * a % md;
    a = a * a % md;
    n >>= 1;
  }
  return rez;
}
int32_t main() {
  long long n, cnt = 0, cntt = 0;
  long long ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == -1)
      cnt++;
    else {
      used[a[i]] = 1;
      ans += get(a[i], n);
      update(a[i], 1);
    }
  }
  long long x = 0;
  for (long long i = n; i >= 1; i--) {
    g[i] = x;
    x += !used[i];
  }
  ans += cnt * (cnt - 1) % md * binpow(4, md - 2) % md;
  ans %= md;
  for (long long i = 0; i < n; i++) {
    if (a[i] == -1)
      cntt++;
    else {
      ans += cntt * (g[a[i]]) % md * binpow(cnt, md - 2) % md;
      ans += (cnt - cntt) * (cnt - g[a[i]]) % md * binpow(cnt, md - 2) % md;
      ans %= md;
    }
  }
  cout << ans << '\n';
}
