#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

const int INF = 1 << 30;

int main()
{
  int n, m;
  while (cin >> m >> n) {
    if ((n|m) == 0)
      break;

    vector<int> cars(n);
    for (int i = 0; i < n; ++i)
      cin >> cars[i];

    int time = 0;
    vector<int> ans;
    vector<pair<int, int> > p1(m, make_pair(-1, INF)), p2(m, make_pair(-1, INF));
    for (int i = 0; i < n; ++i) {
      time = max(time, i*10);

      for ( ; ; ) {
	// out
	bool down = false;
	for (int j = 0; j < m; ++j) {
	  if (p1[j].first != -1 && p1[j].second <= time) {
	    ans.push_back(p1[j].first);
	    p1[j].first = -1;
	    p1[j].second = INF;
	    down = true;
	  }

	  if (p2[j].first != -1 && p2[j].second <= time && p1[j].first == -1) {
	    ans.push_back(p2[j].first);
	    p2[j].first = -1;
	    p2[j].second = INF;
	  }

	  if (down && p2[j].first != -1) {
	    swap(p1[j].first, p2[j].first);
	    swap(p1[j].second, p2[j].second);
	  }
	}

	// in-empty
	bool empty = false;
	for (int j = 0; j < m; ++j) {
	  if (p1[j].first == -1) {
	    p1[j].first = i;
	    p1[j].second = time + cars[i];
	    empty = true;
	    break;
	  }
	}
	if (empty)
	  break;

	// up.1
	int minIndex = -1;
	for (int j = 0; j < m; ++j) {
	  if (p2[j].first == -1) {
	    if (p1[j].second >= time+cars[i]) {
	      if (minIndex == -1)
		minIndex = j;
	      else if (p1[j].second-time-cars[i] < p1[minIndex].second-time-cars[i])
		minIndex = j;
	    }
	  }
	}

	if (minIndex != -1) {
	  p2[minIndex].first = p1[minIndex].first;
	  p2[minIndex].second = p1[minIndex].second;
	  p1[minIndex].first = i;
	  p1[minIndex].second = time + cars[i];
	  break;
	}

	// up.2
	for (int j = 0; j < m; ++j) {
	  if (p2[j].first == -1) {
	    if (p1[j].second < time+cars[i]) {
	      if (minIndex == -1)
		minIndex = j;
	      else if (time+cars[i]-p1[j].second < time+cars[i]-p1[minIndex].second)
		minIndex = j;
	    }
	  }
	}

	if (minIndex != -1) {
	  p2[minIndex].first = p1[minIndex].first;
	  p2[minIndex].second = p1[minIndex].second;
	  p1[minIndex].first = i;
	  p1[minIndex].second = time + cars[i];
	  break;
	}

	int min_time = INF;
	for (int j = 0; j < m; ++j) {
	  if (p1[j].first == -1)
	    min_time = min(min_time, p2[j].second);
	  min_time = min(min_time, p1[j].second);
	}
	time = min_time;
      }
    }

    // all out
    while (ans.size() < n) {
      // out
      for (int j = 0; j < m; ++j) {
	if (p1[j].first != -1 && p1[j].second <= time) {
	  ans.push_back(p1[j].first);
	  p1[j].first = -1;
	  p1[j].second = INF;
	}
	
	if (p2[j].first != -1 && p2[j].second <= time && p1[j].first == -1) {
	  ans.push_back(p2[j].first);
	  p2[j].first = -1;
	  p2[j].second = INF;
	}
      }
       
      int min_time = INF;
      for (int j = 0; j < m; ++j) {
	if (p1[j].first == -1)
	  min_time = min(min_time, p2[j].second);
	min_time = min(min_time, p1[j].second);
      }
      time = min_time;
    }

    for (int i = 0; i < n-1; ++i)
      cout << ans[i]+1 << " ";
    cout << ans.back()+1 << endl;

  }
  return 0;
}