#include <bits/stdc++.h>
using namespace std;
long long int fast_exp(long long int base, long long int exp1) {
  long long int res = 1;
  while (exp1 > 0) {
    if (exp1 & 1) res = (res * base) % 1000000007;
    base = (base * base) % 1000000007;
    exp1 /= 2;
  }
  return res % 1000000007;
}
long long int pr[1000001] = {0};
void isprime() {
  pr[0] = 1;
  pr[1] = 1;
  for (long long int a = 2; a < 1000001; a++) {
    if (!pr[a]) {
      for (long long int b = a * 2; b < 1000001; b += a) {
        pr[b] = 1;
      }
    }
  }
}
long long int comp = 1, tim = 0;
struct vertex {
  vector<long long int> adj;
  long long int vis = 0;
  long long int parent = -1;
  long long int dist = 0;
  long long int component = 0;
  long long int in = 0;
  long long int out = 0;
  long long int low = 0;
  long long int child = 0;
  long long int indeg = 0;
  long long int outdeg = 0;
  bool AP = false;
};
long long int v;
long long int x[10];
string check(string s) {
  long long int k = s[0] - '0';
  long long int rem = v - x[k] * (long long int)(s.length());
  for (long long int ind = 0; ind < s.length(); ind++)
    for (long long int a = 9; a > k; a--) {
      if (x[a] - x[k] <= rem and rem > 0) {
        s[ind] = (a + '0');
        rem -= (x[a] - x[k]);
        break;
      }
    }
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> v;
  long long int len = 0;
  x[0] = 1000000007;
  for (long long int a = 1; a < 10; a++) {
    cin >> x[a];
    if (len < v / x[a]) len = v / x[a];
  }
  if (v < *min_element(x, x + 10)) {
    cout << -1 << endl;
    exit(0);
  }
  vector<string> v1;
  for (long long int a = 1; a < 10; a++) {
    if (v / x[a] == len) {
      long long int p = len;
      string s;
      while (p--) s += (a + '0');
      v1.push_back(s);
    }
  }
  string s;
  for (auto y : v1) s = max(s, check(y));
  cout << s << endl;
  return 0;
}
