#include <bits/stdc++.h>
using namespace std;
void hi() {
  static long long i = 0;
  cout << "Check Point : " << ++i << "\n";
  return;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<pair<long long, long long>> v(9);
    for (long long i = 0; i < 9; i++) {
      v[i].first = i + 1;
      cin >> v[i].second;
    }
    bool all_smaller = true;
    for (auto x : v) {
      if (n >= x.second) {
        all_smaller = false;
        break;
      }
    }
    if (all_smaller) {
      cout << -1 << "\n";
      return 0;
    }
    long long mini = 1000000007;
    long long index = -1;
    for (long long i = 0; i < 9; i++) {
      if (mini >= v[i].second) {
        mini = v[i].second;
        index = i;
      }
    }
    long long count = n / mini;
    if (count * mini == n) {
      for (long long i = 1; i <= count; i++) {
        cout << index + 1;
      }
      cout << " "
           << "\n";
    } else {
      vector<long long> digit;
      for (long long i = 1; i <= count; i++) {
        digit.push_back(index + 1);
      }
      long long remain = n - mini * count;
      long long changed_from;
      long long changed_to;
      for (long long h = 0; h < count; h++) {
        changed_from = digit[h];
        changed_to = digit[h];
        for (long long i = index; i < 9; i++) {
          if (mini + remain >= v[i].second) {
            digit[h] = i + 1;
            changed_to = i + 1;
          }
        }
        remain = remain - v[changed_to - 1].second + v[changed_from - 1].second;
      }
      for (auto x : digit) {
        cout << x;
      }
      cout << " "
           << "\n";
    }
  }
  return 0;
}
