#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
const long long MOD = 998244353;
long long power(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    p /= 2;
  }
  return ret;
}
long long n;
long long a[N];
long long isOne[N];
long long preOne[N], sufOne[N];
long long fact[N];
long long infact[N];
long long inv4;
int bit[N];
void up(int pos, int val) {
  for (; pos <= n; pos += pos & -pos) {
    bit[pos] += val;
  }
}
int get(int pos) {
  int ret = 0;
  for (; pos > 0; pos -= pos & -pos) {
    ret += bit[pos];
  }
  return ret;
}
long long countExpectedInver(long long x) {
  return ((x * (x - 1)) % MOD * (inv4) % MOD) % MOD;
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  infact[n] = power(fact[n], MOD - 2);
  for (long long i = n - 1; i >= 0; i--) {
    infact[i] = (infact[i + 1] * (i + 1)) % MOD;
  }
  inv4 = power(4, MOD - 2);
  for (long long value = 1; value <= n; value++) {
    isOne[value] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    isOne[a[i]] = 0;
  }
  for (long long value = 1; value <= n; value++) {
    isOne[value] += isOne[value - 1];
  }
  for (long long i = 1; i <= n; i++) {
    preOne[i] = preOne[i - 1] + (a[i] == -1);
  }
  for (long long i = n; i >= 1; i--) {
    sufOne[i] = sufOne[i + 1] + (a[i] == -1);
  }
  long long allOne = preOne[n];
  long long ret = 0;
  long long countInver = 0;
  for (long long i = 1; i <= n; i++) {
    if (a[i] == -1) {
      continue;
    }
    long long nSmall = isOne[a[i]];
    long long nBig = allOne - nSmall;
    ret += (nBig * preOne[i]) % MOD * power(allOne, MOD - 2) % MOD;
    ret %= MOD;
    ret += (nSmall * sufOne[i]) % MOD * power(allOne, MOD - 2) % MOD;
    ret %= MOD;
    countInver += get(n) - get(a[i]);
    up(a[i], 1);
  }
  ret += countExpectedInver(allOne);
  ret += countInver;
  ret %= MOD;
  cout << ret;
  return 0;
}
