#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int> a(n), b={1,0,1,0},c={0,1,0,1};
    cin >> a[0];
    long long max_=a[0],min_=a[0];
    for(int i =1;i<n;i++){
        cin>>a[i];
        if(a[i]>max_){max_ = a[i];}
        if(a[i]<min_){min_=a[i];}

    }
    if(a==b||a==c){
        cout<<0<<endl<<1<<" "<<2<<" "<<3;return 0;
    }

    if(n==3){
        cout << max_-min_ << endl;
        for(int i = 1;i<=3;i++)
            cout<<i<<" ";
    }
    else {
        vector<int>arr ;

        if(n==6){
            if(a[0]==a[n-1]){
                cout<<0<<endl<<2<<" "<<4<<" "<<6;
            }
            else {
                cout<<0<<endl<<1<<" "<<3<<" "<<5;
            }
        }
        else {
            long long sum=0;
            vector<long long> sum_;
                arr.push_back(1);

            for(int i = 1,cou=1;i<n;i++){

                if(a[i]==a[i-1]||cou==2){

                    arr.push_back(i+1);
                    sum_.push_back(sum);
                    sum = 0;cou=0;
                }{sum+=a[i];cou++;}
            }
            if(arr[0]==1)sum_.push_back(sum);
            sort(sum_.begin(),sum_.end());

            cout<<1-sum_[0]<<endl;
            if(arr.size()==2){
                arr.push_back(arr[1]+1);
            }
            for(int i =0;i<arr.size();i++){
                cout<<arr[i]<<" ";
            }

        }


    }

    return 0;
}
