#include <bits/stdc++.h>
using namespace std;
int main() {
  int v, a[10], minn = 99999999, im, mod, s;
  cin >> v;
  for (int i = 1; i <= 9; ++i) {
    cin >> a[i];
    if (minn >= a[i]) {
      minn = a[i];
      im = i;
    }
  }
  mod = v % minn;
  s = v / minn;
  if (!s) {
    cout << "-1";
    return 0;
  }
  for (int i = 9;;) {
    if (!s || i <= im) break;
    if (mod + a[im] >= a[i]) {
      cout << i;
      --s;
      mod = mod + a[im] - a[i];
    } else
      --i;
  }
  while (s--) cout << im;
}
