#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const double PI = 2 * acos(0);
int A[10];
int main() {
  int V;
  cin >> V;
  int mini = 1000000;
  int batas = -1;
  for (int i = 1; i < 10; i++) {
    cin >> A[i];
    if (mini >= A[i]) {
      if (mini == A[i] && batas < i)
        batas = i;
      else {
        mini = A[i];
        batas = i;
      }
    }
  }
  int panjang = V / mini;
  int sementara = V % mini;
  string ans;
  for (int i = 0; i < panjang; i++) {
    char z = (int)'0' + batas;
    sementara += mini;
    bool cek = 0;
    for (int j = 9; j > batas; j--) {
      if (sementara >= A[j]) {
        sementara -= A[j];
        z = (int)'0' + j;
        j = batas;
        cek = 1;
      }
    }
    if (!cek) sementara -= mini;
    ans.push_back(z);
  }
  if (ans.length() > 0)
    cout << ans << "\n";
  else
    cout << "-1\n";
}
