#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef pair < int , int > Pi;
#define fr first
#define sc second
const int INF = 1<<30;
vector< stack < Pi > > park;
queue< Pi > sreep;
vector< int > ans;
set< int > out_time;
int exit_F5;


void parking(const int& now){

  while(!sreep.empty()){
    const int id = sreep.front().fr, time = sreep.front().sc;
    int mpos = -1, pospos = -1;
    bool flag = false;

    for(int i = 0 ; i < park.size() ; i++ ){
      if(park[i].empty()){
        park[i].push(Pi( id, time));
        out_time.insert(time + now);
        sreep.pop();
        flag = true;
        break;
      }else if(park[i].size() == 1){
        if(park[i].top().sc >= time && ( mpos == -1 || park[i].top().sc < park[mpos].top().sc)){
          mpos = i;
        }
        if(pospos == -1 || park[i].top().sc > park[pospos].top().sc){
          pospos = i;
        }
      }
    }

    if(flag) continue;
    if(~mpos){
      park[mpos].push( Pi( id, time));
      out_time.insert(time + now);
      sreep.pop();
    }else if(~pospos){
      park[pospos].push( Pi( id, time));
      out_time.insert(time + now);
      sreep.pop();
    }else break;
  }
}

void next(const int& ntime){
  for(int i = 0 ; i < park.size() ; i++ ){
    if(park[i].empty()) continue;
    else if(park[i].size() == 2){
      Pi p = park[i].top();
      park[i].pop();
      park[i].top().sc -= ntime;
      p.sc -= ntime;
      park[i].push(p);
    }else{
      park[i].top().sc -= ntime;
    }
  }
}

void out(const int& in, const int& ot){

  set<int>::iterator ue = out_time.upper_bound(in), sita = out_time.upper_bound(ot);
  int pretime = in;

  //時刻をinに合わせる
  next( in - exit_F5);

  while(ue != sita){
    int nowtime = *ue;

    next(nowtime - pretime);

    for(int i = 0 ; i < park.size() ; i++ ){
      while(!park[i].empty()){
        if(park[i].top().sc <= 0){
          ans.push_back(park[i].top().fr);
          park[i].pop();
          parking(nowtime);
        } else break;
      }
    }
    pretime = nowtime;
    ue++;
  }

  next( ot - pretime);
  exit_F5 = ot;
}

int main(){
  int m, n;

  while( cin >> m >> n , m){
    exit_F5 = 0; //最終更新
    park.resize( m, stack< Pi >());
    for(int i = 0 ; i < n ; i++ ){
      int t;
      cin >> t;
      sreep.push(Pi( i + 1, t));
      parking(i * 10);
      out(i * 10 , (i + 1) * 10);
    }

    out(n * 10 , INF);
    for(int i = 0 ; i < ans.size() ; i++ ){
      cout << (i ? " ": "") << ans[i];
    }
    cout << endl;

    ans.clear();
    out_time.clear();
  }
}