#include <bits/stdc++.h>
using namespace std;
int main() {
  int nofLitres;
  cin >> nofLitres;
  map<int, int> nofLForLNum;
  for (int i = 0; i < 9; i++) {
    int nofL;
    cin >> nofL;
    nofLForLNum[nofL] = max(i + 1, nofLForLNum[nofL]);
  }
  map<int, int, greater<int>> lNumforNLit;
  for (auto it = nofLForLNum.begin(); it != nofLForLNum.end(); it++) {
    lNumforNLit[it->second] = it->first;
  }
  string ans = "";
  int bNum = nofLForLNum.begin()->first;
  int nofDigs = nofLitres / bNum;
  for (int l = nofLitres - 1; l >= 0; l--) {
    int dig = bNum;
    for (auto it = lNumforNLit.begin(); it != lNumforNLit.end(); it++) {
      if ((nofLitres >= it->second) && ((nofLitres - it->second) / bNum >= l)) {
        ans += char(it->first + '0');
        nofLitres -= it->second;
        break;
      }
    }
  }
  if (ans.length() == 0) {
    cout << -1;
  } else {
    cout << ans;
  }
  return 0;
}
