#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1);
const int knightDir[8][2] = {{-2, -1}, {-2, 1}, {-1, 2},  {1, 2},
                             {2, -1},  {2, 1},  {-1, -2}, {1, -2}};
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const long long MOD = 1000000000 + 7;
int n, x, ar[10];
bool cmp(pair<int, int> &a, pair<int, int> &b) {
  if (a.first == b.first)
    return a.second > b.second;
  else
    return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<pair<int, int>> arr;
  for (int i = 0; i < 9; i++) {
    cin >> x;
    ar[i + 1] = x;
    arr.push_back({x, i + 1});
  }
  sort(arr.begin(), arr.end(), cmp);
  string s = "";
  bool flag = false;
  int x = arr[0].second, temp = n;
  for (int i = 0; i < 9; i++) {
    if (arr[i].first > n) {
      break;
    }
    int cnt = n / arr[i].first;
    n = n - (cnt * arr[i].first);
    for (int j = 0; j < cnt; j++) s += ('0' + arr[i].second);
    flag = true;
  }
  n = temp;
  int len = s.length();
  int sum = 0;
  for (int i = 1; i <= len; i++) {
    int left = (len - i);
    int xpense = sum + (left * ar[x]);
    int topay = n - xpense;
    bool dec = true;
    for (int j = 9; j >= 1; j--) {
      if (topay >= ar[j]) {
        s[i - 1] = ('0' + j);
        sum += ar[j];
        dec = true;
        break;
      }
    }
    if (!dec) break;
  }
  if (!flag)
    cout << "-1";
  else
    cout << s;
}
