#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v(9);
  unordered_map<long long int, long long int> umap;
  for (long long int i = 0; i < 9; i++) {
    cin >> v[i].first;
    v[i].second = i + 1;
    umap[i + 1] = v[i].first;
  }
  sort(v.begin(), v.end(),
       [](pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
         if (a.first != b.first) return a.first < b.first;
         return a.second > b.second;
       });
  long long int repeat = n / v[0].first;
  if (repeat == 0) return cout << "-1", 0;
  long long int left = n % v[0].first;
  vector<long long int> ans(repeat, v[0].second);
  for (long long int i = 0; i < ans.size(); i++) {
    long long int currentDigit = ans[i];
    long long int currentCost = umap[currentDigit];
    for (long long int j = 0; j < 9; j++) {
      if (v[j].second > currentDigit && currentCost + left >= v[j].first) {
        left -= v[j].first;
        left += currentCost;
        currentCost = v[j].first;
        ans[i] = v[j].second;
        currentDigit = v[j].second;
      }
    }
  }
  for (auto ele : ans) cout << ele;
  return 0;
}
