#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000007;   const long long int inf = 1e17;   const long long int N = 5005;   long long int n;   long long int a[N];   long long int dp[N][N];   long long int go(long long int idx, long long int flag) {     long long int &ans = dp[idx][flag];     if (ans != -1) return ans;     if (idx > n) {       return 0;     }     if (flag == 0 or flag == 2) {       ans = max(go(idx + 1, flag), go(idx + 1, flag + 1)) + a[idx];     } else {       ans = max(go(idx + 1, flag), go(idx + 1, flag + 1)) - a[idx];     }     return ans;   }   vector<long long int> res;   void backtrack(long long int idx, long long int flag) {     if (idx > n) {       return;     }     if (flag == 0 or flag == 2) {       long long int tmp1 = go(idx + 1, flag) + a[idx];       long long int tmp2 = go(idx + 1, flag + 1) + a[idx];       res.push_back(1);       if (tmp1 >= tmp2) {         backtrack(idx + 1, flag);       } else {         backtrack(idx + 1, flag + 1);       }     } else {       long long int tmp1 = go(idx + 1, flag) - a[idx];       long long int tmp2 = go(idx + 1, flag + 1) - a[idx];       res.push_back(0);       if (tmp1 >= tmp2) {         backtrack(idx + 1, flag);       } else {         backtrack(idx + 1, flag + 1);       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     memset(dp, -1, sizeof(dp));     cin >> n;     for (long long int i = 1; i <= n; i++) {       cin >> a[i];     }     long long int ans = go(0, 0);     backtrack(0, 0);     res.erase(res.begin());     long long int cnt = 0, idx = 0;     while (res[idx] and idx < n) {       cnt++;       idx++;     }     vector<long long int> vec;     vec.push_back(cnt);     cnt = 0;     idx = vec.back();     while (idx < n and !res[idx]) {       cnt++;       idx++;     }     vec.push_back(cnt);     idx = vec[0] + vec[1];     cnt = 0;     while (idx < n and res[idx]) {       cnt++;       idx++;     }     vec.push_back(cnt);     idx = 0, cnt = 0;     for (auto to : vec) {       cnt = to;       if (cnt == 0LL) {         cout << idx <<    ;       } else {         cout << idx + cnt <<    ;         idx += cnt;       }     }   }   