#include <bits/stdc++.h>
namespace IO {
char ch = '\n';
template <class T>
inline T ReadInt() {
  T x(0);
  bool f(1);
  while (ch < '0' || '9' < ch) {
    if (ch == '-') {
      f = 0;
    }
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f ? x : -x;
}
template <class T>
inline T ReadUInt() {
  T x(0);
  while (ch < '0' || '9' < ch) {
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x;
}
inline double ReadDouble() {
  long long int_num = ReadInt<long long>();
  if (ch == '.') {
    double pow10 = 1, result = int_num;
    ch = getchar();
    while ('0' <= ch && ch <= '9') {
      pow10 /= 10.0;
      result += pow10 * (ch ^ 48);
      ch = getchar();
    }
    return result;
  } else {
    return (double)int_num;
  }
}
inline void ReadT(int &x) { x = ReadInt<int>(); }
inline void ReadT(long long &x) { x = ReadInt<long long>(); }
inline void ReadT(bool &x) { x = ReadUInt<bool>(); }
inline void ReadT(unsigned int &x) { x = ReadUInt<unsigned int>(); }
inline void ReadT(unsigned long long &x) { x = ReadUInt<unsigned long long>(); }
inline void ReadT(double &x) { x = ReadDouble(); }
inline void ReadT(char &s) {
  for (; isspace(ch) && (~ch); ch = getchar())
    ;
  s = ch;
  ch = '\n';
}
inline void ReadT(char *s) {
  int len(0);
  for (; isspace(ch) && (~ch); ch = getchar())
    ;
  for (; !isspace(ch) && (~ch); ch = getchar()) {
    s[len++] = ch;
  }
  s[len] = '\0';
  ch = '\n';
}
template <typename T>
inline void Read(T &t) {
  ReadT(t);
}
template <typename T, typename... Args>
void Read(T &t, Args &...args) {
  ReadT(t);
  Read(args...);
}
template <typename T>
void WriteInt(T x) {
  if (x < 0) {
    printf("-");
    x = -x;
  }
  if (9 < x) {
    WriteInt(x / 10);
  }
  putchar(x % 10 + '0');
}
template <typename T>
void WriteUInt(T x) {
  if (9 < x) {
    WriteInt(x / 10);
  }
  putchar(x % 10 + '0');
}
void WriteDouble(long double x, int len) {
  WriteInt((long long)x);
  if (len) {
    x -= (int)x;
    putchar('.');
    if (!x) {
      while (len--) {
        putchar(48);
      }
      return;
    }
    while (len--) {
      x *= 10;
    }
    WriteInt((long long)round(x));
  }
}
template <typename T>
inline void WriteT(T x);
template <>
inline void WriteT<int>(int x) {
  WriteInt<int>(x);
}
template <>
inline void WriteT<long long>(long long x) {
  WriteInt<long long>(x);
}
template <>
inline void WriteT<bool>(bool x) {
  WriteUInt<bool>(x);
}
template <>
inline void WriteT<unsigned int>(unsigned int x) {
  WriteUInt<unsigned int>(x);
}
template <>
inline void WriteT<unsigned long long>(unsigned long long x) {
  WriteUInt<unsigned long long>(x);
}
template <>
inline void WriteT<double>(double x) {
  WriteDouble(x, 6);
}
template <>
inline void WriteT<char *>(char *s) {
  int len(strlen(s));
  while (len--) {
    putchar(*s++);
  }
}
template <>
inline void WriteT<const char *>(const char *s) {
  while (*s) {
    putchar(*s++);
  }
}
template <>
inline void WriteT<char>(char x) {
  putchar(x);
}
template <typename T>
inline void Write(T t) {
  WriteT(t);
}
template <typename T, typename... Args>
void Write(T t, Args... args) {
  WriteT(t);
  Write(args...);
}
template <typename T>
inline void Writeln(T t) {
  WriteT(t);
  puts("");
}
template <typename T, typename... Args>
inline void Writeln(T t, Args... args) {
  WriteT(t);
  Write(args...);
  puts("");
}
inline void Writeln() { puts(""); }
const char NUMBER[36] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
                         '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
                         'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
                         'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
template <typename T>
void WriteK(T x, int p) {
  if (x < 0) {
    printf("-");
    x = -x;
  }
  if (p <= x) {
    WriteK(x / p, p);
  }
  putchar(NUMBER[x % p]);
}
}  // namespace IO
using namespace IO;
using namespace std;
const long long MOD = 998244353;
const int MAXN = 2e5 + 5;
inline long long Pow(long long a, long long b, long long mod = MOD) {
  long long result = 1;
  while (b) {
    if (b & 1) {
      result *= a;
      result %= mod;
    }
    a *= a;
    a %= mod;
    b /= 2;
  }
  return result;
}
long long Sqr(long long a) { return a % MOD * a % MOD; }
int n;
int arr[MAXN];
int tree[MAXN];
int emp[MAXN];
long long fac[MAXN];
int Lowbit(int now) { return now & -now; }
void Add(int num) {
  for (int now = num; now <= n; now += Lowbit(now)) {
    tree[now]++;
  }
}
int Query(int num) {
  int result = 0;
  for (int now = num; now; now -= Lowbit(now)) {
    result += tree[now];
  }
  return result;
}
int main() {
  Read(n);
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    Read(arr[i]);
    emp[i] = emp[i - 1];
    if (~arr[i]) {
      sum += i - emp[i] - 1 - Query(arr[i]);
      Add(arr[i]);
    } else {
      ++emp[i];
    }
  }
  sum %= MOD;
  fac[0] = fac[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  sum *= fac[emp[n]];
  sum %= MOD;
  for (int i = 1; i <= n; ++i) {
    if (~arr[i]) {
      long long small = arr[i] - Query(arr[i]);
      long long big = emp[n] - small;
      if (big || small) {
        sum += ((emp[i]) * big + (emp[n] - emp[i]) * small) % MOD *
               fac[emp[n] - 1];
        sum %= MOD;
      }
    }
  }
  if (1 < emp[n]) {
    sum += Sqr(1ll * emp[n] * (emp[n] - 1) / 2) * fac[emp[n] - 2];
    sum %= MOD;
  }
  Writeln(sum * Pow(fac[emp[n]], MOD - 2) % MOD);
  return 0;
}
