#include <bits/stdc++.h>
using namespace std;
const long long P = 998244353;
long long n;
long long p[200010];
vector<long long> v;
long long arr[200010];
long long pow(long long a, long long b) {
  if (b == 0) return 1LL;
  long long x = pow(a, b / 2);
  long long ret = x * x % P;
  if (b % 2) ret = ret * a % P;
  return ret;
}
long long inv(long long a) { return pow(a, P - 2); }
long long bit[200010];
long long lowbit(long long x) { return x & (-x); }
long long query(long long x) {
  if (!x) return 0;
  long long ans = 0;
  while (x > 0) {
    ans += bit[x];
    x -= lowbit(x);
  }
  return ans;
}
void modify(long long x) {
  while (x <= 200010) {
    bit[x]++;
    x += lowbit(x);
  }
}
long long segment(long long x, long long y) { return query(y) - query(x - 1); }
long long inversions() {
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    modify(v[i]);
    ans += segment(v[i] + 1, n);
  }
  return ans;
}
int main() {
  long long unknown = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    p[i] = x;
    if (x > 0) {
      v.push_back(x);
      arr[x]++;
    } else
      unknown++;
  }
  for (int i = 1; i <= n; i++) arr[i] = arr[i - 1] + arr[i];
  long long ans = (unknown * (unknown - 1)) % P * inv(2) % P * inv(2) % P;
  long long left = 0;
  long long right = unknown - left;
  for (int i = 0; i < n; i++) {
    if (p[i] == -1) {
      left++;
      right--;
      continue;
    }
    long long addleft =
        left * (unknown + arr[p[i]] - p[i]) % P * inv(unknown) % P;
    long long addright = right * (p[i] - arr[p[i]]) % P * inv(unknown) % P;
    ans = (ans + addleft + addright) % P;
  }
  ans = (ans + inversions()) % P;
  cout << ans << endl;
}
