#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[1005];
vector<int> ans;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for (i=0;i<n;i++)
    {
        if (a[i]>=0) break;
    }
    if (i==n)
    {
        int max_ans=-1000000001;
        int i;
        for (i=0;i<n;i++)
        {
            max_ans=max(max_ans,a[i]);
        }
        printf("%d\n",max_ans);
        printf("%d\n",n-1);
        for (i=0;i<n;i++)
        {
            if (a[i]==max_ans)
            {
                int j;
                for (j=n-1;j>i;j--)
                {
                    printf("%d\n",j+1);
                }
                for (j=0;j<i;j++)
                {
                    printf("1\n");
                }
                return 0;
            }
        }
    }
    long long odd_sum=0;
    long long even_sum=0;
    for (i=0;i<n;i++)
    {
        if (a[i]<0) continue;
        if (i%2==0)
        {
            odd_sum+=a[i];
        }
        else
        {
            even_sum+=a[i];
        }
    }
    if (odd_sum>=even_sum)
    {
        cout<<odd_sum<<endl;
        //we choose odd!
        for (i=n-1;i>=0;i--)
        {
            if ((i%2==0)&&(a[i]<0))
            {
                ans.push_back(i+1);
                if (i==0)
                {
                    int j;
                    ans.push_back(1);
                    for (j=2;j<n;j++)
                    {
                        a[j-2]=a[j];
                    }
                    n--;
                    n--;
                    continue;
                }
                if (i==n-1)
                {
                    n--;
                    continue;
                }
                int j;
                for (j=i+1;j<n;j++)
                {
                    a[j-2]=a[j];
                }
                n-=2;
            }
        }
        for (i=n-1;i>=0;i--)
        {
            if (i%2==1)
            {
                ans.push_back(i+1);
            }
        }
    }
    else
    {
        cout<<even_sum<<endl;
        //we choose even!
        for (i=n-1;i>=0;i--)
        {
            if ((i%2==1)&&(a[i]<0))
            {
                ans.push_back(i+1);
                if (i==0)
                {
                    int j;
                    ans.push_back(1);
                    for (j=2;j<n;j++)
                    {
                        a[j-2]=a[j];
                    }
                    n--;
                    n--;
                    continue;
                }
                if (i==n-1)
                {
                    n--;
                    continue;
                }
                int j;
                for (j=i+1;j<n;j++)
                {
                    a[j-2]=a[j];
                }
                n-=2;
            }
        }
        for (i=n-1;i>=0;i--)
        {
            if (i%2==0)
            {
                ans.push_back(i+1);
            }
        }
    }
    printf("%d\n",ans.size());
    for (i=0;i<(int)ans.size();i++)
    {
        printf("%d\n",ans[i]);
    }
    return 0;
} 


Measured memory_bytes: 256