#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main() {
  int n, Min = 1e9;
  cin >> n;
  for (int i = 0; i < 9; i++) {
    int t;
    cin >> t;
    Min = min(Min, t);
    a.push_back(t);
  }
  int div = n / Min;
  if (Min > n) {
    cout << -1 << endl;
    return 0;
  }
  string g = "";
  for (int i = 0; i < div; i++) {
    for (int x = 8; x > -1;) {
      if (((n - a[x])) >= Min * (div - (i + 1))) {
        g += char((x + 1) + '0');
        n -= a[x];
      } else
        x--;
    }
  }
  cout << g << endl;
}
