func_code_string: #include <bits/stdc++.h>   using namespace std;   int N;   long long arr[100020];   long long prefix[100020];   multiset<long long> s;   set<int> ded;   long long range(int i, int j) {     if (i == 0) {       return prefix[j];     } else {       return prefix[j] - prefix[i - 1];     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     if (fopen( cf722c.in ,  r )) {       freopen( cf722c.in ,  r , stdin);       freopen( cf722c.out ,  w , stdout);     }     cin >> N;     arr[0] = 0;     for (int i = 1; i <= N; i++) {       cin >> arr[i];     }     prefix[0] = arr[0];     for (int i = 1; i <= N + 1; i++) {       prefix[i] = prefix[i - 1] + arr[i];     }     s.insert(0);     s.insert(prefix[N + 1]);     ded.insert(0);     ded.insert(N + 1);     for (int i = 0; i < N; i++) {       int x;       cin >> x;       ded.insert(x);       int l = 0, r = 0;       auto lt = ded.lower_bound(x);       if (lt == ded.begin()) {         l = 0;       } else {         lt--;         l = *lt;         l++;       }       auto rt = ded.upper_bound(x);       if (rt == ded.end()) {         r = N + 1;       } else {         r = *rt;         r--;       }       s.erase(s.find(range(l, r)));       s.insert(range(l, x - 1));       s.insert(range(x + 1, r));       cout << *(s.rbegin()) <<   n ;     }     return 0;   }   