#include <bits/stdc++.h>
using namespace std;
void swapping(long int *a, long int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}
void sorting(long int a[2][9], long int b) {
  for (int i = 0; i < b - 1; i++)
    for (int j = 0; j < b - i - 1; j++)
      if (a[1][j] > a[1][j + 1] ||
          (a[1][j] == a[1][j + 1] && a[0][j] < a[0][j + 1])) {
        swapping(&a[1][j], &a[1][j + 1]);
        swapping(&a[0][j], &a[0][j + 1]);
      }
}
void cleanup(long int a[2][9], long int result[2][9], int b) {
  int counter = 1;
  result[0][0] = a[0][0];
  result[1][0] = a[1][0];
  for (int i = 1; i < 9; i++) {
    if (a[1][i] != a[1][i - 1]) {
      result[0][counter] = a[0][i];
      result[1][counter] = a[1][i];
      counter++;
    }
  }
}
int main() {
  long int input[2][9] = {{1, 2, 3, 4, 5, 6, 7, 8, 9}, {0}}, v,
           liter[2][9] = {0}, red = 0;
  cin >> v;
  for (int i = 0; i < 9; i++) cin >> input[1][i];
  sorting(input, 9);
  cleanup(input, liter, 9);
  int counter = 1;
  long int maxi = liter[0][0];
  long int maxa = liter[1][0];
  long int k = 0, total = (v / liter[1][0]);
  if (liter[1][0] <= v) {
    red = v % liter[1][0];
    while (red >= 0 && k < total) {
      k++;
      maxi = liter[0][0];
      while (red + liter[1][0] >= liter[1][counter] && counter < 9) {
        if (liter[0][counter] > maxi) {
          maxa = liter[1][counter];
          maxi = liter[0][counter];
        }
        counter++;
      }
      red = red + liter[1][0] - maxa;
      if (red < 0) red = 0;
      counter = 0;
      cout << maxi;
    }
  } else
    cout << -1 << endl;
  return 0;
}
