#include <bits/stdc++.h>
using namespace std;
const int MAXN = 111;
int n;
int s = 1000001, d;
int a[MAXN];
int main() {
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    cin >> a[i];
    s = min(s, a[i]);
  }
  d = n / s;
  if (!d) {
    cout << -1;
    return 0;
  }
  while (d--)
    for (int i = 9; i >= 1; i--)
      if ((n - a[i]) / s == d && n >= a[i]) {
        cout << i;
        n -= a[i];
        break;
      }
}
