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

typedef long long int ll;

int val[1001];
int dp[1001];
vector<int> history[1001];

int calc(int n){
    switch(n){
        case 0:
            return val[0];
        case 1:
            return max(val[0],val[1]);
        default:
            if (!dp[n]){
                int a=calc(n-1),b=val[n]+calc(n-2);
                if (a>=b){
                    history[n]=history[n-1];
                    dp[n]=a;
                }else{
                    history[n]=history[n-2];
                    history[n].push_back(n);
                    dp[n]=b;
                }
            }
            return dp[n];
    }
}

int main(){
    int i,j,k,l,m,n,h,x,y,w;
    // int i,j,k;
    
    cin >> n;
    
    if (n==1){
        cin>>i;
        cout<<i<<endl;
        cout<<1<<endl;
        return 0;
    }
    
    for (i=0;i<n;i++){
        scanf("%d",val+i);
    }
    
    history[0].push_back(0);
    history[1].push_back(val[0]>=val[1] ? 0 : 1);
    
    cout << calc(n-1) <<endl;
    for (int e:history[n-1]){
        printf("%d ",e+1);
    }
    cout<<endl;
    
    return 0;
}