#include "partition.h"

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi2,popcnt,lzcnt")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

std::vector<int> solve(std::vector<int> A) {
  int n = A.size();
  vector <int> f, s;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += A[i];
  }
  if (n % 2 == 1) {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) f.push_back(i);
      else s.push_back(i);
    }
  } else {
    ll cur = 0;
    for (int i = 0; i < n; i += 2) {
      cur += A[i];
    }
    int i = n - (sum - cur * 2 + 1) / 2 * 2;
    for (int j = 0; j < n; j++) {
      if (j % 2 == (j >= i)) {
        f.push_back(j);
      } else {
        s.push_back(j);
      }
    }
  }
  vector <int> ans;
  for (int i : f) {
    ans.push_back(i);
  }
  for (int i : s) {
    ans.push_back(i);
  }
  return ans;
}
