#include <bits/stdc++.h>
using namespace std;
int main() {
  int counter[10] = {}, paint[10] = {100001};
  int v;
  int min_num = 0;
  cin >> v;
  for (int i = 1; i < 10; i++) {
    cin >> paint[i];
    if (paint[i] <= paint[min_num]) min_num = i;
  }
  counter[min_num] = v / paint[min_num];
  v -= counter[min_num] * paint[min_num];
  int curr_number = 9;
  while (v > 0 && min_num < 9 && counter[min_num] > 0 &&
         curr_number > min_num) {
    if (v + paint[min_num] - (paint[curr_number]) >= 0) {
      counter[curr_number]++;
      counter[min_num]--;
      v -= (paint[curr_number] - paint[min_num]);
    } else
      curr_number--;
  }
  bool allempt = true;
  for (int i = 9; i > 0; i--) {
    if (counter[i] > 0) allempt = 0;
    cout << string(counter[i], '0' + i);
  }
  if (allempt) cout << "-1";
}
