func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)2e5 + 5;   const int MOD = 998244353;   int bit[MAXN];   bool got[MAXN];   int p[MAXN];   void gcd(long long a, long long b, long long& x, long long& y) {     if (b == 0) {       x = 1;       y = 0;       return;     }     gcd(b, a % b, y, x);     y -= (a / b) * x;     return;   }   long long inv(long long a) {     long long x, y;     gcd(a, MOD, x, y);     return (x % MOD + MOD) % MOD;   }   void add(int idx, int n) {     while (idx <= n) {       bit[idx]++;       idx += idx & -idx;     }     return;   }   int query(int idx) {     int sum = 0;     while (idx > 0) {       sum += bit[idx];       idx -= idx & -idx;     }     return sum;   }   void init(int n) {     for (int i = 1; i <= n; i++) {       bit[i] = 0;     }     return;   }   long long calc(int n) {     long long ans = 0;     init(n);     for (int i = n; i >= 1; i--) {       if (p[i] != -1) {         ans += query(p[i]);         add(p[i], n);       }     }     return ans % MOD;   }   long long expected(int n) {     long long ans = (1LL * n * (n - 1)) % MOD;     ans *= inv(4);     return ans % MOD;   }   bool compatible(vector<int> v, int n) {     for (int i = 1; i <= n; i++) {       if (p[i] != -1 && v[i - 1] != p[i]) {         return false;       }     }     return true;   }   long long get_inversions(vector<int> v, int n) {     init(n);     long long ans = 0;     for (int i = n - 1; i >= 0; i--) {       ans += query(v[i]);       add(v[i], n);     }     return ans % MOD;   }   long long brute(int n) {     vector<int> v(n);     for (int i = 0; i < n; i++) {       v[i] = i + 1;     }     long long ans = 0;     long long perm = 0;     do {       if (compatible(v, n)) {         ans += get_inversions(v, n);         perm++;       }     } while (next_permutation(v.begin(), v.end()));     printf( here ans = %lld, perm = %lld, inv = %lld n , ans, perm, inv(perm));     return (1LL * ans * inv(perm)) % MOD;   }   int main(void) {     int n;     int vacant = 0;     int start_vacant = 0;     scanf(  %d , &n);     for (int i = 1; i <= n; i++) {       scanf(  %d , &p[i]);       got[p[i]] = true;       if (p[i] == -1) {         vacant++;       }     }     init(n);     start_vacant = vacant;     for (int i = 1; i <= n; i++) {       if (!got[i]) {         add(i, n);       }     }     long long ans = 0;     int left = 0;     for (int i = 1; i <= n; i++) {       if (p[i] != -1) {         long long aux = 1LL * query(p[i]) * vacant;         aux %= MOD;         ans += aux * inv(start_vacant);         ans %= MOD;         aux = 1LL * (query(n) - query(p[i])) * left;         aux %= MOD;         ans += aux * inv(start_vacant);         ans %= MOD;       } else {         left++;         vacant--;       }     }     ans += expected(start_vacant);     ans += calc(n);     ans %= MOD;     printf( %lld n , ans);     return 0;   }   