#include <bits/stdc++.h>
using namespace std;
int main() {
  int v;
  int digits[9];
  cin >> v;
  cin >> digits[0];
  int min = digits[0];
  int d = 1;
  for (int i = 1; i < 9; ++i) {
    cin >> digits[i];
    if (digits[i] <= min) {
      min = digits[i];
      d = i + 1;
    }
  }
  int sz = v / min;
  if (sz == 0) {
    cout << "-1\n";
    return 0;
  }
  int* n = new int[sz];
  for (int i = 0; i < sz; ++i) n[i] = d;
  v -= sz * min;
  if (d < 9) {
    for (int i = 0; i < sz && v > 0; ++i)
      for (int j = 8; j > d - 1; j--)
        if (v + min >= digits[j]) {
          n[i] = j + 1;
          v += min - digits[j];
          break;
        }
  }
  for (int i = 0; i < sz; ++i) cout << n[i];
  cout << '\n';
  delete[] n;
  return 0;
}
