#include <bits/stdc++.h>
using namespace std;
int const N = 100001;
int n, m = 1e9;
int a[10];
int main() {
  cin >> n;
  for (int i = 1; i < 10; i++) {
    cin >> a[i];
    m = min(a[i], m);
  }
  int s = n / m;
  if (!s) return puts("-1"), 0;
  while (s--) {
    for (int i = 9; i >= 1; i--)
      if (s * m + a[i] <= n) {
        cout << i;
        n -= a[i];
        break;
      }
  }
  return 0;
}
