#include <bits/stdc++.h>
using namespace std;
int n, a[10], mx = -1, j, tmp;
int main(int argc, char **argv) {
  scanf("%d", &n);
  for (int i = 1; i < 10; ++i) {
    scanf("%d", a + i);
    if (n / a[i] > mx) {
      mx = n / a[i];
      j = i;
    }
  }
  string s(mx, j + '0');
  n = n % a[j];
  for (int i = 0; i < mx; ++i) {
    tmp = s[i] - '0';
    for (int j = 9; j > tmp; --j) {
      if (n + a[tmp] - a[j] >= 0) {
        n += a[tmp] - a[j];
        s[i] = j + '0';
        break;
      }
    }
  }
  if (s.empty()) s = "-1";
  puts(s.c_str());
  return 0;
}
