vector<int> solve(vector<int> a) {
    int n = a.size();

    if (n == 1)
        return {0};

    long double sum = 0;
    for (int &val : a)
        sum += val;

    sum /= 2.0;

    vector<int> ans;

    if (n % 2 == 0 && (n / 2) % 2 == 0) {
        for (int i = 0; i < n / 2; i++) {
            ans.push_back(i);
            ans.push_back(n - i - 1);
        }
    }

    else {
        int l = 0, r = n - 1, turn = 0;
        long long s = 0;
        while (s < sum) {
            if (!turn) {
                s += a[r];
                ans.push_back(r);
                r--;
            }

            else {
               s += a[l];
               ans.push_back(l);
               l++;
            }

            turn ^= 1;
        }

        for (int i = l; i <= r; i++)
            ans.push_back(i);
    }
    return ans;
}