#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int test = 1;
  while (test--) {
    long long int n;
    cin >> n;
    long long int mi = 1e9 + 7;
    long long int dig[9];
    for (long long int i = 0; i < 9; i++) {
      cin >> dig[i];
      mi = min(mi, dig[i]);
    }
    if (mi > n) {
      cout << -1 << endl;
      continue;
    }
    vector<long long int> v;
    while (n > 0) {
      long long int temp = 0;
      for (long long int i = 0; i < 9; i++) {
        if (dig[i] <= n && dig[temp] >= dig[i]) temp = i;
      }
      if (dig[temp] <= n) {
        v.push_back(temp + 1);
        n -= dig[temp];
      } else
        break;
    }
    reverse(v.begin(), v.end());
    for (long long int i = 0; i < v.size(); i++) {
      n += dig[v[i] - 1];
      for (long long int j = 8; j >= 0; j--)
        if (dig[j] <= n) {
          v[i] = j + 1;
          break;
        }
      n -= dig[v[i] - 1];
    }
    for (auto x : v) cout << x;
    cout << endl;
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
