#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
 
class Car{
public:
  int id, in_time, rem_time;
  Car(){}
  Car(int a, int b, int c): id(a), in_time(b), rem_time(c){}
};
 
const int INF = (1<<28);
 
int m, n;
queue<Car> que;
Car pa[20];
vector<int> ans;
 
void init(){
  for(int i=0;i<m*2;i++) pa[i] = Car(-1, -1, -1);
  while(!que.empty()) que.pop();
  ans.clear();
}
 
bool is_full(){
  for(int i=0;i<m*2;i++) if(pa[i].id == -1) return false;
  return true;
}

void put_in(int t){
  while(!que.empty()){
    Car c = que.front();
    if(c.in_time > t || is_full()) break;
    int pos = -1;
    for(int i=1;i<m*2;i+=2){
      if(pos == -1 && pa[i].id == -1 && pa[i-1].id == -1) pos = i;
    }
    if(pos != -1){
      pa[pos] = c;
      que.pop();
      continue;
    }
    int valm = INF;
    pos = -1;
    for(int i=0;i<m*2;i+=2){
      if(pa[i].id != -1) continue;
      if(pa[i+1].rem_time >= c.rem_time){
        if(valm > abs(pa[i+1].rem_time - c.rem_time)){
          valm = abs(pa[i+1].rem_time - c.rem_time);
          pos = i;
        }
      }
    }
    if(pos != -1){
      pa[pos] = c;
      que.pop();
      continue;
    }
    valm = INF;
    pos = -1;
    for(int i=0;i<m*2;i+=2){
      if(pa[i].id != -1) continue;
      if(valm > abs(pa[i+1].rem_time - c.rem_time)){
        valm = abs(pa[i+1].rem_time - c.rem_time);
        pos = i;
      }
    }
    if(pos != -1){
      pa[pos+1].rem_time = c.rem_time;
      pa[pos] = c;
      que.pop();
      continue;
    }
  }
}

void put_out(int t){
  while(1){
    int valm = INF;
    int ex_pos = -1;
    for(int i=0;i<m*2;i++){
      if(pa[i].id == -1) continue;
      if(pa[i].rem_time > 0) continue;
      if(valm > pa[i].rem_time){
        valm = pa[i].rem_time;
        ex_pos = i;
      }
    }
    if(ex_pos == -1) break;
    ans.push_back(pa[ex_pos].id);
    pa[ex_pos] = Car(-1, -1, -1);
  }
}

bool is_empty(){
  for(int i=0;i<m*2;i++) if(pa[i].id != -1) return false;
  return true;
}

main(){
  while(cin >> m >> n && (m|n)){
    init();
    for(int i=0;i<n;i++){
      Car in = Car(i+1, i*10, 0);
      cin >> in.rem_time;
      que.push(in);
    }
    for(int t=0;;t+=1){
      if(t > 0 && is_empty()) break;
      for(int i=0;i<m*2;i++){
        if(pa[i].id == -1) continue;
        pa[i].rem_time -= 1;
      }
      put_out(t);
      put_in(t);
    }
    cout << ans[0];
    for(int i=1;i<ans.size();i++) cout << " " << ans[i];
    cout << endl;
  }
}