#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int Mxn = 5005;
void solve() {
  long long k;
  cin >> k;
  int a[10];
  int sum = 0;
  for (int i = 1; i <= 9; i++) cin >> a[i], sum += a[i];
  int mn = *min_element(a + 1, a + 10);
  int mnDigit;
  for (int i = 9; i > 0; i--) {
    if (mn == a[i]) {
      mnDigit = i;
      break;
    }
  }
  if (mn > k) {
    cout << "-1";
    return;
  }
  int len = k / mn;
  int rem = k - mn * len;
  int res[len];
  for (int i = 0; i < len; i++) {
    res[i] = mnDigit;
  }
  for (int i = 0; i < len; i++) {
    for (int j = 9; j > mnDigit; j--) {
      if (rem + mn >= a[j]) {
        res[i] = j;
        rem += mn;
        rem -= a[j];
        break;
      }
    }
  }
  for (int i = 0; i < len; i++) cout << res[i];
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
