#include <bits/stdc++.h>
using namespace std;
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
int main() {
  int v = read();
  int d[10];
  int i, mn = 2147483647, ind = 0, j, x;
  for (i = 1; i <= 9; i++) {
    d[i] = read();
    if (mn >= d[i]) mn = d[i], ind = i;
  }
  string ans = string(v / mn, ind + '0');
  v -= mn * ans.size();
  for (i = 9; i >= 1; i--) {
    for (j = 0; j < ans.size(); j++) {
      x = ans[j] - '0';
      if (x < i && d[i] - d[x] <= v) {
        v -= d[i] - d[x];
        ans[j] = i + '0';
      }
    }
  }
  if (ans.empty())
    printf("-1");
  else
    printf("%s", ans.c_str());
  return 0;
}
