#include <bits/stdc++.h>
using namespace std;
void Fast_Read_Out() {
  ios_base::sync_with_stdio(0);
  cin.tie(), cout.tie();
}
void Random() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
unsigned int Time() {
  unsigned int time = clock() / 1000.00;
  return time;
}
const int inf = int(1e9) + 123;
pair<int, int> a[11];
vector<int> vv;
int mini = inf, pos = 0;
int main() {
  Random();
  Fast_Read_Out();
  long long v;
  cin >> v;
  for (int i = 1; i <= 9; i++) {
    cin >> a[i].first;
    a[i].second = i;
    if (mini >= a[i].first) {
      mini = a[i].first;
      pos = a[i].second;
    }
  }
  long long len = ceil(v / mini);
  for (int i = 1; i <= len; i++) vv.push_back(pos);
  v -= len * mini;
  for (int i = 9; i >= 1; i--) {
    while (v + mini - a[i].first >= 0 && pos != a[i].second) {
      int ok = 1;
      for (int j = (int)(vv.size()) - 1; j >= 0; j--) {
        if (vv[j] == pos && pos < a[i].second) {
          vv[j] = a[i].second;
          v += mini - a[i].first;
          ok = 0;
          break;
        }
      }
      if (ok) break;
    }
  }
  if ((int)(vv.size()) == 0)
    cout << -1 << endl;
  else {
    reverse(vv.begin(), vv.end());
    for (int i = 0; i < (int)(vv.size()); i++) cout << vv[i];
  }
}
