#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lowbit(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T my_pow(T n, T p) {
  if (p == 0) return 1;
  T x = my_pow(n, p / 2);
  x = (x * x);
  if (p & 1) x = (x * n);
  return x;
}
template <class T>
T big_mod(T n, T p, T m) {
  if (p == 0) return (T)1;
  T x = big_mod(n, p / 2, m);
  x = (x * x) % m;
  if (p & 1) x = (x * n) % m;
  return x;
}
template <class T>
inline T Mod(T n, T m) {
  return (n % m + m) % m;
}
template <class T>
T multiplication(T n, T p, T m) {
  if (p == 0) return (T)0;
  T x = multiplication(n, p / 2, m);
  x = (x + x) % m;
  if (p & 1) x = (x + n) % m;
  return x;
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
template <class T>
T extract(string s, T ret) {
  stringstream ss(s);
  ss >> ret;
  return ret;
}
template <class T>
string itos(T n) {
  ostringstream ost;
  ost << n;
  ost.flush();
  return ost.str();
}
long long stoi(string s) {
  long long r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double toDouble(string s) {
  double r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
const int mod = 1e9 + 7;
struct node {
  long long u, v, w;
  long long x, y;
} arr[100100];
bool com(node a, node b) { return a.x < b.x; }
long long a, b, d, n, m, res = 0, c = 0, t = 0, ans = 0, cc = 0, f = 0, ff = 0,
                         cnt = 0, cost = 0, k;
long long mn = (1e15), mx = -(1e15);
string s, ss, ch[100100];
long long ar[654321];
long long ar1[654321];
long long dp[1005][1004];
long long l, nn;
long long rec(long long jj, long long j) {
  if (jj < 0) return 0;
  if (jj == 0) {
    if (j >= d)
      return true;
    else
      return false;
  }
  long long &res = dp[jj][j];
  if (res != -1) return res;
  res = 0;
  for (long long i = 1; i <= k; i++) {
    res = res + rec(jj - i, max(i, j));
    res %= mod;
  }
  return res % mod;
}
int main() {
  cin >> n;
  for (__typeof(9) i = 0; i < (9); i++) {
    cin >> a;
    ar[i] = a;
    if (a <= mn) {
      res = i;
      mn = a;
    }
  }
  if (mn > n) {
    cout << -1;
    return 0;
  }
  long long aa = n / mn;
  long long bb = n % mn;
  for (__typeof(aa) i = 0; i < (aa); i++) s += char(48 + 1 + res);
  for (__typeof(aa) i = 0; i < (aa); i++) {
    for (int j = 8; j > res; j--) {
      if (mn - ar[j] + bb >= 0 && bb > 0) {
        s[i] = char(j + 1 + 48);
        bb -= (ar[j] - mn);
        break;
      }
    }
    if (bb == 0) break;
  }
  cout << s << endl;
  return 0;
}
