#include <bits/stdc++.h>
using namespace std;
int main() {
  int v, a[9], mn = 1000000, nums, lover;
  cin >> v;
  for (int i = 0; i < 9; i++) {
    cin >> a[i];
    mn = min(mn, a[i]);
  }
  nums = v / mn;
  lover = v - nums * mn;
  if (mn > v) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 0; i < nums; i++) {
    for (int j = 8; i >= 0; j--)
      if (a[j] - mn <= lover) {
        lover -= a[j] - mn;
        cout << char('1' + j);
        break;
      }
  }
  cout << '\n';
  return 0;
}
