#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200500;
const long long PHI = (long long)998244352;
const long long INF = 0x3f3f3f3f;
const long long LINF = 0x1f3f3f3f3f3f3f3f;
const long long MOD = (long long)998244353;
const long long OVER_FLOW = 0xffffffff;
long long n, k, m;
long long extend_gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0 && b == 0) return -1;
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extend_gcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
long long inv(long long a, long long n) {
  long long x, y;
  long long d = extend_gcd(a, n, x, y);
  if (d == 1)
    return (x % n + n) % n;
  else
    return -1;
}
long long a[MAXN], ans[MAXN << 2];
inline long long lchild(long long x) { return x << 1; }
inline long long rchild(long long x) { return x << 1 | 1; }
inline void push_up(long long p) { ans[p] = ans[lchild(p)] + ans[rchild(p)]; }
void build(long long p, long long l, long long r) {
  if (l == r) {
    ans[p] = 0;
    return;
  }
  long long mid = (l + r) >> 1;
  build(lchild(p), l, mid);
  build(rchild(p), mid + 1, r);
  push_up(p);
}
inline void update(long long nl, long long nr, long long l, long long r,
                   long long p) {
  if (nl <= l && r <= nr) {
    ans[p] = 1;
    return;
  }
  long long mid = (l + r) >> 1;
  if (nl <= mid) update(nl, nr, l, mid, lchild(p));
  if (nr > mid) update(nl, nr, mid + 1, r, rchild(p));
  push_up(p);
}
long long query(long long q_x, long long q_y, long long l, long long r,
                long long p) {
  long long res = 0;
  if (q_x <= l && r <= q_y) return ans[p];
  long long mid = (l + r) >> 1;
  if (q_x <= mid) res += query(q_x, q_y, l, mid, lchild(p));
  if (q_y > mid) res += query(q_x, q_y, mid + 1, r, rchild(p));
  return res;
}
long long buf[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  build(1, 1, n);
  long long res = 0, tot = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> buf[i];
    if (buf[i] == -1) {
      tot++;
    } else {
      res = (res + query(buf[i], n, 1, n, 1)) % MOD;
      update(buf[i], buf[i], 1, n, 1);
    }
  }
  res = (res + tot * (tot - 1) % MOD * inv(4ll, MOD) % MOD) % MOD;
  long long cnt = 0;
  if (tot > 0) {
    for (long long i = 1; i <= n; i++) {
      if (buf[i] == -1)
        cnt++;
      else {
        long long les = buf[i] - query(1, buf[i], 1, n, 1), grt = tot - les;
        res = (res + inv(tot, MOD) * grt % MOD * cnt % MOD) % MOD;
        res = (res + inv(tot, MOD) * les % MOD * (tot - cnt) % MOD) % MOD;
      }
    }
  }
  cout << res << endl;
  return 0;
}
