#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int V;
  cin >> V;
  long long int p[10], minm = INT_MAX;
  for (long long int i = 1; i <= 9; i++) {
    cin >> p[i];
    minm = min(minm, p[i]);
  }
  long long int n = V / minm;
  if (!n) {
    cout << -1 << endl;
    return 0;
  }
  V = V - n * minm;
  for (; n > 0; n--) {
    bool b = 1;
    long long int index = 0;
    for (long long int j = 9; j >= 1; j--) {
      long long int k = -minm;
      k += p[j];
      if (V >= k) {
        V = V - k;
        cout << j;
        b = 0;
        break;
      } else {
        index = max(index, j);
      }
    }
    if (b) {
      cout << index;
    }
  }
  cout << endl;
  return 0;
}
