#include <bits/stdc++.h>
using namespace std;
int arr[10];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 9; i++) cin >> arr[i];
  int pos = *min_element(arr, arr + 9);
  if (pos > n) {
    cout << -1 << endl;
    return 0;
  }
  while (1) {
    int p = n / pos;
    if (p == 0) break;
    for (int j = 8; j >= 0; j--) {
      if (n >= arr[j]) {
        int x = (n - arr[j]) / pos;
        if (p == x + 1) {
          cout << j + 1;
          n -= arr[j];
          break;
        }
      }
    }
  }
  cout << endl;
  return 0;
}
