#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[9];
  for (int i = 0; i < 9; i++) cin >> a[i];
  int m = a[8], pos = 9;
  for (int i = 8; i >= 0; i--)
    if (a[i] < m) {
      m = a[i];
      pos = i + 1;
    }
  if (m > n)
    cout << -1;
  else {
    int rem = n % m;
    int ans[9];
    for (int i = 0; i < 9; i++) ans[i] = 0;
    ans[pos - 1] = n / m;
    while (rem > 0) {
      bool flag = false;
      for (int i = 8; i >= pos; i--)
        if ((a[i] - a[pos - 1]) <= rem) {
          int x = rem / (a[i] - a[pos - 1]);
          rem -= x * (a[i] - a[pos - 1]);
          ans[i] += x;
          ans[pos - 1] -= x;
          flag = true;
        }
      if (flag == false) break;
    }
    for (int i = 8; i >= 0; i--)
      for (int j = 0; j < ans[i]; j++) printf("%d", i + 1);
  }
}
