#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int A[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int v;
  cin >> v;
  int mn = N;
  for (int i = 1; i <= 9; i++) {
    cin >> A[i];
    mn = min(mn, A[i]);
  }
  int d = v / mn;
  if (d == 0) {
    cout << "-1\n";
    return 0;
  }
  int tot = d * mn;
  for (int i = 1; i <= d; i++) {
    for (int j = 9;; j--) {
      if (tot - mn + A[j] <= v) {
        cout << j;
        tot = tot - mn + A[j];
        break;
      }
    }
  }
  cout << "\n";
  return 0;
}
