#include <bits/stdc++.h>
using namespace std;
int n, a[200002];
long long sp[200002];
vector<int> v;
int aib[200002];
void upd(int pos) {
  for (int i = pos; i >= 1; i -= i & (-i)) aib[i]++;
}
long long qry(int pos) {
  long long ans = 0;
  for (int i = pos; i <= n; i += i & (-i)) ans += aib[i];
  return ans;
}
long long ind[200002];
long long pwr(long long a, long long b) {
  if (b == 0) return 1;
  long long p = pwr(a, b / 2);
  if (b % 2 == 0) return p * p % 998244353;
  return p * p % 998244353 * a % 998244353;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == -1)
      sp[i]++;
    else
      v.push_back(a[i]);
    sp[i] += sp[i - 1];
  }
  long long ans = 0;
  if (sp[n] > 0)
    ans = (sp[n] * (sp[n] - 1)) % 998244353 * pwr(4, 998244353 - 2) % 998244353;
  for (int i = 0; i < v.size(); i++) {
    ans += qry(v[i]);
    ans %= 998244353;
    upd(v[i]);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) ind[v[i]] = i + 1;
  if (sp[n] > 0)
    for (int i = 1; i <= n; i++)
      if (a[i] != -1) {
        ans = (ans +
               (sp[n] - sp[i]) * (a[i] - ind[a[i]]) % 998244353 *
                   pwr(sp[n], 998244353 - 2) % 998244353 +
               sp[i] * (n - a[i] + 1 - (v.size() - ind[a[i]] + 1)) % 998244353 *
                   pwr(sp[n], 998244353 - 2) % 998244353) %
              998244353;
      }
  cout << ans << "\n";
  return 0;
}
