#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; constexpr ll mod = 998244353; const ll INF = mod * mod; typedef pairP; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) #define all(v) (v).begin(),(v).end() typedef pair LP; typedef double ld; typedef pair LDP; const ld eps = 1e-12; const ld pi = acos(-1.0); int dp[1001][2]; P pre[1001][2]; void solve() { int n; cin >> n; vector a(n); rep(i, n)cin >> a[i]; rep(i, n + 1) { rep(j, 2)dp[i][j] = -mod; } dp[0][0] = 0; rep(i, n) { if (dp[i][0] > dp[i + 1][0]) { dp[i + 1][0] = dp[i][0]; pre[i + 1][0] = { i,0 }; } if (dp[i][0] + a[i] > dp[i + 1][1]) { dp[i + 1][1] = dp[i][0] + a[i]; pre[i + 1][1] = { i,0 }; } if (dp[i][1] > dp[i + 1][0]) { dp[i + 1][0] = dp[i][1]; pre[i + 1][0] = { i,1 }; } } int ci = n, cj = 0; int ans = dp[n][0]; if (dp[n][0] < dp[n][1]) { ans = dp[n][1]; cj = 1; } vector ids; while (ci != 0) { if (cj) { ids.push_back(ci); } P p = pre[ci][cj]; ci = p.first, cj = p.second; } reverse(all(ids)); cout << ans << "\n"; rep(j, ids.size()) { if (j > 0)cout << " "; cout << ids[j]; } cout << "\n"; } signed main() { //ios::sync_with_stdio(false); //cin.tie(0); //cout << fixed << setprecision(10); //init_f(); //expr(); //int t; cin >> t; rep(i, t) solve(); return 0; }