#include <bits/stdc++.h>
using namespace std;
long long fact[10000001] = {0};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void Find_Factorial(long long max) {
  fact[0] = 1;
  for (long long i = 1; i <= max; i++) fact[i] = (fact[i - 1] * i) % 1000000007;
}
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    b = b >> 1;
    a = (a * a) % 1000000007;
  }
  return res;
}
long long nCr(long long n, long long r) {
  if (r < 0 || r > n) return 0;
  long long val = fact[n];
  val *= (binpow(fact[r], 1000000007 - 2) % 1000000007);
  val %= 1000000007;
  val *= (binpow(fact[n - r], 1000000007 - 2) % 1000000007);
  val %= 1000000007;
  return val;
}
void test_case() {
  long long n;
  cin >> n;
  vector<long long> v(10);
  for (long long i = 1; i < 10; i++) cin >> v[i];
  long long ind = 9;
  long long sz = INT_MAX;
  for (long long i = 9; i >= 1; i--) {
    if (sz > v[i]) {
      sz = v[i];
      ind = i;
    }
  }
  long long len = n / sz;
  long long rem = n % sz;
  string ans = "";
  bool flag = true;
  while (flag) {
    flag = false;
    for (long long i = 9; i > ind; i--) {
      if (rem + sz >= v[i]) {
        rem += sz;
        rem -= v[i];
        len--;
        ans += i + '0';
        flag = true;
        break;
      }
    }
  }
  for (long long i = 0; i < len; i++) ans += ind + '0';
  if (ans.length() == 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) test_case();
  return 0;
}
