#include <bits/stdc++.h>
using namespace std;
const int INF = 1e7;
int main() {
  vector<int> A;
  int V, k, cnt = 0;
  cin >> V;
  int v_mnor = INF;
  char num_mnor;
  for (int i = 0; i < 9; i++) {
    cin >> k;
    A.push_back(k);
    if (k <= v_mnor) {
      v_mnor = k;
      num_mnor = (i + 49);
      cnt = i;
    }
  }
  if (v_mnor > V) {
    cout << -1;
    return 0;
  }
  string res;
  if (V % v_mnor == 0) {
    res = string((V / v_mnor), num_mnor);
    cout << res;
    return 0;
  }
  map<char, int> X;
  X[num_mnor] = V / v_mnor;
  int money = V - v_mnor * (V / v_mnor);
  while (true) {
    bool ok = 1;
    X[num_mnor]--;
    money += v_mnor;
    int id = 0;
    for (int i = cnt + 1; i < 9; i++) {
      if (A[i] <= money) {
        id = i;
        ok = 0;
      }
    }
    if (!ok) {
      X[(id + 49)]++;
      money -= A[id];
    } else {
      X[num_mnor]++;
    }
    if (money == 0 or ok or X[num_mnor] == 0) {
      break;
    }
  }
  for (char i = '1'; i <= '9'; i++) {
    while (X[i] > 0) {
      res += i;
      X[i]--;
    }
  }
  sort(res.rbegin(), res.rend());
  cout << res;
  return 0;
}
