#include <iostream>
#include <vector>
#define ll long long
#define pii std::pair<int, int>
#define sz 1000001
#define inf 100000000001
class segtree {
private:
    const int DEFAULT = 0;
    std::vector<int> tree;
    int n;
    int combine(const int& a, const int& b);
    void build(const std::vector<int>& arr, int v, int tl, int tr);
    int sum(int v, int tl, int tr, int l, int r);
public:
    segtree(int nn);
    segtree(const std::vector<int>& arr);
    void build(const std::vector<int>& arr);
    int sum(int l, int r);
};
segtree::segtree(int nn) : n(nn) {
    tree = std::vector<int>(4 * n, DEFAULT);
};
segtree::segtree(const std::vector<int>& arr) : n((int)arr.size()) {
    tree = std::vector<int>(4 * n, DEFAULT);
    build(arr, 1, 0, n - 1);
};
int segtree::combine(const int& a, const int& b) {
    return a + b;
};
void segtree::build(const std::vector<int>& arr, int v, int tl, int tr) {
    if (tl == tr) {
        tree[v] = arr[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(arr, 2 * v, tl, tm);
        build(arr, 2 * v + 1, tm + 1, tr);
        tree[v] = combine(tree[2 * v], tree[2 * v + 1]);
    }
};
int segtree::sum(int v, int tl, int tr, int l, int r) {
    if (tl > r || tr < l || tl > tr) {
        return DEFAULT;
    }
    if (tl >= l && tr <= r) {
        return tree[v];
    }
    int tm = (tl + tr) / 2;
    int left_res = sum(2 * v, tl, tm, l, std::min(r, tm));
    int right_res = sum(2 * v + 1, tm + 1, tr, std::max(l, tm + 1), r);
    return combine(left_res, right_res);
}
void segtree::build(const std::vector<int>& arr) {
    build(arr, 1, 0, n - 1);
};
int segtree::sum(int l, int r) {
    return sum(1, 0, n - 1, l, r);
};
int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
        sum += a[i];
    }
    segtree st(a);
    int ans = inf;
    int xxx = -1, yyy = -1, zzz = -1;
    for (int x = 0; x < n; ++x) {
        for (int y = x + 1; y < n; ++y) {
            for (int z = y + 1; z < n; ++z) {
                int xx = st.sum(x, y - 1);
                int yy = st.sum(y, z - 1);
                int zz = sum - xx - yy;
                int mn = std::min(xx, std::min(yy, zz));
                int mx = std::max(xx, std::max(yy, zz));
                if (ans > (mx - mn)) {
                    ans = mx - mn;
                    xxx = x + 1;
                    yyy = y + 1;
                    zzz = z + 1;
                }
            }
        }
    }
    std::cout << ans << '\n';
    std::cout << xxx << ' ' << yyy << ' ' << zzz << '\n';
    return 0;
}