/**
 *    author:  tourist
 *    created: 20.06.2020 16:45:06       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  {
    int mn = *min_element(a.begin(), a.end());
    int mx = *max_element(a.begin(), a.end());
    if (2 * mn < mx) {
      cout << -1 << '\n';
      return 0;
    }
  }
  vector<int> b(n);
  auto Can = [&]() {
//    debug(a, b);
    vector<int> c(n);
    int mn = 787788;
    int mx = -787788;
    for (int i = 0; i < n; i++) {
      if (b[i] == 0) {
        c[i] = -1;
        mn = min(mn, a[i] - 1);
        mx = max(mx, a[i] - 2);
      } else {
        c[i] = a[i] - b[i];
        mn = min(mn, c[i]);
        mx = max(mx, c[i]);
      }
    }
    if (mn < 0 || mx < 0 || 2 * mn < mx) {
      return false;
    }
    return true;
  };
  auto One = [&]() {
    if (*max_element(a.begin(), a.end()) == 0) {
      return vector<int>();
    }
    int pos = 0;
    while (true) {
      for (int i = pos; i < n; i++) {
        b[i] = 1;
      }
      if (Can()) {
        break;
      }
      for (int i = pos; i < n; i++) {
        b[i] = 0;
      }
      bool found = false;
      for (int i = pos; i < n; i++) {
        b[i] = 2;
        if (Can()) {
          pos = i + 1;
          found = true;
          break;
        }
        b[i] = 1;
      }
      assert(found);
    }
    vector<int> ter;
    for (int x : {2, 1, 2}) {
      for (int i = 0; i < n; i++) {
        if (b[i] == x) {
          ter.push_back(i);
        }
      }
    }
    return ter;
  };
  vector<int> ret;
  while (*max_element(a.begin(), a.end()) > 0) {
    bool done = false;
    vector<int> best;
    int bcut = -1;
    for (int cut = 1; cut < n; cut++) {
      for (int i = 0; i < cut; i++) {
        b[i] = 2;
      }
      for (int i = cut; i < n; i++) {
        b[i] = 1;
      }
      if (Can()) {
        auto bb = b;
        for (int i = 0; i < n; i++) {
          a[i] -= bb[i];
        }
        auto help = One();
        for (int i = 0; i < n; i++) {
          a[i] += bb[i];
        }
        vector<int> cur;
        for (int i = 0; i < n; i++) {
          cur.push_back(i);
        }
        for (int i = 0; i < cut; i++) {
          cur.push_back(i);
        }
        for (int x : help) {
          cur.push_back(x);
        }
        debug(cut, cur);
        if (best.empty() || cur < best) {
          best = cur;
          bcut = cut;
        }
      }
    }
    if (bcut != -1) {
      for (int i = 0; i < bcut; i++) {
        b[i] = 2;
      }
      for (int i = bcut; i < n; i++) {
        b[i] = 1;
      }
      done = true;
    }
    if (!done) {
      fill(b.begin(), b.end(), 0);
      int pos = 0;
      while (true) {
        for (int i = pos; i < n; i++) {
          b[i] = 1;
        }
        if (Can()) {
          break;
        }
        for (int i = pos; i < n; i++) {
          b[i] = 0;
        }
        bool found = false;
        for (int i = pos; i < n; i++) {
          b[i] = 2;
          if (Can()) {
            pos = i + 1;
            found = true;
            break;
          }
          b[i] = 1;
        }
        assert(found);
      }
    }
    for (int i = 0; i < n; i++) {
      a[i] -= b[i];
    }
    for (int x : {2, 1, 2}) {
      for (int i = 0; i < n; i++) {
        if (b[i] == x) {
          ret.push_back(i);
        }
      }
    }
  }
  int sz = (int) ret.size();
  vector<int> was(n, 0);
  bool changed = true;
  while (changed) {
    changed = false;
    for (int i = 0; i < sz - 1; i++) {
      if (ret[i] > ret[i + 1]) {
        swap(ret[i], ret[i + 1]);
        for (int j = 0; j < n; j++) {
          was[j] = 0;
        }
        bool ok = true;
        int R = -1;
        for (int j = 0; j < n; j++) {
          if (was[ret[j]] == 1) {
            ok = false;
            break;
          }
          was[ret[j]] = 1;
        }
        int zeros = 0;
        if (ok) {
          R = n - 1;
          for (int j = n; j < sz; j++) {
            --was[ret[j - n]];
            if (was[ret[j - n]] == 0) {
              ++zeros;
            }
            if (was[ret[j]] == 0) {
              --zeros;
            }
            ++was[ret[j]];
            if (zeros == 0) {
              int nL = j - n + 1;
              int nR = j;
              if (nL > R + 1) {
                ok = false;
                break;
              }
              R = nR;
            }
          }
          if (R < sz - 1) {
            ok = false;
          }
        }
        if (ok) {
          changed = true;
        } else {
          swap(ret[i], ret[i + 1]);
        }
      }
    }
  }
  for (int i = 0; i < (int) ret.size(); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << ret[i] + 1;
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3676