#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long mod = 998244353;
long long cnt[maxn], n, ans, a[maxn], fw[maxn], m, invm, inv2, s[maxn],
    ha[maxn];
long long fpm(long long a, long long p) {
  long long r = 1, base = a;
  while (p) {
    if (p & 1) r = r * base % mod;
    base = base * base % mod;
    p /= 2;
  }
  return r;
}
long long lbt(long long x) { return x & (-x); }
void add(int x) {
  while (x <= n) {
    fw[x]++;
    x += lbt(x);
  }
}
long long sum(long long x) {
  long long summ = 0;
  while (x) {
    summ += fw[x];
    x -= lbt(x);
  }
  return summ;
}
long long inv(long long n1) { return fpm(n1, mod - 2); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] == -1)
      m++;
    else
      s[a[i]] = 1;
  }
  invm = fpm(m, mod - 2);
  inv2 = fpm(2, mod - 2);
  ans = (m - 1) * m % mod * inv(4);
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1) continue;
    ans = (ans + sum(n) - sum(a[i] - 1)) % mod;
    add(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + (s[i] == 0);
  }
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1)
      cnt++;
    else {
      ans = (ans + invm * (m - s[a[i]]) % mod * cnt % mod) % mod;
    }
  }
  cnt = 0;
  for (int i = n; i >= 1; i--) {
    if (a[i] == -1)
      cnt++;
    else {
      ans = (ans + invm * (s[a[i]]) % mod * cnt % mod) % mod;
    }
  }
  cout << ans % mod << endl;
  return 0;
}
