#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 234567;
const int g = 3;
int tree[maxn * 4];
int n;
namespace BIT {
inline int lowbit(int x) { return x & -x; }
inline void update(int x, int y) {
  for (int i = x; i <= n; i += lowbit(i)) tree[i] += y;
}
inline int query(int x) {
  int res = 0;
  for (int i = x; i; i -= lowbit(i)) res += tree[i];
  return res;
}
inline void clear() {
  for (int i = 0; i <= n; i++) {
    tree[i] = 0;
  }
}
}  // namespace BIT
using namespace BIT;
int inv(int x) {
  if (x == 1) return 1;
  return (mod - mod / x) * inv(mod % x) % mod;
}
int main(int argc, char const *argv[]) {
  std::cin >> n;
  vector<int> a(n, 0);
  vector<int> b(n + 1);
  long long res = 0;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    if (a[i] <= 0) {
      cnt++;
    } else {
      update(a[i], 1);
      res = (res + query(n) - query(a[i]) + mod) % mod;
      b[a[i]] = 1;
    }
  }
  if (cnt == 0) {
    std::cout << res << '\n';
    return 0;
  }
  res = (res + (cnt * (cnt - 1) % mod) * inv(2) % mod * inv(2)) % mod;
  res %= mod;
  clear();
  for (int i = 1; i <= n; i++) {
    if (b[i] == 0) {
      update(i, 1);
    }
  }
  long long num = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= 0) {
      num++;
    } else {
      int k = cnt - query(a[i]);
      res = (res + k * num % mod * inv(cnt)) % mod;
      res = (res + (cnt - k) * (cnt - num) % mod * inv(cnt)) % mod;
    }
  }
  std::cout << res << '\n';
  return 0;
}
