func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   long long pwr(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % MOD;       b >>= 1, a = a * a % MOD;     }     return ans;   }   long long inv(long long a) { return pwr(a, MOD - 2); }   template <class T, int SZ>   struct BIT {     T bit[SZ + 1];     BIT() { memset(bit, 0, sizeof bit); }     void upd(int k, T val) {       for (; k <= SZ; k += (k & -k)) bit[k] += val;     }     T query(int k) {       T temp = 0;       for (; k > 0; k -= (k & -k)) temp += bit[k];       return temp;     }     T query(int l, int r) { return query(r) - query(l - 1); }   };   BIT<long long, 1 << 18> b1;   BIT<long long, 1 << 18> b2;   map<int, bool> m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, cnt = 0, ans = 0, k;     cin >> n;     long long a[n];     for (int i = 0; i < n; ++i) {       cin >> a[i];       if (a[i] == -1)         ++cnt;       else {         m[a[i]] = 1;       }     }     ans += ((cnt * (cnt - 1)) % MOD * inv((long long)4)) % MOD;     for (int i = 0; i < n; ++i) {       if (a[i] != -1) {         b1.upd(a[i], 1LL);         ans += b1.query(a[i] + 1, n);         ans %= MOD;       }     }     for (int i = 1; i <= n; ++i) {       if (!m[i]) b2.upd(i, 1LL);     }     long long left[n], right[n], t = 0;     for (int i = 0; i < n; ++i) {       left[i] = t;       t += (a[i] == -1);     }     t = 0;     for (int i = n - 1; i >= 0; --i) {       right[i] = t;       t += (a[i] == -1);     }     for (int i = 0; i < n; ++i) {       if (a[i] != -1) {         k = (left[i] * b2.query(a[i], n)) % MOD;         k = (k * inv(cnt)) % MOD;         ans += k;         k = (right[i] * b2.query(1, a[i])) % MOD;         k = (k * inv(cnt)) % MOD;         ans += k;         ans %= MOD;       }     }     cout << ans % MOD <<   n ;     return 0;   }   