#include <bits/stdc++.h>
using namespace std;
void solve() {
  int v;
  cin >> v;
  int a[9];
  int t = 100000, x;
  for (long long i = 0; i < 9; ++i) {
    cin >> a[i];
    t = min(t, a[i]);
  }
  if (t > v) {
    cout << -1;
    return;
  }
  x = v / t;
  while (x--) {
    for (int i = 8; i >= 0; i--) {
      if (a[i] <= v && (v - a[i]) / t == x) {
        cout << i + 1;
        v -= a[i];
        break;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
