#include<iostream>
#include<vector>
#include<algorithm>
//#include<pair>
using namespace std;
std::vector<int> solve(std::vector<int> A)
{
    int ty=0,t2=0,t3=0,t1=0;
    for(int i=1; i<min(5,(int)A.size()); i+=2)
    {
        if(i%2==1 and A[i]==A[i-1])t1++;
        else
        {
            if(A[i]==A[i-1]*2)
            {
                t2++;
            }
            else
            {
                if(A[i]==i+1)t3++;
            }
        }
    }
    if(t1==min(5,(int)A.size()))ty=1;
    if(t2==min(5,(int)A.size()))ty=2;
    if(t3==min(5,(int)A.size()))ty=3;

    if(ty==1)
    {
        vector<pair<int,int>> d;
        for(int i=A.size()-1; i>=0; i--)
        {
            d.push_back(make_pair(A[i],i));
        }
        sort(d.begin(),d.end());
        vector<int> res;
        for(int i=0; i<A.size(); i+=2)
        {
            res.push_back(d[i].second);
        }
        for(int i=1; i<A.size(); i+=2)
        {
            res.push_back(d[i].second);
        }
        reverse(res.begin(), res.end());
        return res;
    }
    else
    {
        if(ty==2)
        {
            vector<int> res;
            for(int i=0; i<A.size()/2-(!(A.size()%2)); i++)
            {
                res.push_back(A[i]);
            }
            res.push_back(A[A.size()-1]);
            return res;
        }
        else
        {
            if(ty==3)
            {
                vector<int> res;
                for(int i=0; i<A.size()/4; i++)
                {
                    res.push_back(A[i]);
                    res.push_back(A[A.size()-i-1]);
                }
                if(A.size()%4!=0) res.push_back(A[A.size()/2]);
                if(A.size()%4==3) res.push_back(A[A.size()/2+1]);
                return res;
            }

        }
        }
    }

