#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double eps = 1e-9;
const int N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  if (!n) {
  ret:;
    return cout << "-1" << endl, 0;
  }
  vector<int> a(9), d(N), D(N);
  for (int i = 0; i < 9; i++) {
    cin >> a[i];
    d[a[i]] = i + 1;
    D[i + 1] = a[i];
  }
  sort((a).begin(), (a).end());
  if (a.front() > n) goto ret;
  string ans;
  ans.resize(n / a[0]);
  for (int i = 0; i < ((int)(ans).size()); i++) ans[i] = (d[a[0]] + '0');
  int rem = n - ((int)(ans).size()) * a[0];
  for (int i = 0; i < ((int)(ans).size()); i++) {
    int cr = rem + D[(ans[i] - '0')], digit = -1;
    for (int k = (ans[i] - '0') + 1; k <= 9; ++k) {
      if (cr >= D[k]) {
        digit = k;
      }
    }
    if (digit != -1) {
      ans[i] = (digit + '0');
      rem = cr - D[digit];
    }
  }
  cout << ans << endl;
  return 0;
}
