#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int fac[200005];
int arr[200005];
bool flag[200005];
int c[200005];
int n;
int down[200005];
int up[200005];
int mm;
void clear() { memset(c, 0, sizeof(c)); }
void insert(int v) {
  while (v < 200005) {
    c[v]++;
    v += (v & (-v));
  }
}
int sum(int p) {
  int res = 0;
  while (p) {
    res += c[p];
    p -= p & (-p);
  }
  return res;
}
int fpow(int a, int p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = (long long)res * a % mod;
    }
    p >>= 1;
    a = (long long)a * a % mod;
  }
  return res;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i < 200005; i++) {
    fac[i] = (long long)fac[i - 1] * i % mod;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", arr + i);
  }
  clear();
  for (int i = 1; i <= n; i++) {
    if (arr[i] == -1) {
      mm++;
      continue;
    }
    insert(arr[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (arr[i] == -1) continue;
    down[i] = arr[i] - 1 - sum(arr[i] - 1);
    up[i] = n - arr[i] - sum(n) + sum(arr[i]);
  }
  clear();
  int res = 0;
  int cc = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] == -1) {
      cc++;
      continue;
    }
    int tmp;
    if (mm) {
      tmp = (long long)up[i] * fpow(mm, mod - 2) % mod;
      tmp = (long long)tmp * cc % mod;
      tmp = (long long)tmp * fac[mm] % mod;
      res = (res + tmp) % mod;
      tmp = (long long)down[i] * fpow(mm, mod - 2) % mod;
      tmp = (long long)tmp * (mm - cc) % mod;
      tmp = (long long)tmp * fac[mm] % mod;
      res = (res + tmp) % mod;
    }
    tmp = sum(n) - sum(arr[i]);
    res = (res + (long long)tmp * fac[mm]) % mod;
    insert(arr[i]);
  }
  if (mm >= 2) {
    int tmp = ((long long)mm * (mm - 1) / 2) % mod;
    tmp = (long long)tmp * fac[mm] % mod;
    tmp = (long long)tmp * fpow(2, mod - 2) % mod;
    res = (res + tmp) % mod;
  }
  res = (long long)res * fpow(fac[mm], mod - 2) % mod;
  cout << res << endl;
  return 0;
}
