#include <bits/stdc++.h>
using namespace std;
int a[9];
int main() {
  int v, mincost = (int)1e9, mindig;
  cin >> v;
  for (int i = 0; i < 9; i++) cin >> a[i];
  for (int i = 0; i < 9; i++)
    if (a[i] < mincost) mincost = a[i], mindig = i + 1;
  int len = v / mincost;
  string str = "";
  for (int i = 0; i < len; i++) str += (char)(mindig + '0');
  int have = v % mincost;
  for (int i = 0; i < len; i++)
    for (int j = 9; j > mindig; j--)
      if (mincost + have >= a[j - 1]) {
        have = have + mincost - a[j - 1], str[i] = (char)(j + '0');
        break;
      }
  if (str.length() == 0) str = "-1";
  cout << str << '\n';
  return 0;
}
