#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15 + 10;
long long gcd(long long u, long long v) {
  if (u == v) return u;
  if (u == 0) return v;
  if (v == 0) return u;
  if (~u & 1) {
    if (v & 1)
      return gcd(u >> 1, v);
    else
      return gcd(u >> 1, v >> 1) << 1;
  }
  if (~v & 1) return gcd(u, v >> 1);
  if (u > v) return gcd((u - v) >> 1, v);
  return gcd((v - u) >> 1, u);
}
int n;
std::vector<int> bit;
std::vector<int> a;
std::vector<long long> numerator;
std::vector<long long> denominator;
void update(int idx_onebased, int value) {
  int diff = value - a[idx_onebased];
  a[idx_onebased] = value;
  while (idx_onebased <= n) {
    bit[idx_onebased] += diff;
    idx_onebased += (idx_onebased & -idx_onebased);
  }
}
long long get_sum(int idx_onebased) {
  long long sum = 0;
  while (idx_onebased) {
    sum += bit[idx_onebased];
    idx_onebased -= (idx_onebased & -idx_onebased);
  }
  return sum;
}
long long get_rank(int number) { return get_sum(number); }
bool predicate(int i, int k) { return get_rank(i) >= k; }
long long get_kth_numbet(int k) {
  int f = 0, l = n, mid = (f + l) / 2;
  while ((l - f) > 1) {
    if (predicate(mid, k))
      l = mid;
    else
      f = mid;
    mid = (f + l) / 2;
  }
  return l;
}
void insertElement(int x) { update(x, a[x] + 1); }
void deleteElement(int x) { update(x, a[x] - 1); }
void add_fraction(long long a, long long b) {
  a %= 998244353;
  b %= 998244353;
  long long gcd_cur = gcd(a, b);
  numerator.push_back(a / gcd_cur);
  denominator.push_back(b / gcd_cur);
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 998244353;
    y = y >> 1;
    x = (x * x) % 998244353;
  }
  return res;
}
long long inverse_mod(long long x) { return power(x, 998244353 - 2); }
long long get_fractions_sum_mod() {
  long long ans = 0;
  for (int i = 0; i < numerator.size(); i++) {
    ans += ((numerator[i] % 998244353) * (inverse_mod(denominator[i]))) %
           998244353;
    ans %= 998244353;
  }
  return ans;
}
int main() {
  bit = std::vector<int>(200001, 0);
  a = std::vector<int>(200001, 0);
  std::vector<int> v;
  cin >> n;
  int x;
  long long total_blanks = 0;
  long long static_inversions = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    if (x == -1) {
      total_blanks++;
      continue;
    }
    insertElement(x);
    static_inversions += (i + 1) - total_blanks - get_rank(x);
  }
  add_fraction(static_inversions, 1);
  if (!total_blanks) {
    cout << static_inversions % 998244353;
    return 0;
  }
  add_fraction((total_blanks) * (total_blanks - 1), 4);
  long long blanks_till_now = 0;
  for (int i = 0; i < n; i++) {
    x = v[i];
    if (x == -1) {
      blanks_till_now++;
      continue;
    }
    int current_greater_numbers = n - total_blanks - get_rank(x);
    int total_greater_numbers = n - x;
    long long greater_numbers_left =
        total_greater_numbers - current_greater_numbers;
    add_fraction(blanks_till_now * greater_numbers_left +
                     (total_blanks - blanks_till_now) *
                         (total_blanks - greater_numbers_left),
                 total_blanks);
  }
  cout << get_fractions_sum_mod();
  return 0;
}
