#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int v;
  cin >> v;
  int arr[9];
  for (int i = 0; i < 9; i++) cin >> arr[i];
  int minColour = 0;
  for (int i = 0; i < 9; i++) {
    if (arr[minColour] >= arr[i]) minColour = i;
  }
  vector<int> ans;
  while (v >= arr[minColour]) {
    ans.push_back(minColour + 1);
    v -= arr[minColour];
  }
  if (ans.size() == 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> remainingColours;
  for (int i = 8; i > minColour; i--) remainingColours.push_back(arr[i]);
  for (int i = 0; i < ans.size(); i++) {
    if (v == 0) break;
    for (int j = 0; j < remainingColours.size(); j++) {
      if (remainingColours[j] - arr[minColour] <= v) {
        v -= remainingColours[j] - arr[minColour];
        ans[i] = 9 - j;
        break;
      }
    }
  }
  for (auto i : ans) cout << i;
  cout << endl;
  return 0;
}
