#include <bits/stdc++.h>
using namespace std;
int arr[100000 + 100];
int num[200];
int main() {
  int n;
  int sum;
  while (scanf("%d", &sum) != EOF) {
    for (int i = 1; i <= 9; i++) scanf("%d", &arr[i]);
    int mi = 9;
    for (int i = 9; i >= 1; i--) {
      if (arr[i] < arr[mi]) {
        mi = i;
      }
    }
    int num1 = sum / arr[mi];
    if (num1 == 0) {
      printf("-1\n");
    } else {
      sum = sum - num1 * arr[mi];
      deque<int> v;
      v.clear();
      for (int k = 0; k < num1; k++) v.push_back(mi);
      int flag = 1;
      while (sum > 0 && flag) {
        flag = 0;
        for (int u = 9; u >= mi; u--) {
          if (u <= v.front()) continue;
          if (sum + arr[v.front()] - arr[u] >= 0) {
            sum = sum + arr[v.front()] - arr[u];
            v.pop_front();
            v.push_back(u);
            flag = 1;
            break;
          }
        }
      }
      vector<int> vv;
      vv.clear();
      while (!v.empty()) {
        vv.push_back(v.back());
        v.pop_back();
      }
      sort(vv.begin(), vv.end());
      int mm = vv.size();
      for (int kk = mm - 1; kk >= 0; kk--) {
        printf("%d", vv[kk]);
      }
      printf("\n");
    }
  }
  return 0;
}
