#define _USE_MATH_DEFINES #include #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// int dp[1001]; string str[1001]; int no[1000]; int num = 0; int show( string str){ for(int i=0;i>N; int V[1000]; rep(i,N){ cin>>V[i]; } dp[0] = V[0]; str[0] = "1"; if(N > 1){ dp[1] = V[1]; str[1] = "2"; } stringstream ss; for(int i=2;i<=N;++i){ if(i-2 >= 0){ if( dp[i] < dp[i-2] + V[i] ){ dp[i] = dp[i-2] + V[i]; ss.str(""); ss.clear(stringstream::goodbit); ss << " " << i+1; str[i] = str[i-2] + ss.str(); } } if(i-3 >= 0){ if( dp[i] < dp[i-3] + V[i] ){ dp[i] = dp[i-3] + V[i]; ss.str(""); ss.clear(stringstream::goodbit); ss << " " << i+1; str[i] = str[i-3] + ss.str(); } } } int ans = 0; if( dp[N] > dp[N-1] ){ ans = N; }else{ ans = N-1; } P(dp[ans]); show(str[ans] ); return 0; }