#include <bits/stdc++.h>
int digitCost[10];
int digits[10];
int digitCount[10] = {0};
int answer[10];
int v;
int partition(int start, int end) {
  int i, j, pivot, temp, pivotDigit;
  pivot = digitCost[digits[start]];
  pivotDigit = digits[start];
  i = start;
  for (j = start + 1; j <= end; j++) {
    if (digitCost[digits[j]] < pivot ||
        (digitCost[digits[j]] == pivot && digits[j] > pivotDigit)) {
      i++;
      temp = digits[i];
      digits[i] = digits[j];
      digits[j] = temp;
    }
  }
  temp = digits[start];
  digits[start] = digits[i];
  digits[i] = temp;
  return i;
}
void quickSortDigits(int start, int end) {
  int p;
  if (start < end) {
    p = partition(start, end);
    quickSortDigits(start, p - 1);
    quickSortDigits(p + 1, end);
  }
  return;
}
void paintNumber() {
  if (v < digitCost[digits[1]]) {
    printf("%d", -1);
    return;
  }
  int remPaint, difPaint;
  int i, j;
  answer[digits[1]] = v / digitCost[digits[1]];
  remPaint = v % digitCost[digits[1]];
  for (i = 9; i > digits[1]; i--) {
    difPaint = digitCost[i] - digitCost[digits[1]];
    if (remPaint >= difPaint) {
      answer[i] = remPaint / difPaint;
      answer[digits[1]] -= answer[i];
      remPaint %= difPaint;
    }
  }
  for (i = 9; i >= digits[1]; i--) {
    for (j = 0; j < answer[i]; j++) {
      printf("%d", i);
    }
  }
  return;
}
int main() {
  int i, j;
  scanf("%d", &v);
  for (i = 1; i < 10; i++) {
    scanf("%d", &digitCost[i]);
    digits[i] = i;
  }
  quickSortDigits(1, 9);
  paintNumber();
  return 0;
}
