#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)998244353;
const int N = (int)2e5 + 7;
int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int mul(int a, int b) { return (long long)a * b % MOD; }
int Pow(int a, int k) {
  int re = 1;
  while (k) {
    if (k & 1) re = mul(re, a);
    a = mul(a, a);
    k >>= 1;
  }
  return re;
}
int tree[N << 1];
int query(int l, int r) {
  int re = 0;
  l += N, r += N;
  while (l <= r) {
    if (l & 1) re = add(re, tree[l++]);
    if (~r & 1) re = add(re, tree[r--]);
    l >>= 1, r >>= 1;
  }
  return re;
}
void update(int x) {
  x += N;
  while (x) {
    tree[x]++;
    x >>= 1;
  }
}
int cal(vector<int> &v) {
  int ans = 0;
  for (int i = (0); i < ((int)(v).size()); ++i) {
    ans = add(ans, query(v[i] + 1, N - 3));
    update(v[i]);
  }
  return ans;
}
vector<int> v;
int a[N], dp[N], jc[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  int unk = 0;
  for (int i = (0); i < (n); ++i) {
    if (a[i] == -1)
      unk++;
    else
      v.push_back(a[i]);
  }
  int s1 = cal(v);
  sort((v).begin(), (v).end());
  int rk = 0, ans = 0;
  for (int i = (0); i < (n); ++i) {
    if (a[i] == -1)
      rk++;
    else {
      int t =
          a[i] - (lower_bound((v).begin(), (v).end(), a[i]) - v.begin() + 1);
      ans = add(ans, mul(t, unk - rk));
      t = unk - t;
      ans = add(ans, mul(t, rk));
    }
  }
  dp[1] = 0;
  jc[1] = 1;
  for (int i = (2); i < (unk + 1); ++i) jc[i] = mul(jc[i - 1], i);
  for (int i = (2); i < (unk + 1); ++i) {
    dp[i] = add(mul(dp[i - 1], i),
                mul((long long)i * (i - 1) / 2 % MOD, jc[i - 1]));
  }
  ans = mul(ans, Pow(unk, MOD - 2));
  ans = add(ans, mul(dp[unk], Pow(jc[unk], MOD - 2)));
  ans = add(s1, ans);
  printf("%d\n", ans);
  return 0;
}
