#include <bits/stdc++.h>
using namespace std;
pair<int, int> dp[1000001];
int f_len(int v) {
  if (v < 0) return -1;
  if (v == 0) return 0;
  return dp[v].second;
}
int main() {
  dp[0] = make_pair(0, 0);
  int j, v, data[9], i, mxlen, mxlen_id, mn_paint = 1000000000, len[9];
  scanf("%d", &v);
  for (i = 0; i < 9; i++) {
    scanf("%d", &data[i]);
    mn_paint = min(mn_paint, data[i]);
  }
  for (i = 1; i <= v; i++) {
    if ((i - mn_paint) < 0) {
      dp[i] = make_pair(0, 0);
      continue;
    }
    mxlen = -1;
    for (j = 0; j < 9; j++) {
      len[j] = f_len(i - data[j]);
      mxlen = max(mxlen, len[j]);
    }
    for (j = 8; j >= 0; j--) {
      if (len[j] == mxlen) {
        dp[i].first = j + 1;
        dp[i].second = len[j] + 1;
        break;
      }
    }
  }
  if (dp[v].second == 0) {
    printf("-1\n");
    return 0;
  }
  while (v >= mn_paint) {
    printf("%d", dp[v].first);
    v -= data[dp[v].first - 1];
  }
  printf("\n");
  return 0;
}
