#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const int mod = 998244353;
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
int mul(int a, int b) { return (long long)a * b % mod; }
int qpow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    b >>= 1;
  }
  return ans;
}
int t[N];
int upd(int p, int v) {
  for (; p > 0; p -= p & -p) t[p] += v;
  return 1;
}
int get(int p) {
  int ans = 0;
  for (; p < N; p += p & -p) ans += t[p];
  return ans;
}
int n;
int p[N];
int f[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int ans = 0;
  int cnt = 0;
  fill(f + 1, f + 1 + n, 1);
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
    if (p[i] > 0) {
      ans = add(ans, get(p[i]));
      upd(p[i], 1);
      f[p[i]] = 0;
    } else
      ++cnt;
  }
  for (int i = n; i >= 1; --i) f[i] += f[i + 1];
  ans = add(ans, mul(mul(cnt, cnt - 1), 748683265));
  int cur = 0;
  for (int i = 1; i <= n; ++i) {
    if (p[i] < 0) {
      ++cur;
      continue;
    }
    ans = add(ans, mul(mul(cur, f[p[i]]), qpow(cnt, mod - 2)));
  }
  for (int i = 1; i <= n; ++i) f[i] = cnt - f[i];
  cur = 0;
  for (int i = n; i >= 1; --i) {
    if (p[i] < 0) {
      ++cur;
      continue;
    }
    ans = add(ans, mul(mul(cur, f[p[i]]), qpow(cnt, mod - 2)));
  }
  cout << ans << endl;
}
