#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
const long long inf = 92233720ll;
long long v, n, x;
map<long long, long long> mp;
void solve() {
  cin >> v;
  for (long long i = (1); i < (10); i++) {
    cin >> x;
    mp[x] = i;
  }
  string s;
  long long mn = (*mp.begin()).first;
  long long dig = (*mp.begin()).second;
  if (v < mn)
    cout << -1;
  else {
    while (v >= mn) {
      s += dig + '0';
      v -= mn;
    }
    if (v != 0) {
      long long in_hand = v;
      for (long long i = (0); i < (s.size()); i++) {
        in_hand += mn;
        long long best = s[i] - '0';
        long long cost = mn;
        for (auto x : mp) {
          if (x.first <= in_hand && best < x.second) {
            best = x.second;
            cost = x.first;
          }
        }
        s[i] = best + '0';
        in_hand -= cost;
      }
    }
    cout << s;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
