#include <bits/stdc++.h>
using namespace std;
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
class sym {
 public:
  int ind, pr;
};
int main() {
  int i, j, d, s, f, t, h, r, l, x, y, x0, y0, n, m, k;
  int b[10], c[10], a[10];
  string s1, s2, s3, sp;
  double res;
  bool ok = false;
  cin >> k;
  n = 9;
  m = INT_MAX;
  x = 0;
  for (int i = 0; i < int(n); ++i) {
    c[i] = 0;
    cin >> b[i];
    if (b[i] <= m) {
      m = b[i];
      x = i;
    }
  }
  c[x] += k / m;
  k = k % m;
  if (k > 0)
    for (int i = 8; i >= 0; i--) {
      while (c[x] > 0 && k + m >= b[i] && i > x) {
        c[x]--;
        k += m;
        k -= b[i];
        c[i]++;
      }
    }
  for (int i = 8; i >= 0; i--)
    while (c[i] > 0) {
      cout << (i + 1);
      c[i]--;
      ok = true;
    }
  if (!ok) {
    cout << "-1";
  }
  return 0;
}
