#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int v[10];
  int mn = INT_MAX, val;
  for (int i = 1; i < 10; i++) {
    scanf("%d", &v[i]);
    if (v[i] <= mn) {
      mn = v[i];
      val = i;
    }
  }
  int mx = n / v[val];
  if (mx == 0) {
    printf("-1");
    return 0;
  }
  int a[mx];
  for (int i = 0; i < mx; i++) a[i] = val;
  int left = n % v[val];
  for (int i = 0; i < mx; i++) {
    for (int j = 9; j > val; j--) {
      if (v[j] <= v[val] + left) {
        left = v[val] + left - v[j];
        a[i] = j;
        break;
      }
    }
  }
  for (int i = 0; i < mx; i++) printf("%d", a[i]);
  return 0;
}
