#include <bits/stdc++.h>
using namespace std;
int costs[9];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int x;
  bool poss = false;
  for (int i = 1; i <= 9; i++) {
    cin >> x;
    costs[i - 1] = x;
    if (N >= x) poss = true;
  }
  string ans = "";
  if (!poss)
    cout << -1 << endl;
  else {
    int minid;
    int m = pow(10, 6) + 1;
    for (int i = 0; i < 9; i++) {
      if (costs[i] <= m) {
        minid = i + 1;
        m = costs[i];
      }
    }
    int numchars = N / m;
    N = N % m;
    string ans = string(numchars, minid + '0');
    bool found;
    for (int i = 0; i < numchars; i++) {
      found = false;
      for (int j = 8; j >= 0; j--) {
        if (costs[j] - m <= N) {
          N += m;
          N -= costs[j];
          ans[i] = (char)(j + 1) + '0';
          found = true;
          break;
        }
      }
      if (!found) break;
    }
    cout << ans << endl;
  }
  return 0;
}
