func_code_string: #include <bits/stdc++.h>   using namespace std;   void solve(int n, int m, vector<int> a) {     for (int i = int(0); i < int(m); i++) a[i] = min(a[i], n / 2);     int sum = accumulate((a).begin(), (a).end(), 0);     if (sum < n) {       cout << -1 << endl;       return;     }     vector<pair<int, int> > b(m);     for (int i = int(0); i < int(m); i++) b[i] = make_pair(a[i], i);     sort((b).begin(), (b).end(), greater<pair<int, int> >());     vector<int> res(n);     for (int i = int(0); i < int(n); i++) {       int j = -1;       if (i == 0)         j = 0;       else if (i == n - 1) {         for (int k = int(0); k < int(m); k++)           if (b[k].second != res[i - 1] && b[k].second != res[0] &&               (j == -1 || b[k].first > b[j].first))             j = k;       } else {         for (int k = int(0); k < int(m); k++)           if (b[k].second != res[i - 1] && (j == -1 || b[k].first > b[j].first))             j = k;       }       res[i] = b[j].second;       b[j].first--;     }     for (int i = int(0); i < int(n); i++)       cout << res[i] + 1 << (i == n - 1 ?   n  :    );   }   int main() {     for (int n, m; cin >> n >> m, n | m;) {       vector<int> a(m);       for (int i = int(0); i < int(m); i++) cin >> a[i];       solve(n, m, a);       break;     }     return 0;   }   