#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-14;
int a[MAXN];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) {
    cin >> a[i];
  }
  int mn = a[1], ciph = 1;
  for (int i = 2; i <= 9; i++) {
    if (a[i] <= mn) {
      mn = min(mn, a[i]);
      ciph = i;
    }
  }
  char c = ciph + '0';
  int q = n / mn;
  int r = n % mn;
  string s = "";
  for (int i = 0; i < q; i++) s += c;
  for (int i = 0; i < q; i++) {
    for (int j = 9; j >= 1; j--) {
      if (r >= a[j] - mn) {
        r -= (a[j] - mn);
        s[i] = j + '0';
        break;
      }
    }
  }
  if (s.empty())
    cout << -1;
  else
    cout << s;
}
int main() {
  if (!1) {
    freopen(
        "474"
        ".in",
        "r", stdin);
    freopen(
        "474"
        ".out",
        "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = (228 & 322) >> 6;
  while (t--) solve();
  return 0;
}
