#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

template<typename T>
struct DP2
{
	const int N1, N2;
	vector<T> data;
	DP2(int N1, int N2, const T& t = T())
		: N1(N1), N2(N2), data(N1*N2, t) { assert(data.size()*sizeof(T)<(1<<28)); }
	T& operator()(int i1, int i2)
		{ return data[ (i1*N2)+i2 ]; }
	void swap(DP2& rhs)
		{ data.swap(rhs.data); }
};

class FoxesOfTheRoundTable { public:
	vector <int> minimalDifference(vector <int> h)
	{
		const int N = h.size();
		vector<int> idx(N);
		for(int i=0; i<idx.size(); ++i) idx[i] = i;

		sort(idx.begin(), idx.end(), [&](int a, int b) {
			return h[a] < h[b];
		});

		vector<int> aa(1, 0), bb(1, 0);
		for(int k=1; k<N-1; ++k)
			(aa.back()<bb.back() ? aa : bb).push_back(k);
		vector<int> ans;
		for(auto a: aa)
			ans.push_back(idx[a]);
		bb.push_back(N-1);
		reverse(bb.begin(), bb.end());
		bb.pop_back();
		for(auto b: bb)
			ans.push_back(idx[b]);

		return ans;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <int>& Expected, const vector <int>& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, FoxesOfTheRoundTable().minimalDifference(h));}
int main(){

CASE(0)
	int h_[] = {1,99,50,50};
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = {0, 3, 1, 2 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	int h_[] = {123,456,789};
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = {0, 1, 2 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(2)
	int h_[] = {10,30,40,50,60};
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = {0, 1, 4, 3, 2 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	int h_[] = {1,2,3,4,8,12,13,14 };
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = {0, 1, 2, 3, 5, 6, 7, 4 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(4)
	int h_[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 };
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
/*
CASE(5)
	int h_[] = ;
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = ;
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(6)
	int h_[] = ;
	  vector <int> h(h_, h_+sizeof(h_)/sizeof(*h_)); 
	int __[] = ;
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
*/
}
// END CUT HERE
