#include <bits/stdc++.h>
using namespace std;
template <int sz>
struct BIT {
  long long b[sz + 1];
  BIT() {
    for (int i = 0; i < sz + 1; i++) b[i] = 0;
  }
  void add(int k, long long val) {
    k++;
    for (; k <= sz; k += (k & -k)) b[k] += val;
  }
  long long psum(int ind) {
    long long ans = 0;
    ind++;
    for (; ind > 0; ind -= (ind & -ind)) ans += b[ind];
    return ans;
  }
  long long sum(int l, int r) { return psum(r) - psum(l - 1); }
};
const long long MOD = 998244353;
const int MAX_N = 200200;
int n;
int arr[MAX_N];
BIT<MAX_N> countold;
BIT<MAX_N> countnew;
set<int> unused;
long long pwr(long long val, long long exp) {
  if (exp == 0) return 1LL;
  long long res = pwr(val, exp / 2);
  if (exp % 2 == 0) return (res * res) % MOD;
  long long ans = (res * res) % MOD;
  ans *= val;
  ans %= MOD;
  return ans;
}
long long inv(long long val) { return pwr(val, MOD - 2); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long k = 0;
  for (int i = 0; i < n; i++) k += (arr[i] == -1);
  long long res = 0;
  for (int i = 0; i < n; i++)
    if (arr[i] != -1) {
      res += countold.sum(arr[i] + 1, n);
      res %= MOD;
      countold.add(arr[i], 1LL);
    }
  long long newnew = k * (k - 1LL);
  newnew %= MOD;
  newnew *= inv(4LL);
  newnew %= MOD;
  res += newnew;
  res %= MOD;
  long long b = k;
  long long a = b;
  for (int i = 1; i < n + 1; i++) unused.insert(i);
  for (int i = 0; i < n; i++)
    if (arr[i] != -1) {
      unused.erase(unused.find(arr[i]));
    }
  for (int i : unused) countnew.add(i, 1);
  for (int i = 0; i < n; i++) {
    if (arr[i] == -1)
      a--;
    else {
      long long x = countnew.sum(1, arr[i] - 1);
      long long toadd = (x * a) % MOD;
      toadd *= inv(b);
      toadd %= MOD;
      res += toadd;
      res %= MOD;
      long long toadd2 = countnew.sum(arr[i] + 1, n);
      toadd2 *= b - a;
      toadd2 %= MOD;
      toadd2 *= inv(b);
      toadd2 %= MOD;
      res += toadd2;
      res %= MOD;
    }
  }
  return cout << res << '\n', 0;
  ;
}
