#include <bits/stdc++.h>
using namespace std;
int v, t[9];
int main() {
  cin >> v;
  for (int i = (int)(0); i < (int)(9); ++i) cin >> t[i];
  int j = 0;
  for (int i = (int)(0); i < (int)(9); ++i)
    if (t[i] < t[j]) j = i;
  int nb = v / t[j];
  if (!nb) {
    cout << "-1";
    return 0;
  }
  while (nb) {
    for (int i = (int)(9); i > (int)(0); --i) {
      while (t[i - 1] <= v && (v - t[i - 1]) / t[j] == nb - 1) {
        cout << i;
        v -= t[i - 1];
        --nb;
      }
    }
  }
  return 0;
}
