#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
  int m,n,t[100],i;
  int u[10],l[10];

  for(;;){
    cin >> m >> n;
    if(!m && !n)break;

    for(i=0;i<n;i++)cin >> t[i];
    for(i=0;i<m;i++){
      u[i] = 0;
      l[i] = 0;
    }

    int time = 0;
    queue<int> q,ans;

    do{
      /*
      cout << time << " " << ans.size() << endl;
      for(i=0;i<m;i++)cout << u[i] << " ";
      cout << endl;
      for(i=0;i<m;i++)cout << l[i] << " ";
      cout << endl;
      */
      //time pending
      for(i=0;i<m;i++){
	if(u[i] && t[u[i]-1])t[u[i]-1]--;
	if(l[i] && t[l[i]-1])t[l[i]-1]--;
      }
      //out
      for(i=0;i<m;i++){
	if(l[i] && !t[l[i]-1]){
	  ans.push(l[i]);
	  l[i] = 0;
	}
	if(!l[i] && u[i])swap(l[i],u[i]);
	if(l[i] && !t[l[i]-1]){
	  ans.push(l[i]);
	  l[i] = 0;
	}
      }
      //in
      if(!(time%10) && time<n*10)q.push(time/10+1);
      while(q.size()){
	int tmp = q.front();
	//cout << tmp << endl;
	for(i=0;i<m;i++)
	  if(!l[i])break;
	if(i<m){
	  l[i] = tmp;
	  q.pop();
	  continue;
	}
	int pos = -1;
	for(i=0;i<m;i++)
	  if(!u[i] && t[l[i]-1]>=t[tmp-1]){
	    if(pos<0)pos = i;
	    else if(t[l[pos]-1]>t[l[i]-1])pos = i;
	  }
	if(pos>=0){
	  u[pos] = l[pos];
	  l[pos] = tmp;
	  q.pop();
	  continue;
	}
	//cout << pos << endl;
	for(i=0;i<m;i++)
	  if(!u[i]){
	    if(pos<0)pos = i;
	    else if(t[l[pos]-1]<t[l[i]-1])pos = i;
	  }
	//cout << pos << endl;
	if(pos>=0){
	  u[pos] = l[pos];
	  l[pos] = tmp;
	  q.pop();
	  continue;
	}
	break;
      }
      time++;
    }while((int)ans.size()<n);

    while(ans.size()){
      cout << ans.front();
      ans.pop();
      if(ans.size())cout << " ";
    }
    cout << endl;
  }
}