#include <bits/stdc++.h>
using namespace std;
int main() {
  int v;
  int a[50];
  while (~scanf("%d", &v)) {
    int minn = 1000000;
    for (int i = 1; i <= 9; i++) {
      scanf("%d", &a[i]);
      if (a[i] < minn) minn = a[i];
    }
    if (v < minn) {
      printf("-1\n");
    }
    int r = v / minn - 1;
    for (int i = r; i >= 0; i--) {
      for (int j = 9; j > 0; j--) {
        if (v >= a[j] && (v - a[j]) / minn >= i) {
          printf("%d", j);
          v -= a[j];
          break;
        }
      }
    }
    cout << endl;
  }
  return 0;
}
