#include <bits/stdc++.h>
using namespace std;
int n, v;
vector<int> a;
void init() {
  scanf("%d", &v);
  a.assign(10, 0);
  for (int i = 1; i < 10; i++) scanf("%d", &a[i]);
}
void solve() {
  vector<pair<int, int> > vec;
  for (int i = 1; i < 10; i++) vec.push_back(make_pair(a[i], -i));
  sort(vec.begin(), vec.end());
  vector<int> res;
  int numb = vec[0].second * (-1);
  int cnt = v / vec[0].first;
  v = v % vec[0].first;
  int cur = 9;
  while (cur > numb && cnt > 0) {
    if (a[cur] - vec[0].first <= v) {
      v -= a[cur] - vec[0].first;
      res.push_back(cur);
      cnt--;
    } else
      cur--;
  }
  while (cnt > 0) {
    res.push_back(numb);
    cnt--;
  }
  if (res.size() > 0)
    for (int i = 0; i < res.size(); i++) printf("%d", res[i]);
  else
    printf("-1");
}
int main() {
  init();
  solve();
  return 0;
}
