#include <bits/stdc++.h>
using namespace std;
char T[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int V;
int K[50];
int main(int argc, char** argv) {
  cin >> V;
  int mmin = 1;
  for (int i = 1; i <= 9; ++i) {
    cin >> K[i];
    if (K[i] < K[mmin]) mmin = i;
  }
  int digits = V / K[mmin];
  if (digits == 0) {
    cout << "-1\n";
    return 0;
  }
  string res = "";
  char app = T[mmin];
  for (int i = 0; i < digits; ++i) res += app;
  int curr = digits * K[mmin];
  for (int i = 0; i < digits; ++i) {
    for (int j = 9; j >= 1; j--) {
      if ((curr - K[mmin] + K[j]) <= V) {
        res[i] = T[j];
        curr += K[j] - K[mmin];
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}
