#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct State{
	int t,id;
	int io; // 0:駐車, 1:出庫
	int len; // 駐車の時:駐車時間, 出庫の時:駐車スペース
	State(){}
	State(int t,int id,int io,int len):t(t),id(id),io(io),len(len){}
	bool operator<(const State& s)const{
		if(t!=s.t) return t<s.t;
		if(io!=s.io) return io>s.io;
		if(io==0) return id<s.id;
		if(io==1) return len!=s.len?len<s.len:id>s.id;
		return false;
	}
	bool operator>(const State& s)const{
		if(t!=s.t) return t>s.t;
		if(io!=s.io) return io<s.io;
		if(io==0) return id>s.id;
		if(io==1) return len!=s.len?len>s.len:id<s.id;
		return false;
	}
};

int main()
{
	for(int m,n;cin>>m>>n,m|n;){
		priority_queue<State,vector<State>,greater<State>> pq;
		rep(i,n){
			int t; cin>>t;
			pq.push(State(i*10,i,0,t));
		}
		vvi pid(2,vi(m,-1)),out(2,vi(m,-1)); // [0][i]:下段, [1][i]:上段
		vi res;
		while(pq.size()){
			State cur=pq.top(); pq.pop();
			
			if(cur.io==0){ // 駐車
				rep(i,m) if(pid[0][i]==-1 && pid[1][i]==-1){
					pid[0][i]=cur.id;
					out[0][i]=cur.t+cur.len;
					pq.emplace(cur.t+cur.len,cur.id,1,i);
					goto end;
				}
				int j=-1;
				rep(i,m) if(pid[1][i]==-1 && out[0][i]>=cur.t+cur.len){
					if(j==-1 || out[0][j]>out[0][i])
						j=i;
				}
				if(j!=-1){
					pid[1][j]=pid[0][j];
					out[1][j]=out[0][j];
					pid[0][j]=cur.id;
					out[0][j]=cur.t+cur.len;
					pq.emplace(cur.t+cur.len,cur.id,1,j);
					goto end;
				}
				rep(i,m) if(pid[1][i]==-1){
					if(j==-1 || out[0][j]<out[0][i])
						j=i;
				}
				if(j!=-1){
					pid[1][j]=pid[0][j];
					out[1][j]=out[0][j];
					pid[0][j]=cur.id;
					out[0][j]=cur.t+cur.len;
					pq.emplace(cur.t+cur.len,cur.id,1,j);
					goto end;
				}
				pq.emplace(cur.t+1,cur.id,0,cur.len);
			}
			if(cur.io==1){ // 出庫
				rep(i,2) rep(j,m) if(pid[i][j]==cur.id){
					if(i==0){
						pid[0][j]=pid[1][j];
						out[0][j]=out[1][j];
						pid[1][j]=out[1][j]=-1;
						res.push_back(cur.id);
						goto end;
					}
					if(i==1){
						pq.emplace(cur.t+1,cur.id,1,cur.len);
						goto end;
					}
				}
			}
			end:;
		}
		rep(i,res.size())
			cout<<res[i]+1<<(i==res.size()-1?'\n':' ');
	}
	
	return 0;
}