#include <bits/stdc++.h>
using namespace std;
int main() {
  long long v;
  cin >> v;
  vector<long long> cost(9);
  for (long long i = 0; i < 9; ++i) cin >> cost[i];
  long long minCost = *min_element(cost.begin(), cost.end());
  if (minCost > v) {
    cout << -1 << endl;
    return 0;
  }
  long long maxPossLength = v / minCost, currentLength = 0;
  string str = "";
  for (long long i = 9; i >= 1; --i) {
    long long key = i, Cost = cost[i - 1];
    if (maxPossLength == currentLength) continue;
    while (currentLength < maxPossLength &&
           v - Cost >= (maxPossLength - currentLength - 1) * minCost) {
      v -= Cost;
      str.push_back(char('0' + key));
      currentLength++;
    }
  }
  cout << str << endl;
}
