#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

struct E{
	int t,floor,carid,spcid;
	E(int t,int floor,int carid,int spcid):
	t(t),floor(floor),carid(carid),spcid(spcid){};
	bool operator<(const E &r)const
	{
		if(t!=r.t)return t>r.t;
		return floor>r.floor;
	}
};
int m,n,t[100];
int spc[10][2],outtime[10][2];

pi find(int t,int ptime)
{
	rep(i,m)if(!spc[i][0]&&!spc[i][1])return mp(i,1);
	
	int mn=inf,mni;
	rep(i,m)if(!spc[i][0])
	{
		int d=outtime[i][1]-t-ptime;
		if(d>=0&&mn>d)mn=d,mni=i;
	}
	if(mn!=inf)return mp(mni,0);
	
	rep(i,m)if(!spc[i][0])
	{
		int d=abs(outtime[i][1]-t-ptime);
		if(mn>d)mn=d,mni=i;
	}
	assert(mn!=inf);
	return mp(mni,0);
}
int main()
{
	while(scanf("%d%d",&m,&n),m)
	{
		rep(i,n)scanf("%d",t+i);
		rep(i,m)rep(j,2)spc[i][j]=0;
		
		int ans[100],na=0,parking=0,curtime=0;
		
		priority_queue<E> Qout;
		queue<pair<int,pi> > Qin;
		rep(i,n)Qin.push(mp(10*i,mp(i+1,t[i])));
		
		while(!Qout.empty()||!Qin.empty())
		{
			if(!Qin.empty()&&(Qout.empty()||Qout.top().t>Qin.front().first
				&&parking<2*m))
			{
				int t=Qin.front().first,carid=Qin.front().second.first,
				ptime=Qin.front().second.second; Qin.pop();
				
				curtime=t=max(curtime,t);
				pi p=find(t,ptime);
				spc[p.first][p.second]=carid; parking++;
				outtime[p.first][p.second]=t+ptime;
				
				Qout.push(E(t+ptime,p.second,carid,p.first));
				continue;
			}
			
			E e=Qout.top(); Qout.pop();
			curtime=e.t;
			if(e.floor==0)
			{
				spc[e.spcid][0]=0; parking--;
				ans[na++]=e.carid; continue;
			}
			if(spc[e.spcid][0])
			{
				e.t=outtime[e.spcid][0];
				Qout.push(e); continue;
			}
			spc[e.spcid][1]=0; parking--;
			ans[na++]=e.carid; continue;
			
		}
		rep(i,n)printf("%d%c",ans[i],i==n-1?'\n':' ');
	}
	return 0;
}