#include <bits/stdc++.h>
const int dx[4] = {0, 0, 0, 0};
using namespace std;
int a[10];
int main(int argc, char** argv) {
  int value, min, cnt;
  scanf("%d", &value);
  min = 100010;
  for (int i = 1; i <= 9; i++) {
    scanf("%d", &a[i]);
    if (min > a[i]) min = a[i];
  }
  if (value < min) {
    printf("-1\n");
    return 0;
  }
  cnt = value / min;
  for (int i = cnt - 1; i >= 0; i--) {
    for (int j = 9; j >= 1; j--) {
      if (value >= a[j] && (value - a[j]) / min >= i) {
        printf("%d", j);
        value -= a[j];
        break;
      }
    }
  }
  printf("\n");
  return 0;
}
