#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 2;
const int mod = 998244353;
int n, cnt;
int a[maxn], b[maxn];
bool vis[maxn];
int bit[maxn];
struct Binary_Indexed_Tree {
  int lowbit(int x) { return x & -x; }
  void add(int x, int val) {
    while (x) {
      bit[x] += val;
      x -= lowbit(x);
    }
  }
  int sum(int x) {
    int ret = 0;
    while (x <= n) {
      ret += bit[x];
      x += lowbit(x);
    }
    return ret;
  }
};
Binary_Indexed_Tree BIT;
long long inv[maxn];
void init() {
  inv[1] = 1;
  for (int i = 2; i < maxn; i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (~a[i]) vis[a[i]] = true;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) b[++cnt] = i;
  long long tot = 0, ans = 1LL * cnt * (cnt - 1) % mod * inv[4] % mod;
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1) {
      tot++;
      continue;
    }
    ans = (ans + BIT.sum(a[i])) % mod;
    BIT.add(a[i], 1);
    int pos = lower_bound(b + 1, b + cnt + 1, a[i]) - b - 1;
    ans = (ans + (1ll * tot * (cnt - pos) % mod * inv[cnt] +
                  1ll * pos * (cnt - tot) % mod * inv[cnt] % mod)) %
          mod;
  }
  printf("%I64d", ans);
  return 0;
}
