#include "partition.h"
#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;
  f.reserve(n/2);
  s.reserve(n/2);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  if (n % 2 == 1) {
    for (int i = 0; i < n; i += 2) {
      int x = i;
      int y = i+1;
      if (i == n-1) {
        f.push_back(i);
        break;
      }
      if (a[i] > a[i+1]) swap(x, y);
      f.push_back(x);
      s.push_back(y);
    }
  } else {
    ll cur = 0;
    for (int i = 0; i < n; i += 2) {
      cur += min(a[i], a[i+1]);
    }
    int i = (int)a.size() - 2;
    while (cur * 2 < sum) {
      cur += abs(a[i+1] - a[i]);
      i -= 2;
    }
    i += 2;
    for (int j = 0; j < (int)a.size(); j++) {
      if (j % 2 == (j >= i)) {
        f.push_back(j);
      } else {
        s.push_back(j);
      }
    }
  }
  vector <int> ans;
  ans.reserve(n);
  for (int i : f) {
    ans.push_back(i);
  }
  for (int i : s) {
    ans.push_back(i);
  }
  return ans;
}
