#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum EVENT{
	OUT,
	IN,
};

struct Info{
	double length,out_time;
};

struct Data{
	Data(){
		time = 0.0;
		car_id = 0;
		event = OUT;
	}
	Data(double arg_time,int arg_car_id,EVENT arg_event){
		time = arg_time;
		car_id = arg_car_id;
		event = arg_event;
	}
	bool operator<(const struct Data &arg) const{
		return time > arg.time;
	}
	int car_id;
	double time;
	EVENT event;
};

struct PARK{
	int floor_1,floor_2;
};

struct LOC{
	int park_id,floor;
};

struct CAR_OUT{
	CAR_OUT(int arg_car_id,int arg_park_id,int arg_floor){
		park_id = arg_park_id;
		floor = arg_floor;
		car_id = arg_car_id;
	}
	bool operator<(const struct CAR_OUT &arg) const{
		if(park_id != arg.park_id){
			return park_id < arg.park_id;
		}else{
			return floor < arg.floor;
		}
	}
	int car_id,park_id,floor;
};

int M,N;
Info info[100];
PARK park[10];
LOC loc[100];
bool is_FULL;

void func(){

	for(int i = 0; i < M; i++){
		park[i].floor_1 = -1;
		park[i].floor_2 = -1;
	}

	for(int i = 0; i < N; i++)loc[i].park_id  = -1;

	priority_queue<Data> Q,OUT_Q;

	double tmp;
	for(int i = 0; i < N; i++){
		scanf("%lf",&tmp);
		info[i].length = tmp;
		Q.push(Data(10.0*i,i,IN));
	}

	Data current;
	bool FLG,is_First = true;

	int min_index;
	double minimum;

	is_FULL = false;

	vector<CAR_OUT> car_OUT;

	while(!Q.empty()){
		current = Q.top();
		Q.pop();

		if(current.event == IN){

			if(is_FULL){
				Q.push(Data(OUT_Q.top().time+EPS,current.car_id,IN));
				continue;
			}

			FLG = false;

			for(int i = 0; i < M; i++){
				if(park[i].floor_1 == -1){
					park[i].floor_1 = current.car_id;
					loc[current.car_id].park_id = i;
					loc[current.car_id].floor = 1;
					info[current.car_id].out_time = current.time + info[current.car_id].length-EPS;
					Q.push(Data(info[current.car_id].out_time,current.car_id,OUT));
					OUT_Q.push(Data(info[current.car_id].out_time,current.car_id,OUT));
					FLG = true;
					break;
				}
			}
			if(FLG)continue;

			minimum = DBL_MAX;
			for(int i = 0; i < M; i++){
				if(park[i].floor_2 != -1)continue;
				if(info[park[i].floor_1].out_time >= current.time+info[current.car_id].length){
					tmp = info[park[i].floor_1].out_time - (current.time+info[current.car_id].length);
					if(tmp < minimum){
						minimum = tmp;
						min_index = i;
					}
				}
			}

			if(minimum != DBL_MAX){
				park[min_index].floor_2 = park[min_index].floor_1;
				loc[park[min_index].floor_2].floor = 2;
				park[min_index].floor_1 = current.car_id;
				loc[current.car_id].park_id = min_index;
				loc[current.car_id].floor = 1;
				info[current.car_id].out_time = current.time + info[current.car_id].length-EPS;
				Q.push(Data(info[current.car_id].out_time,current.car_id,OUT));
				OUT_Q.push(Data(info[current.car_id].out_time,current.car_id,OUT));
				continue;
			}

			for(int i = 0; i < M; i++){
				if(park[i].floor_2 != -1)continue;
				if(info[park[i].floor_1].out_time < current.time+info[current.car_id].length){
					tmp = current.time+info[current.car_id].length - info[park[i].floor_1].out_time;
					if(tmp < minimum){
						minimum = tmp;
						min_index = i;
					}
				}
			}

			if(minimum != DBL_MAX){
				park[min_index].floor_2 = park[min_index].floor_1;
				loc[park[min_index].floor_2].floor = 2;
				park[min_index].floor_1 = current.car_id;
				loc[current.car_id].park_id = min_index;
				loc[current.car_id].floor = 1;
				info[current.car_id].out_time = current.time + info[current.car_id].length-EPS;
				Q.push(Data(info[current.car_id].out_time,current.car_id,OUT));
				OUT_Q.push(Data(info[current.car_id].out_time,current.car_id,OUT));
				continue;
			}

			is_FULL = true;
			Q.push(Data(OUT_Q.top().time+EPS,current.car_id,IN));

		}else{ //OUT

			OUT_Q.pop();

			if(loc[current.car_id].floor == 2 && info[park[loc[current.car_id].park_id].floor_1].out_time > info[current.car_id].out_time){
				Q.push(Data(info[park[loc[current.car_id].park_id].floor_1].out_time,current.car_id,OUT));
				OUT_Q.push(Data(info[park[loc[current.car_id].park_id].floor_1].out_time,current.car_id,OUT));
				continue;
			}

			car_OUT.push_back(CAR_OUT(current.car_id,loc[current.car_id].park_id,loc[current.car_id].floor));

			while(OUT_Q.empty() == false && fabs(current.time-OUT_Q.top().time) < EPS){
				car_OUT.push_back(CAR_OUT(OUT_Q.top().car_id,loc[OUT_Q.top().car_id].park_id,loc[OUT_Q.top().car_id].floor));
				OUT_Q.pop();
				Q.pop();
			}

			sort(car_OUT.begin(),car_OUT.end());

			for(int k = 0; k < car_OUT.size(); k++){
				if(is_First){
					printf("%d",car_OUT[k].car_id+1);
					is_First = false;
				}else{
					printf(" %d",car_OUT[k].car_id+1);
				}
				if(car_OUT[k].floor == 1){
					park[car_OUT[k].park_id].floor_1 = park[car_OUT[k].park_id].floor_2;
					loc[park[car_OUT[k].park_id].floor_1].floor = 1;
					park[car_OUT[k].park_id].floor_2 = -1;
				}else{
					park[car_OUT[k].park_id].floor_1 = -1;
				}
			}
			car_OUT.clear();
			is_FULL = false;
		}
	}
	printf("\n");
}

int main(){

	while(true){
		scanf("%d %d",&M,&N);
		if(M == 0 && N == 0)break;

		func();
	}

	return 0;
}