#include <bits/stdc++.h>
using namespace std;
long long a[15];
int main() {
  long long v, mi = 99999999999, m = 0;
  cin >> v;
  for (int i = 0; i < 9; i++) {
    cin >> a[i];
    if (a[i] <= mi) {
      mi = a[i];
      m = i;
    }
  }
  string s;
  for (int i = 0; i < v / mi; i++) {
    s += (char)(m + (int)'1');
  }
  v %= mi;
  bool bad = false;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 8; j > m; j--) {
      if (a[j] - a[m] <= v) {
        s[i] = (char)((int)s[i] + (j - m));
        v -= a[j] - a[m];
        break;
      }
      if (j == m + 1) {
        bad = true;
      }
    }
    if (bad) break;
  }
  if (s.size() == 0)
    cout << "-1";
  else
    cout << s;
  return 0;
}
