#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, v, x, mx = 0, dig, a[11], ans[1000000], j, b[11], mn = 10e6;
  cin >> v;
  for (i = 1; i < 10; i++) {
    cin >> a[i];
    x = v / a[i];
    if (a[i] < mn) mn = a[i];
    b[i] = x;
    mx = max(mx, x);
  }
  if (!mx) {
    cout << "-1";
    return 0;
  }
  v -= (mx * mn);
  for (j = 0; j < mx; j++) {
    v += mn;
    for (i = 9; i >= 1; i--) {
      if (v - a[i] >= 0) {
        v -= a[i];
        ans[j] = i;
      }
    }
    cout << ans[j];
  }
  return 0;
}
