#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 5;
const int INF = (int)1e9 + 7;
const double EPS = 1e-9;
const int hh[4] = {1, -1, 0, 0};
const int hc[4] = {0, 0, 1, -1};
void nhap();
void process();
int n;
int res;
int f[1000006];
int main() {
  int nTest = 1;
  for (int test = 1; test <= nTest; ++test) {
    nhap();
    process();
  }
}
void nhap() {
  int v;
  cin >> v;
  int a[10];
  for (int i = 1; i <= 9; ++i) cin >> a[i];
  for (int i = 1; i <= v; ++i)
    for (int j = 9; j > 0; --j)
      if (i >= a[j]) f[i] = max(f[i], f[i - a[j]] + 1);
  if (f[v] == 0)
    cout << -1;
  else
    while (1) {
      bool ok = 1;
      for (int i = 9; i > 0; --i)
        if (v >= a[i] && f[v] == f[v - a[i]] + 1) {
          cout << i;
          v -= a[i];
          ok = 0;
          break;
        }
      if (ok) break;
    }
}
void process() {}
