#include <iostream>
#include <vector>
using namespace std;

int main()
{
	while ( true )
	{
		int m,n; cin>>m>>n;
		if ( m==0 && n==0 )
			break;
		vector<int> C(n);		//	Ô
		for ( int i=0; i<n; i++ )
			cin>>C[i];
		vector<int> U(m,-1);	//	ã
		vector<int> D(m,-1);	//	º
		vector<int> S;			//	ÔÒ¿
		vector<int> ans;		//	¦

		for ( int t=0; (int)ans.size()<n; t++ )
		{
			//	oÉ
			for ( int i=0; i<m; i++ )
			{
				if ( D[i]>=0 )
					if ( --C[D[i]]<=0 )
						ans.push_back(D[i]),
						D[i] = -1;
				if ( U[i]>=0 )
					if ( --C[U[i]]<=0 && D[i]==-1 )
						ans.push_back(U[i]),
						U[i] = -1;
			}

			//	üÉ
			if ( t%10==0 && t/10<n )
				S.push_back( t/10 );
			if ( S.size()>0 )
			{
				bool f = false;
				for ( int i=0; i<m && !f; i++ )
					if ( U[i]==-1 && D[i]==-1 )
						U[i] = S[0],
						f = true;
				if ( !f )
				{
					int mn=99999999;
					int mi;
					for ( int i=0; i<m; i++ )
						if ( D[i] == -1 )
						if ( C[U[i]] >= C[S[0]] )
							if ( C[U[i]]-C[S[0]] < mn )
								mn = C[U[i]]-C[S[0]],
								mi = i;
					if ( mn<99999999 )
						D[mi] = S[0],
						f = true;
				}
				if ( !f )
				{
					int mn=99999999;
					int mi;
					for ( int i=0; i<m; i++ )
						if ( D[i]==-1 )
							if ( C[S[0]]-C[U[i]] < mn )
								mn = C[S[0]]-C[U[i]],
								mi = i;
					if ( mn<99999999 )
						D[mi] = S[0],
						f = true;
				}

				if ( f )
					S.erase(S.begin());
			}
		}

		for ( int i=0; i<(int)ans.size(); i++ )
			cout << (i>0?" ":"") << ans[i]+1;
		cout << endl;
	}
	return 0;
}