#include <bits/stdc++.h>
using namespace std;
vector<int> bees;
vector<int> aes;
vector<int> cees;
int n, m, a;
bool recurse(int depth, int whichone) {
  if (depth == n - 1) {
    bees[n - 1] = whichone + 1;
    return bees[0] != bees[n - 1];
  }
  bees[depth] = whichone + 1;
  aes[whichone]--;
  for (int i = 0; i < m; i++) {
    if (bees[depth] != i + 1)
      if (aes[i] > 0)
        if (recurse(depth + 1, i)) return true;
  }
  aes[whichone]++;
  return false;
}
void alternate_method() {
  int c = 0, j = 1, too_many_iterations = 100;
  bees[0] = 1;
  aes[0]--;
  do {
    for (int i = 1; i < n; i++) {
      if (bees[i] == 0 || bees[i] == bees[i - 1]) {
        for (int d = 1; d < m; d++) {
          if (aes[(bees[i - 1] + d - 1) % m] > 0) {
            if (i == n - 1 && (bees[i - 1] + d - 1) % m + 1 == 1) continue;
            if (bees[i] != 0) aes[bees[i] - 1]++;
            bees[i] = (bees[i - 1] + d - 1) % m + 1;
            aes[(bees[i - 1] + d - 1) % m]--;
            break;
          }
        }
        c = 0;
      } else {
        c++;
      }
    }
    for (int i = 0; i < n; i++) {
    }
    for (int i = 0; i < m; i++) {
    }
  } while (c <= n - 1 && j++ < too_many_iterations);
  if (j < too_many_iterations) {
    for (int i = 0; i < n; i++) {
      cout << cees[bees[i] - 1] + 1 << ' ';
    }
  } else {
    cout << -1;
  }
  return;
}
bool stupid_function(int i, int j) { return i > j; }
bool stupid_function2(int i, int j) { return aes[i] > aes[j]; }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &a);
    aes.push_back(a);
    cees.push_back(i);
  }
  sort(cees.begin(), cees.end(), stupid_function2);
  sort(aes.begin(), aes.end(), stupid_function);
  for (int i = 0; i < n; i++) {
    bees.push_back(0);
  }
  if (pow((double)n, (double)m) > 12000000 && n > 800) {
    alternate_method();
  } else {
    if (recurse(0, 0)) {
      for (int i = 0; i < n; i++) {
        cout << cees[bees[i] - 1] + 1 << ' ';
      }
      cout << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
