#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;



struct DSU {
    int n;
    vector<int> p, h;

    DSU(int m) {
        n = m;
        p.assign(n + 1, -1);
        h.assign(n + 1, 1);

        for (int i = 0; i <= n; i++) {
            p[i] = i;
            h[i] = 1;
        }
    }

    int findParent(int node) {
        if (p[node] == node) {
            return node;
        }
        return p[node] = findParent(p[node]);
    }

    bool sameSet(int a, int b) {
        a = findParent(a);
        b = findParent(b);
        return a == b;
    }

    void unionSets(int a, int b) {
        a = findParent(a);
        b = findParent(b);
        if (a == b) return;
        if (h[a] < h[b]) {
            swap(a, b);
        }
        p[b] = a;
        h[a] += h[b];
    }
};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    ll a[n] = {};
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    ll ans = LLONG_MAX;
    int aa = -1, bb = -1, cc = -1;

    ll first = a[0], second = a[1], third = sum - a[0] - a[1];
    int i = 0, j = 0, k = 1;

    while (i <= n) {
        while ((k + 2) % n != i && second < third && (second + a[(k + 1) % n]) < (third - a[(k + 1) % n])) {
            k = (k + 1) % n;
            second += a[k];
            third -= a[k];
        }
        if (first > second && first > third) {
            first -= a[i];
            third += a[i];
            i++;
            if (i == j + 1) {
                j = (j + 1) % n;
                first += a[j];
                second -= a[j];

                if (j == k) {
                    k = (k + 1) % n;
                    second += a[k];
                    third -= a[k];
                }
            }
            continue;
        }
        if (first > second) {
            if ((k + 2) % n == i) {
                first -= a[i];
                third += a[i];
                i++;
                if (i == j + 1) {
                    j = (j + 1) % n;
                    first += a[j];
                    second -= a[j];

                    if (j == k) {
                        k = (k + 1) % n;
                        second += a[k];
                        third -= a[k];
                    }
                }
            }
            else {
                k = (k + 1) % n;
                second += a[k];
                third -= a[k];
            }
            continue;
        }
        if (first > third) {
            first -= a[i];
            third += a[i];
            i++;
            if (i == j + 1) {
                j = (j + 1) % n;
                first += a[j];
                second -= a[j];

                if (j == k) {
                    k = (k + 1) % n;
                    second += a[k];
                    third -= a[k];
                }
            }
            continue;
        }
        if (first <= second && first <= third) {
            if (max(second, third) - first < ans) {
                ans = max(second, third) - first;
                aa = i;
                bb = (j + 1) % n;
                cc = (k + 1) % n;
            }
        }
        if ((k + 2) % n != i) {
            if (max(second + a[(k + 1) % n], third - a[(k + 1) % n]) - first < ans) {
                ans = max(second + a[(k + 1) % n], third - a[(k + 1) % n]) - first;
                aa = i;
                bb = (j + 1) % n;
                cc = (k + 2) % n;
            }
        }
        j = (j + 1) % n;
        first += a[j];
        second -= a[j];
    }

    printf("%lld\n", ans);
    vector<int> answers = {aa, bb, cc};
    sort(answers.begin(), answers.end());
    for (int i =0 ; i < 3; i++) {
        printf("%i ", answers[i] + 1);
    }
    printf("\n");

    


    
    
}