#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vpii = vector<pair<int, int> >;
using vpll = vector<pair<long long, long long> >;
using vld = vector<long double>;
using vb = vector<bool>;
const int inf = (int)1e9 + 7;
const long long llinf = (long long)1e18 + 7;
void solve() {
  long long v;
  cin >> v;
  long long a[10], mi = inf, id = 1;
  for (long long i = 1; i <= 9; i++) {
    cin >> a[i];
    if (a[i] <= mi) mi = a[i], id = i;
  }
  long long n = v / mi;
  if (n == 0ll) {
    cout << -1 << "\n";
    return;
  }
  long long left = v - n * mi;
  vll vec(n, id);
  long long id1 = id;
  for (long long i = 0; i < n; i++) {
    long long flag = 0;
    for (long long j = id + 1; j <= 9; j++) {
      if (a[j] <= mi + left) {
        flag = 1;
        id1 = j;
      }
    }
    if (!flag) break;
    vec[i] = id1;
    left = mi + left - a[id1];
  }
  for (long long i = 0; i < n; i++) {
    cout << vec[i];
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long ttt = 1;
  for (long long i = 1; i <= ttt; i++) {
    solve();
  }
}
