#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 998244353;
long long jc[N] = {1}, ny[N] = {1};
int a[N], tr[N];
void Add(long long &x, long long y) { x = (x + y) % mod; }
void Mul(long long &x, long long y) { x = (x * y) % mod; }
long long add(long long x, long long y) { return (x + y) % mod; }
long long mul(long long x, long long y) { return x * y % mod; }
long long q_pow(long long x, int y) {
  long long ans = 1;
  for (; y; y >>= 1) {
    if (y & 1) Mul(ans, x);
    Mul(x, x);
  }
  return ans;
}
int lower(int x) { return x & (-x); }
void insert(int x, int k) {
  for (; x < N; x += lower(x)) tr[x] += k;
}
int Get(int x) {
  int ans = 0;
  for (; x; x -= lower(x)) ans += tr[x];
  return ans;
}
long long A(int x, int y) {
  if (x < y) return 0ll;
  return mul(jc[x], ny[x - y]);
}
int main() {
  int n;
  scanf("%d", &n);
  int res = 0;
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    jc[i] = mul(jc[i - 1], i), ny[i] = q_pow(jc[i], mod - 2);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == -1)
      res++;
    else {
      Add(ans, i - 1 - res - Get(a[i]));
      insert(a[i], 1);
    }
  }
  if (res) Add(ans, mul(mul(res, res - 1), q_pow(4, mod - 2)));
  int gg = 0;
  long long bas = q_pow(res, mod - 2);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == -1)
      gg++;
    else {
      int pos = Get(a[i] - 1);
      int tmp = a[i] - 1 - pos;
      Add(ans, mul(gg, mul(res - tmp, bas)));
      Add(ans, mul(res - gg, mul(tmp, bas)));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
