#include <bits/stdc++.h>
using namespace std;
int main() {
  long long v;
  cin >> v;
  long long a[10], j;
  long long mini = INT_MAX;
  for (int i = 1; i < 10; i++) {
    cin >> a[i];
    if (a[i] <= mini) {
      mini = a[i];
      j = i;
    }
  }
  long long x = v / mini;
  if (x == 0) {
    cout << -1;
    return 0;
  }
  vector<long long> bb;
  for (int i = 0; i < x; i++) {
    bb.push_back(j);
  }
  x = v % mini;
  long long temp = x;
  long long y = bb.size();
  long long sexy = -1;
  long long k = 0, cnt = 0;
  for (int i = 9; i >= j + 1; i--) {
    if (a[j] + temp >= a[i] and temp > 0 and a[i] - a[j] != 0) {
      cnt += temp / (a[i] - a[j]);
      temp = temp - (temp / (a[i] - a[j])) * (a[i] - a[j]);
    }
    for (; k < cnt; k++) bb[k] = i;
  }
  for (int i = 0; i < bb.size(); i++) cout << bb[i];
  return 0;
}
