# Polygon

### $mn[i][i+j]=min(mx[i][k]mn[k+1][i+j],mx[i][k]mn[k+1][i+j],mn[i][k]*mx[k+1][i+j]);$

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

#define MX 102
#define PLU 1
#define MUL 2

using namespace std;

int num[MX],cal[MX],n;
int mn[MX][MX],mx[MX][MX];

void input()
{
char ch;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
ch=getchar();
while(ch==' '||ch=='\n'||ch=='\r')ch=getchar();
if(ch=='t')cal[i]=PLU;
else if(ch=='x') cal[i]=MUL;
scanf("%d",&num[i]);
num[i+n]=num[i];
cal[i+n]=cal[i];
}
}

int main()
{
input();
for(int i=1;i<=n*2;i++)for(int j=1;j<=n*2;j++)mx[i][j]=-327699,mn[i][j]=327689;
for(int i=1;i<=n*2;i++)mx[i][i]=mn[i][i]=num[i];
for(int j=1;j<=n;j++)
{
for(int i=1;i+j<=n*2;i++)
{
for(int k=i;k<=i+j-1;k++)
{
if(cal[k+1]==PLU)
{
mx[i][i+j]=max(mx[i][i+j],mx[i][k]+mx[k+1][i+j]);
mn[i][i+j]=min(mn[i][i+j],mn[i][k]+mn[k+1][i+j]);
}
else
{
mx[i][i+j]=max(mx[i][i+j],mx[i][k]*mx[k+1][i+j]);
mx[i][i+j]=max(mx[i][i+j],mn[i][k]*mn[k+1][i+j]);
mn[i][i+j]=min(mn[i][i+j],mn[i][k]*mx[k+1][i+j]);
mn[i][i+j]=min(mn[i][i+j],mx[i][k]*mn[k+1][i+j]);
mn[i][i+j]=min(mn[i][i+j],mx[i][k]*mn[k+1][i+j]);
}
}
}
}
int p=-3838383,mxpos[MX],pnum=0;
for(int i=1;i<=n;i++)
{
if(mx[i][i+n-1]==p)mxpos[++pnum]=i;
else if(mx[i][i+n-1]>p)p=mx[i][i+n-1],pnum=1,mxpos[pnum]=i;
}
printf("%d\n",p);
for(int i=1;i<=pnum;i++)printf("%d ",mxpos[i]);
return 0;
}