
#include <bits/stdc++.h>
using namespace std;

using ll= long long;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << factorial(7);
    int n;
    cin>>n;
    vector<int> arr(n);
    int minn = 1000000000;
    int maxx = 0;
    ll sum =0;
    for (int i = 0; i < n;i++) {
        cin>>arr[i];
        sum += arr[i];
        maxx = max(maxx, arr[i]);
        minn = min(minn, arr[i]);
    }
    if (n==3) {
        cout << maxx-minn << endl;
        cout << 1 << " " << 2 << " " << 3 << endl;
    }
    else {
        ll dif = sum/3;

        int x=0;
        int y = 0;
        int z = 0;
        for (int i = 0; i < n;i++) {
            bool found = false;
            ll temp_sum = 0;
            for (int j = i; j < n;j++) {
                temp_sum += arr[j];
                if (temp_sum>dif)break;
                if (temp_sum==dif) {
                    x=i+1;
                    y=j+2;
                    found = true;
                    break;
                }

            }
            if (found) break;

        }
        ll temp_sum = 0;

        for (int i = y-1; i < n;i++) {
            temp_sum+=arr[i];
            if (temp_sum==dif) {
                z=i+2;
            }

        }
        cout << 0 << endl;
        cout << x << " " << y << " " << z << endl;
        // for (int i = x; )
    }
    return 0;
}