#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f1(n)  for(ll i=0;i<(n);++i)
#define f2(n)  for(ll j=0;j<(n);++j)
#define _fast_   ios_base::sync_with_stdio(false),cin.tie(NULL);
#define pb  push_back
#define f_1(a,b) for(ll i=a;i<=b;i++)
#define f_2(a,b) for(ll j=a;j>=b;j--)
#define v(name) vector<ll> name
#define sz(a)  a.size()
const int MAX=5e5+10,mod=1e9+9,base=41,INF=1e9+10,sq=502;

int main()
{

    _fast_
    ll v;
    cin>>v;
    vector<pair<int,int>>pp;
   ll min=INT_MAX;
    f1(9)
   {
   	ll a;
    cin>>a;
    if(a<min)
    	min=a;
    pp.pb({a,i+1});
   }
  /* cout<<min<<endl;
   //sort(pp.begin(),pp.end());
   f1(9)
    cout<<pp[i].first<<" "<<pp[i].second<<endl;
   */if(v<min)
   {
   	cout<<-1<<endl;
   }
   else
   	{
      ll val =min;
      ll ans=0,ind=0;
      f1(9)
      {
        if(val==pp[i].first)
        {
        	ind=i;
        }
     }
      if( val==1)
      {
      	f1(v/val)
      	cout<<pp[ind].second;
      	cout<<endl;
      }
      else
      {
      	ll m=v;
       while(v>val)
      {
      	ll p=0;
      	ll req = val + (v%val);
      	f_1(0,8)
      	{
      		if(pp[i].first<=req)
      		{
               p=i;
       		}
        }
       //	cout<<pp[p].second;
      	v -=pp[p].first;
      	cout<<pp[p].second;
      }
      	f1((v/val))
      	cout<<pp[ind].second;
      	cout<<endl;
      }
   	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f1(n)  for(ll i=0;i<(n);++i)
#define f2(n)  for(ll j=0;j<(n);++j)
#define _fast_   ios_base::sync_with_stdio(false),cin.tie(NULL);
#define pb  push_back
#define f_1(a,b) for(ll i=a;i<=b;i++)
#define f_2(a,b) for(ll j=a;j>=b;j--)
#define v(name) vector<ll> name
#define sz(a)  a.size()
const int MAX=5e5+10,mod=1e9+9,base=41,INF=1e9+10,sq=502;

int main()
{

    _fast_
    ll v;
    cin>>v;
    vector<pair<int,int>>pp;
   ll min=INT_MAX;
    f1(9)
   {
   	ll a;
    cin>>a;
    if(a<min)
    	min=a;
    pp.pb({a,i+1});
   }
   cout<<min<<endl;
   //sort(pp.begin(),pp.end());
   f1(9)
    cout<<pp[i].first<<" "<<pp[i].second<<endl;
   if(v<pp[0].first)
   {
   	cout<<-1<<endl;
   }
   else
   	{
      ll val =min;
      ll ans=0,ind=0;
      f1(9)
      {
        if(val==pp[i].first)
        {
        	ind=i;
        }
     }
      if(v%2==0 or val==1)
      {
      	f1(v/val)
      	cout<<pp[ind].second;
      	cout<<endl;
      }
      else
      {
      	ll m=v;
       while(v>val)
      {
      	ll p=0;
      	ll req = val + (v%val);
      	f_1(0,8)
      	{
      		if(pp[i].first<=req)
      		{
               p=i;
       		}
        }
       //	cout<<pp[p].second;
      	v -=pp[p].first;
      	cout<<pp[p].second;
      }
      	f1((v/val))
      	cout<<pp[ind].second;
      	cout<<endl;
      }
   	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f1(n)  for(ll i=0;i<(n);++i)
#define f2(n)  for(ll j=0;j<(n);++j)
#define _fast_   ios_base::sync_with_stdio(false),cin.tie(NULL);
#define pb  push_back
#define f_1(a,b) for(ll i=a;i<=b;i++)
#define f_2(a,b) for(ll j=a;j>=b;j--)
#define v(name) vector<ll> name
#define sz(a)  a.size()
const int MAX=5e5+10,mod=1e9+9,base=41,INF=1e9+10,sq=502;

int main()
{

    _fast_
    ll v;
    cin>>v;
    vector<pair<int,int>>pp;
    f1(9)
   {
   	ll a;
    cin>>a;
    pp.pb({a,i+1});
   }
   sort(pp.begin(),pp.end());
   /*f1(9)
    cout<<pp[i].first<<" "<<pp[i].second<<endl;
  */ if(v<pp[0].first)
   {
   	cout<<-1<<endl;
   }
   else
   	{
      ll val =pp[0].first;
      ll ans=0,ind=0;
      f1(9)
      {
        if(val!=pp[i].first)
        {
        	ind=i;
        	break;
        }

      }
      if(v%2==0 or val==1)
      {
      	if(ind==0)
      		ind=9;
      	f1(v/val)
      	cout<<pp[ind-1].second;
      	cout<<endl;
      }
      else
      {
       while(v>val)
      {
      	ll p=0;
      	ll req = val + (v%val);
      	f_1(ind,8)
      	{
      		if(pp[i].first<=req)
      		{
               p=i;
       		}
      	}
      	cout<<pp[p].second;
      	v -=pp[p].first;
      }
      	f1((v/val))
      	cout<<pp[ind-1].second;
      	cout<<endl;
      }
   	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f1(n)  for(ll i=0;i<(n);++i)
#define f2(n)  for(ll j=0;j<(n);++j)
#define _fast_   ios_base::sync_with_stdio(false),cin.tie(NULL);
#define pb  push_back
#define f_1(a,b) for(ll i=a;i<=b;i++)
#define f_2(a,b) for(ll j=a;j>=b;j--)
#define v(name) vector<ll> name
#define sz(a)  a.size()
const int MAX=5e5+10,mod=1e9+9,base=41,INF=1e9+10,sq=502;

int main()
{

    _fast_
    ll v;
    cin>>v;
    vector<pair<int,int>>pp;
   ll min=INT_MAX;
    f1(9)
   {
   	ll a;
    cin>>a;
    if(a<min)
    	min=a;
    pp.pb({a,i+1});
   }
  /* cout<<min<<endl;
   //sort(pp.begin(),pp.end());
   f1(9)
    cout<<pp[i].first<<" "<<pp[i].second<<endl;
   */if(v<pp[0].first)
   {
   	cout<<-1<<endl;
   }
   else
   	{
      ll val =min;
      ll ans=0,ind=0;
      f1(9)
      {
        if(val==pp[i].first)
        {
        	ind=i;
        }
     }
      if(v%2==0 or val==1)
      {
      	f1(v/val)
      	cout<<pp[ind].second;
      	cout<<endl;
      }
      else
      {
      	ll m=v;
       while(v>val)
      {
      	ll p=0;
      	ll req = val + (v%val);
      	f_1(0,8)
      	{
      		if(pp[i].first<=req)
      		{
               p=i;
       		}
        }
       //	cout<<pp[p].second;
      	v -=pp[p].first;
      	cout<<pp[p].second;
      }
      	f1((v/val))
      	cout<<pp[ind].second;
      	cout<<endl;
      }
   	}
	return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    REP(0,9){
    //debug3(n/a[i],x,y);
        if(n/a[i]>=x){
            x=n/a[i];
            y=max(y,i);
        }
    }
    if(y==-1)cout<<"-1";
    else REP(0,x)cout<<y+1;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
	lo v,ma,print=0,right;
    vl va,a(11);
    cin>>v;
    lo min=MOD,min2=MOD;
    REP(1,10){
        cin>>a[i];
        if(a[i]<min)min=a[i];
    }
    while(1){
        ma=0;
        REP(1,10){
            lo no=v/a[i];
            ma=max(ma,no);
        }
        if(ma==0){
            break;
        }
        else {
            lo x;
            for(int i=9;i>=0;i--){
                x=v;
                x-=a[i];
                if((x/min==ma-1)&&(x>=0)){
                    right=i;
                    break;
                }
            }
            va.push_back(right);
            print=1;
            v-=(a[right]);
        }
    }
    if(print==0)cout<<"-1";
    sort(va.begin(),va.end(),greater<lo>());
    for(lo i=0;i<va.size();i++)cout<<va[i];
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    vl ans;
    lo mi=*min_element(all(a));
    while(1){
        REP(0,9){
        //debug3(n/a[i],x,y);
            if(n/a[i]>=x and n/a[i]){
                x=n/a[i];
                y=max(y,i);
            }
        }
        REP(0,x){
            ans.pb(y+1);
            n-=x;
        }
        if(n<mi)break;
    }
    sort(all(ans));
    reverse(all(ans));
    if(y==-1)cout<<"-1"<<endl;
    else REP(0,ans.size())cout<<ans[i];
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    REP(0,9){
    //debug3(n/a[i],x,y);
        if(n/a[i]>=x and n/a[i]){
            x=n/a[i];
            y=max(y,i);
        }
    }
    if(y==-1)cout<<"-1"<<endl;
    else {
        REP(0,x)cout<<y+1;
    }
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    REP(0,9){
        if(n/a[i]>=x){
            x=n/a[i];
            y=max(y,i);
        }
    }
    if(y==-1)cout<<"-1";
    else REP(0,x)cout<<i+1;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    REP(0,n){
        if(v/a[i]>=x){
            x=v/a[i];
            y=max(y,i);
        }
    }
    if(y)cout<<"-1";
    else REP(0,x)cout<<i+1;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    REP(0,9){
        if(n/a[i]>=x){
            x=n/a[i];
            y=max(y,i);
        }
    }
    if(y)cout<<"-1";
    else REP(0,x)cout<<i+1;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    REP(0,9){
    //debug3(n/a[i],x,y);
        if(n/a[i]>=x){
            x=n/a[i];
            y=max(y,i);
        }
    }
    if(y==-1)cout<<"-1"<<endl;
    else {
        REP(0,x)cout<<y+1;
    }
    cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    vl ans;
    lo mi=*min_element(all(a));
    while(1){
        REP(0,9){
        //debug3(n/a[i],x,y);
            if(n/a[i]>=x and n/a[i]){
                x=n/a[i];
                y=max(y,i);
            }
        }
        //debug2(x,mi);
        REP(0,x){
            ans.pb(y+1);
            n-=a[y];
        }
        //debug2(n,x);
        //break;
        if(n<mi)break;
    }
    //debug(ans.size());
    sort(all(ans));
    reverse(all(ans));
    if(y==-1)cout<<"-1"<<endl;
    else REP(0,ans.size())cout<<ans[i];
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    vl ans;
    lo mi=*min_element(all(a));
    while(1){
        REP(0,9){
        //debug3(n/a[i],x,y);
            if(n/a[i]>=x and n/a[i]){
                x=n/a[i];
                y=max(y,i);
            }
        }
        REP(0,x){
            ans.pb(y);
            n-=x;
        }
        if(n<min)break;
    }
    sort(all(ans));
    reverse(all(ans));
    if(y==-1)cout<<"-1"<<endl;
    else cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
	lo v,ma,print=0,right;
    vl va,a(10);
    cin>>v;
    lo min=min2=MOD;
    REP(0,9)
        cin>>arr[i];
        if(arr[i]<min)min=arr[i];
    }
    while(1){
        ma=0;
        REP(0,9)
            no=v/arr[i];
            ma=max(ma,no);
        }
        if(ma==0){
            break;
        }
        else {
            lo x;
            for(int i=9;i>=0;i--){
                x=v;
                x-=arr[i];
                if((x/min==ma-1)&&(x>=0)){
                    right=i;
                    break;
                }
            }
            va.push_back(right);
            print=1;
            v-=(arr[right]);
        }
    }
    if(print==0)
    cout<<"-1";
    sort(va.begin(),va.end(),greater<int>());
    for(int i=0;i<va.size();i++)
    cout<<va[i];
    return 0;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including seg_tree_order_statistics_node_update
#include <stdio.h>
#include <cassert>
using namespace std;
//using namespace __gnu_pbds;
typedef long long  lo;
typedef long double ld;
typedef pair<lo,lo> ll;//pair
typedef vector<lo> vl;  //vector of long
typedef vector<ll > vll;   //vector of pair
typedef priority_queue<lo>p_q;
typedef vector< vl > vvl;  //vector of vectors
#define X first
#define Y second
#define mp(a,b) make_pair((a),(b))
#define REP(a,b) for(lo i=(a);i<(lo)b;i++)//no need to declare variable i
#define REPE(a,b,c,d) REP(a,b)for(lo j=(c);j<(lo)d;j++)//no need to declare vaiables i,j
#define REPV(a,b,c) for(lo(a)=b;(a)<(c);(a)++)//a is the variable
#define IREP(a,b) for(lo i=(a);i>=(b);i--)
#define IREPV(a,b,c) for(lo(a)=b;(a)>=(c);(a)--)
#define all(v) (v).begin(),(v).end()
#define TRV(a) for(auto &it : a)
#define INF 101000
#define MOD 1000000007
#define M 1000000007
#define BLOCK 300
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
#define pb(a) push_back((a))
#define eps 1e-2
#define PI acos(-1.0)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debug2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w<<"="<<w<<endl;
#define debug5(x,y,z,w,t) cout<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug6(p,x,y,z,w,t) cout<<#p<<" "<<p<<" "<<#x<<"="<<x <<" ";debug4(y,z,w,t);
#define debug7(o,p,x,y,z,w,t) cout<<#o<<" "<<o<<" ";debug6(p,x,y,z,w,t);
#define print_matrix(a,n,m) REPE(0,n,0,m){cout<<(a)[i][j]<<((j==m-1)?'\n':' ');}
#define endl "\n"
template<typename T> ostream& operator<< ( ostream &o,vector<T> v ) {
    if ( v.size() >0 )o<<v[0];
    for ( unsigned   i=1; i<v.size(); i++ )o<<" "<<v[i];
    return o<<endl;
}
template<typename U,typename V> ostream& operator<< ( ostream &o,pair<U,V> p ) {
    return o<<"("<<p.first<<", "<<p.second<<") ";
}
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
    for ( unsigned   i=0; i<v.size(); i++ )in>>v[i];
    return in;
}
template<typename T> istream& operator>> ( istream &in,pair <T,T> &p ) {
    in>>p.X;
    in>>p.Y;
    return in;
}
int main(){
    //std::ios::sync_with_stdio(false);
	//cin.tie(0);cout.tie(0);cout.precision(20);
    lo n;
    cin>>n;
    vl a(9);
    cin>>a;
    lo x=0;
    lo y=-1;
    vl ans;
    lo mi=*min_element(all(a));
    while(1){
        REP(0,9){
        //debug3(n/a[i],x,y);
            if(n/a[i]>=x and n/a[i]){
                x=n/a[i];
                y=max(y,i);
            }
        }
        REP(0,x){
            ans.pb(y+1);
            n-=x;
        }
        if(n<mi)break;
    }
    sort(all(ans));
    reverse(all(ans));
    if(y==-1)cout<<"-1"<<endl;
    else cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[10];
int dp[10][1000006];
int len = 0;
int flag =0 ;
int solve(int st,int rem)
{
	if(rem == 0)
		return 0;
	if(dp[st][rem] != -1)
		return dp[st][rem];
	int ans = 0;
	for(int i = 1; i <= 9; ++i)
	{
		if(rem - arr[i] >= 0)
		ans = max(ans,1 + solve(i,rem - arr[i]));
	}
	return dp[st][rem] = ans;
}
void print(int v,int x)
{
	//cout << v  <<" "<<x<<endl;

	for(int i = 9; i >= 1; --i)
	{
		//cout<<solve(i,v)<<endl;ŝ]
		if(v - arr[i] >= 0 && solve(i,v - arr[i]) == x-1)
		{
			cout <<i;
			flag=1;
			print(v-arr[i],x-1);
			break;
		}

	}
}
int main()
{
	int v;
	cin >> v;
	memset(dp,-1,sizeof(dp));
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	int ans = 0;
	for(int i = 1; i <= 9; ++i)
	{
		if(v/arr[i] >= len)
		{
			len = v/arr[i];
		}
	}
	print(v,len);
	if(flag == 0)
		cout<<-1;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[10];
string solve(int v)
{
//cout << v <<endl;
if(v == 0)
	return "";
int ans = 0;
char ch;
int pos = 0;
for(int i = 1; i <= 9; ++i)
{
	if(v/arr[i] > ans)
	{
		ans = v/arr[i];
		pos = arr[i];
		ch = (i + 48);
	}
}
string aa ="";
for(int i = 1; i <= ans; ++i)
	aa = aa + ch;
aa += solve(v - pos * ans);
return aa;
}
int main()
{
	int v;
	cin >> v;
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	string ans =  solve(v);
	if(ans.empty())
		ans = -1;
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long int i=(a);i<=(b);++i)
#define NFOR(i,a,b) for(long long int i=(a);i>=(b);--i)
#define pb push_back
#define ll long long
#define F first
#define PI 3.14159265
#define S second
#define all(v) v.begin(),v.end()
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
using namespace std;
//ll prime[10000007];
//vector<ll>stprime;
//ll fastpow(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
//void sieve(){memset(prime,1,sizeof(prime));prime[0]=0;prime[1]=0;for(ll i=2;i*i<=10000000;++i){if(prime[i]){for(ll j=i*i;j<=10000000;j+=i)prime[j]=0;}}FOR(i,1,1000000){if(prime[i])stprime.pb(i);}}
//bool comp(const ll &a,const ll &b){if(a>b)return false;else return true;}
//**********************************************************************************************************************************************//

int arr[10];

int main()
{
    fast;

    int n,x;
    cin>>n;

    FOR(i,1,9)
    cin>>arr[i];

    ll brr[10];
    ll maxi=0;
    ll id=0;
    FOR(i,1,9)
    {
        x=n/arr[i];
        if(x>=maxi)
        {
            maxi=x;
            id=i;
        }
    }
    if(maxi==0)
        cout<<-1<<endl;
    else
    {
        FOR(i,1,maxi)
        cout<<id;
    }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[10];
int dp[10][1000006];
int len = 0;
int solve(int st,int rem)
{
	if(rem == 0)
		return 0;
	if(dp[st][rem] != -1)
		return dp[st][rem];
	int ans = 0;
	for(int i = 1; i <= 9; ++i)
	{
		if(rem - arr[i] >= 0)
		ans = max(ans,1 + solve(i,rem - arr[i]));
	}
	return dp[st][rem] = ans;
}
void print(int v,int x)
{
	//cout << v  <<" "<<x<<endl;

	for(int i = 9; i >= 1; --i)
	{
		//cout<<solve(i,v)<<endl;ŝ]
		if(v - arr[i] >= 0 && solve(i,v - arr[i]) == x-1)
		{
			cout <<i;

			print(v-arr[i],x-1);
			break;
		}

	}
}
int main()
{
	int v;
	cin >> v;
	memset(dp,-1,sizeof(dp));
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	int ans = 0;
	for(int i = 1; i <= 9; ++i)
	{
		if(v/arr[i] >= len)
		{
			len = v/arr[i];
		}
	}
	print(v,len);

	return 0;
}


/*
50
5 3 10 2 2 4 3 6 5
*/
#include<bits/stdc++.h>
using namespace std;
int arr[10];
string solve(int v)
{
//cout << v <<endl;
if(v == 0)
	return "";
int ans = 0;
char ch;
int pos = 0;
for(int i = 1; i <= 9; ++i)
{
	if(v/arr[i] >= ans)
	{
		ans = v/arr[i];
		pos = arr[i];
		ch = (i + 48);
	}
}
string aa ="";
for(int i = 1; i <= ans; ++i)
	aa = aa + ch;
aa += solve(v - pos * ans);
return aa;
}
int main()
{
	int v;
	cin >> v;
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	string ans =  solve(v);
	if(ans.empty())
		ans = "-1";
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[10];
string solve(int v)
{
//cout << v <<endl;
if(v == 0)
	return "";
int ans = 0;
char ch;
int pos = 0;
for(int i = 1; i <= 9; ++i)
{
	if(v/arr[i] > ans)
	{
		ans = v/arr[i];
		pos = arr[i];
		ch = (i + 48);
	}
}
string aa ="";
for(int i = 1; i <= ans; ++i)
	aa = aa + ch;
aa += solve(v - pos * ans);
return aa;
}
int main()
{
	int v;
	cin >> v;
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	string ans =  solve(v);
	if(ans.empty())
		ans = "-1";
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long int i=(a);i<=(b);++i)
#define NFOR(i,a,b) for(long long int i=(a);i>=(b);--i)
#define pb push_back
#define ll long long
#define F first
#define PI 3.14159265
#define S second
#define all(v) v.begin(),v.end()
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
using namespace std;
//ll prime[10000007];
//vector<ll>stprime;
//ll fastpow(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
//void sieve(){memset(prime,1,sizeof(prime));prime[0]=0;prime[1]=0;for(ll i=2;i*i<=10000000;++i){if(prime[i]){for(ll j=i*i;j<=10000000;j+=i)prime[j]=0;}}FOR(i,1,1000000){if(prime[i])stprime.pb(i);}}
//bool comp(const ll &a,const ll &b){if(a>b)return false;else return true;}
//**********************************************************************************************************************************************//

int arr[10];
int temp;
string ans;
map<pair<int,pair<int,string> >,string >mp;
string solve(int n,int level,string pick)
{
    if(mp.find({n,{level,pick}})!=mp.end())
        return mp[{n,{level,pick}}];

    if(pick.size()>ans.size())
    {
        ans=pick;
    }
    else if(pick.size()==ans.size())
    {
        if(pick>ans)
            ans=pick;
    }
    if(n==0)
    return "";
    if(level==temp+1)
        return "";

    string tt="",tem="";
    FOR(i,1,9)
    {
        tt=i+48;
        if(n>=arr[i])
        tem=max(solve(n,level+1,pick),solve(n-arr[i],level+1,pick+tt));
        else
        tem=solve(n,level+1,pick);
    }
   return mp[{n,{level,pick}}]=tem;
}

int main()
{
    fast;

    int n;
    cin>>n;
    temp=n;

    FOR(i,1,9)
    cin>>arr[i];

    string s=solve(n,1,"");
    if(ans.empty())
        cout<<-1<<endl;
    else
        cout<<ans<<endl;

return 0;
}


/*
50
5 3 10 2 2 4 3 6 5
*/
#include<bits/stdc++.h>
using namespace std;
int arr[10];
string solve(int v)
{
//cout << v <<endl;
if(v == 0)
	return "";

int ans = 1;
char ch;
int pos = 0;
for(int i = 1; i <= 9; ++i)
{
	if(v/arr[i] >= ans)
	{
		ans = v/arr[i];
		pos = arr[i];
		ch = (i + 48);
	}
}
string aa ="";
if(pos!=0)
for(int i = 1; i <= ans; ++i)
	aa = aa + ch;
if(pos!=0)
aa += solve(v - pos * ans);
return aa;
}
int main()
{
	int v;
	cin >> v;
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	string ans =  solve(v);
	if(ans.empty())
		ans = "-1";
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define ll long long
#define F first
#define PI 3.14159265358979323846264338327
#define S second
#define all(v) v.begin(),v.end()
#define endl "\n"
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
using namespace std;
ll arr[10];
map<int,string>mp;
string maxi (string a,string b)
{
	if(a.size() > b.size())
		return a;
	else if(b.size() > a.size())
		return b;
	else
	{
		for(int i = 0; i < a.size();++i)
		{
			if(a[i] > b[i])
				return a;
		}
		return b;
	}
}
string solve(int v)
{
	if(v == 0)
	{
		return "-1";
	}
	if(mp.find(v)!=mp.end())
		return mp[v];
	string ans = "-1";
	for(int i = 1; i <= 9; ++i)
	{
		char ss = i + 48;
		string sx = "";
		if(v - arr[i] >= 0)
		ans = maxi(ans,sx + ss + solve(v - arr[i]));
	}

	return mp[v] = ans;
}
int main()
{
    fast;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll v;
    cin >> v;
    FOR(i,1,9)
    cin >> arr[i];
    cout << solve(v);
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define ll long long
#define F first
#define PI 3.14159265358979323846264338327
#define S second
#define all(v) v.begin(),v.end()
#define endl "\n"
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
using namespace std;
ll arr[10];
map<int,string>mp;
string maxi (string a,string b)
{
	if(a.size() > b.size())
		return a;
	else if(b.size() > a.size())
		return b;
	else
	{
		for(int i = 0; i < a.size();++i)
		{
			if(a[i] > b[i])
				return a;
		}
		return b;
	}
}
string solve(int v)
{
	if(v == 0)
	{
		return "";
	}
	if(mp.find(v)!=mp.end())
		return mp[v];
	string ans = "";
	for(int i = 1; i <= 9; ++i)
	{
		char ss = i + 48;
		string sx = "";
		if(v - arr[i] >= 0)
		ans = maxi(ans,sx + ss + solve(v - arr[i]));
	}

	return mp[v] = ans;
}
int main()
{
    fast;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll v;
    cin >> v;
    FOR(i,1,9)
    cin >> arr[i];
    string s = solve(v);
    if(s.empty())
		s = "-1";
	cout<<s;
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define ll long long
#define F first
#define PI 3.14159265358979323846264338327
#define S second
#define all(v) v.begin(),v.end()
#define endl "\n"
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
using namespace std;
ll arr[10];
int main()
{
    fast;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll v,x;
    cin >> v;
    priority_queue<pair<int,int> >pq;
    FOR(i,1,9)
    {
    cin >> x;
    pq.push({-x,i});
    }
    string ans = "";
    while(!pq.empty())
	{
		pair<int,int>pp = pq.top();
		int val = -1 * pp.first;
		if(v < val)
			break;
		ll req = v / val;
		for(int i = 1; i <= req; ++i)
			ans += char(pp.second + 48);
		v -= req*val;
	}
	if(ans.empty())
		ans = "-1";
	sort(all(ans));
	reverse(ans.begin(),ans.end());
	cout << ans;

    return 0;
}


/*
50
5 3 10 2 2 4 3 6 5
*/
#include<bits/stdc++.h>
using namespace std;
int arr[10];
string solve(int v)
{
//cout << v <<endl;
if(v == 0)
	return "";

int ans = 0;
char ch;
int pos = 0;
for(int i = 1; i <= 9; ++i)
{
	if(v/arr[i] >= ans)
	{
		ans = v/arr[i];
		pos = arr[i];
		ch = (i + 48);
	}
}
string aa ="";
for(int i = 1; i <= ans; ++i)
	aa = aa + ch;
if(pos!=0)
aa += solve(v - pos * ans);
return aa;
}
int main()
{
	int v;
	cin >> v;
	for(int i = 1; i <= 9; ++i)
		cin >> arr[i];
	string ans =  solve(v);
	if(ans.empty())
		ans = "-1";
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back
#define ll long long
#define F first
#define PI 3.14159265358979323846264338327
#define S second
#define all(v) v.begin(),v.end()
#define endl "\n"
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
using namespace std;
ll arr[10];
int main()
{
    fast;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll v,x;
    cin >> v;
    priority_queue<pair<int,int> >pq;
    FOR(i,1,9)
    {
    cin >> x;
    pq.push({-x,i});
    }
    string ans = "";
    while(!pq.empty())
	{
		pair<int,int>pp = pq.top();
		int val = -1 * pp.first;
		if(v < val)
			break;
		ll req = v / val;
		for(int i = 1; i <= req; ++i)
			ans += char(pp.second + 48);
		v -= req*val;
	}

	sort(all(ans));
	reverse(ans.begin(),ans.end());
	if(ans.empty())
		ans += "-1";
	cout << ans;

    return 0;
}


#include<stdio.h>
#include<string.h>
using namespace std;
int a[15];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i]);
        }
        int maxlen=0;
        int maxnum=0;
        int yu=0;
        for(int i=9;i>=1;i--)
        {
            if(n/a[i]>maxlen)
            {
                maxlen=n/a[i];
                maxnum=i;
                yu=n%a[i];
            }
        }
        if(maxlen==0)printf("-1");
        for(int i=9;i>maxnum;i--)
        {
            if(yu+a[maxnum]>=a[i])
            {
                int len=yu/(a[i]-a[maxnum]);
                for(int j=0;j<len;j++)
                {
                    printf("%d",i);
                    maxlen--;
                }
                yu=yu%(a[i]-a[maxnum]);
            }
        }
        for(int i=0;i<maxlen;i++)
        {
            printf("%d",maxnum);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<string.h>
using namespace std;
int a[15];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i]);
        }
        int maxlen=0;
        int maxnum=0;
        int yu=0;
        for(int i=9;i>=1;i--)
        {
            if(n/a[i]>maxlen)
            {
                maxlen=n/a[i];
                maxnum=i;
                yu=n%a[i];
            }
        }
        if(maxlen==0)printf("-1");
        for(int i=0;i<maxlen;i++)
        {
            int flag=0;
            for(int j=9;j>maxnum;j--)
            {
                if(a[j]-a[maxnum]<=yu)
                {
                    yu-=a[j]-a[maxnum];
                    flag=1;
                    printf("%d",j);
                    break;
                }
            }
            if(flag==0)printf("%d",maxnum);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<string.h>
using namespace std;
int a[15];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i]);
        }
        int maxlen=0;
        int maxnum=0;
        int yu=0;
        for(int i=1;i<=9;i++)
        {
            if(n/a[i]>maxlen)
            {
                maxlen=n/a[i];
                maxnum=i;
                yu=n%a[i];
            }
        }
        if(maxlen==0)printf("-1");
        for(int i=0;i<maxlen;i++)
        {
            int j;
            for(j=9;j>maxnum;j--)
            {
                if(a[j]-a[maxnum]<=yu)
                {
                    yu-=a[j]-a[maxnum];
                    break;
                }
            }
            printf("%d",j);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct node
{
    int val;
    int num;
}a[15];
int have[15];
int cmp(node a,node b)
{
    if(a.val!=b.val)
    return a.val<b.val;
    else return a.num>b.num;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(have,0,sizeof(have));
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i].val);
            a[i].num=i;
        }
        int maxlen=0;
        int maxnum=0;
        for(int i=9;i>=1;i--)
        {
            if(n/a[i].val>maxlen)
            {
                maxnum=i;
                maxlen=n/a[i].val;
            }
        }
        if(maxlen==0)printf("-1");
        for(int i=0;i<maxlen;i++)
        {
            printf("%d",maxnum);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<string.h>
using namespace std;
int a[15];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i]);
        }
        int maxlen=0;
        int maxnum=0;
        int yu=0;
        for(int i=9;i>=1;i--)
        {
            if(n/a[i]>maxlen)
            {
                maxlen=n/a[i];
                maxnum=i;
                yu=n%a[i];
            }
        }
        if(maxlen==0)printf("-1");
        for(int i=0;i<maxlen;i++)
        {
            int j;
            for(j=9;j>maxnum;j--)
            {
                if(a[j]-a[maxnum]<=yu)
                {
                    yu-=a[j]-a[maxnum];
                    break;
                }
            }
            printf("%d",j);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct node
{
    int val;
    int num;
}a[15];
int have[15];
int cmp(node a,node b)
{
    return a.val<b.val;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(have,0,sizeof(have));
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i].val);
            a[i].num=i;
        }
        sort(a+1,a+10,cmp);
        for(int i=1;i<=9;i++)
        {
            have[a[i].num]=n/a[i].val;
            n=n%a[i].val;
        }
        int flag=0;
        for(int i=1;i<=9;i++)
        {
            for(int j=0;j<have[i];j++)
            {
                flag=1;
                printf("%d",i);
            }
        }
        if(flag==0)printf("-1");
        printf("\n");
    }
}


#include<stdio.h>
#include<string.h>
using namespace std;
int a[15];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i]);
        }
        int maxlen=0;
        int maxnum=0;
        int yu=0;
        for(int i=9;i>=1;i--)
        {
            if(n/a[i]>maxlen)
            {
                maxlen=n/a[i];
                maxnum=i;
                yu=n%a[i];
            }
        }
        if(maxlen==0)printf("-1");
        for(int i=9;i>maxnum;i--)
        {
            if(yu+a[maxnum]>a[i])
            {
                int len=yu/(a[i]-a[maxnum]);
                for(int j=0;j<len;j++)
                {
                    printf("%d",i);
                    maxlen--;
                }
                yu=yu%(a[i]-a[maxnum]);
            }
        }
        for(int i=0;i<maxlen;i++)
        {
            printf("%d",maxnum);
        }
        printf("\n");
    }
}


#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct node
{
    int val;
    int num;
}a[15];
int have[15];
int cmp(node a,node b)
{
    if(a.val!=b.val)
    return a.val<b.val;
    else return a.num>b.num;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(have,0,sizeof(have));
        for(int i=1;i<=9;i++)
        {
            scanf("%d",&a[i].val);
            a[i].num=i;
        }
        sort(a+1,a+10,cmp);
        for(int i=1;i<=9;i++)
        {
            have[a[i].num]=n/a[i].val;
            n=n%a[i].val;
        }
        int flag=0;
        for(int i=1;i<=9;i++)
        {
            for(int j=0;j<have[i];j++)
            {
                flag=1;
                printf("%d",i);
            }
        }
        if(flag==0)printf("-1");
        printf("\n");
    }
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

typedef struct
{
    int siz=0;
    int nw=0;
    int kt=0;
} dnode;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        temp.a=A[i+1].a;
        temp.n=mx;
        B.push_back(temp);
        mx=0;
    }

    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
    dnode dp[B.size()+1][v+1];
    for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
            if(B[i-1].a<=j)
            {
                if(dp[i][j-B[i-1].a].siz+1>=dp[i-1][j].siz)
                {
                    int k=1;
                    while(k*B[i-1].a<=j)
                    {
                        if(dp[i][j-k*B[i-1].a].siz+k>=dp[i-1][j].siz)
                        {
                            k++;
                        }
                        else break;

                    }
                    k--;
                    dp[i][j].siz=dp[i][j-k*B[i-1].a].siz+k;
                    dp[i][j].nw=1;
                    dp[i][j].kt=k;
                }
                else
                {
                    dp[i][j].siz=dp[i-1][j].siz;
                    dp[i][j].nw=0;
                    dp[i][j].kt=0;
                }
            }
            else
            {
                dp[i][j].siz=dp[i-1][j].siz;
                dp[i][j].nw=0;
                dp[i][j].kt=0;
            }
        }
    }
    dnode x=dp[B.size()][v];
    if(x.siz==0)cout<<"-1\n";
    else
    {
        int i,j;
        i=B.size();
        j=v;
        while(x.siz!=0)
        {
            if(x.nw==1)
            {
                for(int k=0; k<x.kt; k++)cout<<B[i-1].n;
                j-=x.kt*B[i-1].a;
                x=dp[i][j];
            }
            else
            {
                i--;
                x=dp[i][j];
            }
        }
    }

}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        temp.a=A[i+1].a;
        temp.n=mx;
        B.push_back(temp);
        mx=0;
    }
    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
    vector<int> dp[B.size()+1][v+1];
    for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
            if(B[i-1].a<=j)
            {
                if(dp[i][j-B[i-1].a].size()+1>dp[i-1][j].size())
                {
                    int k=1;
                    while(k*B[i-1].a<=j)
                    {
                        if(dp[i][j-k*B[i-1].a].size()+k>dp[i-1][j].size())
                        {
                            k++;
                        }
                        else break;

                    }
                    k--;
                    dp[i][j]=dp[i][j-k*B[i-1].a];
                    for(int p=0; p<k; p++)dp[i][j].push_back(B[i-1].n);
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                }
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    vector<int> tem;
    tem=dp[B.size()][v];
    if(tem.size()==0)cout<<"-1\n";
    else
        for(int i=0; i<tem.size(); i++)cout<<tem[i];
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

typedef struct
{
    int siz=0;
    int nw=0;
    int kt=0;
} dnode;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0,flag=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            flag=1;
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        if(flag)
        {
            temp.a=A[i+1].a;
            temp.n=mx;
            B.push_back(temp);
            mx=0;
            flag=0;
        }
        else
            B.push_back(A[i+1]);
    }

    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
    dnode dp[B.size()+1][v+1];
    for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
            if(i==1)
            {
                dp[i][j].siz=j/B[0].a;
                dp[i][j].nw=1;
                dp[i][j].kt=dp[i][j].siz;
            }
            else if(B[i-1].a<=j)
            {
                if(dp[i][j-B[i-1].a].siz+1>dp[i-1][j].siz)
                {
                    int k=1;
                    while(k*B[i-1].a<=j)
                    {
                        if(dp[i][j-k*B[i-1].a].siz+k>dp[i-1][j].siz)
                        {
                            k++;
                        }
                        else break;

                    }
                    k--;
                    // k=(j/B[i-1].a)-dp[i-1][j].siz+1;
                    dp[i][j].siz=dp[i][j-k*B[i-1].a].siz+k;
                    dp[i][j].nw=1;
                    dp[i][j].kt=k;
                }
                else if(dp[i][j-B[i-1].a].siz+1==dp[i-1][j].siz)
                {
                    int flag=1;
                    for(int x=0; x<i-1; x++)
                        if(B[x].n>B[i-1].n)
                            flag=0;
                    if(flag)
                    {
                        int k=1;
                        while(k*B[i-1].a<=j)
                        {
                            if(dp[i][j-k*B[i-1].a].siz+k>=dp[i-1][j].siz)
                            {
                                k++;
                            }
                            else break;

                        }
                        k--;
                        // k=(j/B[i-1].a)-dp[i-1][j].siz+1;
                        dp[i][j].siz=dp[i][j-k*B[i-1].a].siz+k;
                        dp[i][j].nw=1;
                        dp[i][j].kt=k;
                    }
                    else
                    {
                    dp[i][j].siz=dp[i-1][j].siz;
                    dp[i][j].nw=0;
                    dp[i][j].kt=0;
                    }
                }
                else
                {
                    dp[i][j].siz=dp[i-1][j].siz;
                    dp[i][j].nw=0;
                    dp[i][j].kt=0;
                }
            }
            else
            {
                dp[i][j].siz=dp[i-1][j].siz;
                dp[i][j].nw=0;
                dp[i][j].kt=0;
            }
        }
    }
    dnode x=dp[B.size()][v];
    if(x.siz==0)cout<<"-1\n";
    else
    {
        int i,j;
        i=B.size();
        j=v;
        while(x.siz!=0)
        {
            if(x.nw==1)
            {
                for(int k=0; k<x.kt; k++)printf("%d",B[i-1].n);
                j-=x.kt*B[i-1].a;
                x=dp[i][j];
            }
            else
            {
                i--;
                x=dp[i][j];
            }
        }
    }
    cout<<endl;

}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        temp.a=A[i+1].a;
        temp.n=mx;
        B.push_back(temp);
        mx=0;
    }
    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
    vector<int> dp[B.size()+1][v+1];
    for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
            if(B[i-1].a<=j)
            {
                if(dp[i][j-B[i-1].a].size()+1>dp[i-1][j].size())
                {
                    int k=1;
                    while(k*B[i-1].a<=j)
                    {
                        if(dp[i][j-k*B[i-1].a].size()+k>dp[i-1][j].size())
                        {
                            dp[i][j]=dp[i][j-k*B[i-1].a];
                            for(int p=0; p<k; p++)dp[i][j].push_back(B[i-1].n);
                        }
                        k++;
                    }
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                }
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    vector<int> tem;
    tem=dp[B.size()][v];
    if(tem.size()==0)cout<<"-1\n";
    else
        for(int i=0; i<tem.size(); i++)cout<<tem[i];
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        temp.a=A[i+1].a;
        temp.n=mx;
        B.push_back(temp);
        mx=0;
    }

    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
    vector<int> dp[B.size()+1][v+1];
    for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
            if(B[i-1].a<=j)
            {
                if(dp[i][j-B[i-1].a].size()+1>=dp[i-1][j].size())
                {
                    int k=1;
                    while(k*B[i-1].a<=j)
                    {
                        if(dp[i][j-k*B[i-1].a].size()+k>=dp[i-1][j].size())
                        {
                            k++;
                        }
                        else break;

                    }
                    k--;
                    dp[i][j]=dp[i][j-k*B[i-1].a];
                    for(int p=0; p<k; p++)dp[i][j].push_back(B[i-1].n);
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                }
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    dp[B.size()][v];
    if(dp[B.size()][v].size()==0)cout<<"-1\n";
    else
        for(int i=dp[B.size()][v].size()-1; i>=0; i--)cout<<dp[B.size()][v][i];
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

typedef struct
{
    int siz=0;
    int nw=0;
    int kt=0;
} dnode;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0,flag=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            flag=1;
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        if(flag)
        {
            temp.a=A[i+1].a;
            temp.n=mx;
            B.push_back(temp);
            mx=0;
            flag=0;
        }
        else
            B.push_back(A[i+1]);
    }

    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
     dnode dp[B.size()+1][v+1];
     for(int i=1; i<B.size()+1; i++)
     {
         for(int j=1; j<v+1; j++)
         {
             if(i==1){
                 dp[i][j].siz=j/B[0].a;
                 dp[i][j].nw=1;
                 dp[i][j].kt=dp[i][j].siz;
             }
             else if(B[i-1].a<=j)
             {
                 if(dp[i][j-B[i-1].a].siz+1>=dp[i-1][j].siz)
                 {
                     int k=1;
                     while(k*B[i-1].a<=j)
                     {
                         if(dp[i][j-k*B[i-1].a].siz+k>=dp[i-1][j].siz)
                         {
                             k++;
                         }
                         else break;

                     }
                     k--;
                    // k=(j/B[i-1].a)-dp[i-1][j].siz+1;
                     dp[i][j].siz=dp[i][j-k*B[i-1].a].siz+k;
                     dp[i][j].nw=1;
                     dp[i][j].kt=k;
                 }
                 else
                 {
                     dp[i][j].siz=dp[i-1][j].siz;
                     dp[i][j].nw=0;
                     dp[i][j].kt=0;
                 }
             }
             else
             {
                 dp[i][j].siz=dp[i-1][j].siz;
                 dp[i][j].nw=0;
                 dp[i][j].kt=0;
             }
         }
     }
     dnode x=dp[B.size()][v];
    if(x.siz==0)cout<<"-1\n";
    else
    {
        int i,j;
        i=B.size();
        j=v;
        while(x.siz!=0)
        {
            if(x.nw==1)
            {
                for(int k=0; k<x.kt; k++)printf("%d",B[i-1].n);
                j-=x.kt*B[i-1].a;
                x=dp[i][j];
            }
            else
            {
                i--;
                x=dp[i][j];
            }
        }
    }
    cout<<endl;

}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

typedef struct
{
    int siz=0;
    int nw=0;
    int kt=0;
} dnode;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0,flag=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            flag=1;
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        if(flag)
        {
            temp.a=A[i+1].a;
            temp.n=mx;
            B.push_back(temp);
            mx=0;
            flag=0;
        }
        else
            B.push_back(A[i+1]);
    }

    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
     dnode dp[B.size()+1][v+1];
     for(int i=1; i<B.size()+1; i++)
     {
         for(int j=1; j<v+1; j++)
         {
             if(B[i-1].a<=j)
             {
                 if(dp[i][j-B[i-1].a].siz+1>=dp[i-1][j].siz)
                 {
                     int k=1;
                     while(k*B[i-1].a<=j)
                     {
                         if(dp[i][j-k*B[i-1].a].siz+k>=dp[i-1][j].siz)
                         {
                             k++;
                         }
                         else break;

                     }
                     k--;
                     dp[i][j].siz=dp[i][j-k*B[i-1].a].siz+k;
                     dp[i][j].nw=1;
                     dp[i][j].kt=k;
                 }
                 else
                 {
                     dp[i][j].siz=dp[i-1][j].siz;
                     dp[i][j].nw=0;
                     dp[i][j].kt=0;
                 }
             }
             else
             {
                 dp[i][j].siz=dp[i-1][j].siz;
                 dp[i][j].nw=0;
                 dp[i][j].kt=0;
             }
         }
     }
     dnode x=dp[B.size()][v];
    if(x.siz==0)cout<<"-1\n";
    else
    {
        int i,j;
        i=B.size();
        j=v;
        while(x.siz!=0)
        {
            if(x.nw==1)
            {
                for(int k=0; k<x.kt; k++)cout<<B[i-1].n;
                j-=x.kt*B[i-1].a;
                x=dp[i][j];
            }
            else
            {
                i--;
                x=dp[i][j];
            }
        }
    }

}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;
typedef struct
{
    int n;
    int a;
} num;

bool operator<(num const &a, num const &b)
{
    return a.a < b.a;
}

int main()
{
    int v;
    cin>>v;
    vector<num> A;
    num temp;
    for(int i=0; i<9; i++)
    {
        temp.n=i+1;
        cin>>temp.a;
        A.push_back(temp);
    }
    sort(A.begin(),A.begin()+9);
    int j=0;
    vector<num> B;
    int mx=0;
    for(int i=7; i>=0; i--)
    {
        while(A[i].a==A[i+1].a)
        {
            if(A[i].n>mx)mx=A[i].n;
            if(A[i+1].n>mx)mx=A[i+1].n;
            i--;
        }
        temp.a=A[i+1].a;
        temp.n=mx;
        B.push_back(temp);
        mx=0;
    }

    if(A[0].a!=A[1].a)B.push_back(A[0]);
    sort(B.begin(),B.end());
    for(int i=0;i<B.size();i++){
        cout<<B[i].a<<" "<<B[i].n<<endl;
    }
    vector<int> dp[B.size()+1][v+1];
    for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
            if(B[i-1].a<=j)
            {
                if(dp[i][j-B[i-1].a].size()+1>=dp[i-1][j].size())
                {
                    int k=1;
                    while(k*B[i-1].a<=j)
                    {
                        if(dp[i][j-k*B[i-1].a].size()+k>=dp[i-1][j].size())
                        {
                            k++;
                        }
                        else break;

                    }
                    k--;
                    dp[i][j]=dp[i][j-k*B[i-1].a];
                    for(int p=0; p<k; p++)dp[i][j].push_back(B[i-1].n);
                }
                else
                {
                    dp[i][j]=dp[i-1][j];
                }
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
     vector<int> tem;
   for(int i=1; i<B.size()+1; i++)
    {
        for(int j=1; j<v+1; j++)
        {
    tem=dp[i][j];
    if(tem.size()==0)cout<<"-1\n";
    else
        for(int i=tem.size()-1; i>=0; i--)cout<<tem[i];
        cout<<"\t";
        }
        cout<<endl;}
}


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
   for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

  if (v[0].first>n) {cout<<-1; return 0;}

 int i=0;
 do { int k=n/v[0].first;
     // if (n%v[0].first==0) {for (int i=0;i<n/v[0].first;i++)
       //                     cout<<v[0].second; return 0;}

      int ind=v[0].second; int po=0;
      for (int i=1;i<9;i++)
      { int h=n-v[i].first;
         if (h<0) {break;}
         if (n%v[i].first==0) {for (int w=0;w<n/v[i].first;w++)
                                 cout<<v[i].second; return 0;}

         if (h/v[0].first==k-1) { ind=v[i].second; po=i;}
         else break;
         }
      if (ind!=v[0].second) {cout<<ind; n-=v[po].first;}
      else {for (int w=0;w<n/v[0].first;w++)
                               cout<<v[0].second; return 0;}

     } while(n>0);
}


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
   for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

  if (v[0].first>n) {cout<<-1; return 0;}

 int i=0;
 do { int k=n/v[0].first;
     // if (n%v[0].first==0) {for (int i=0;i<n/v[0].first;i++)
       //                     cout<<v[0].second; return 0;}

      int ind=v[0].second; int po=0;
      for (int i=8;i>0;i--)
      { int h=n-v[i].first;
         if (h<0) {break;}
         if (n%v[i].first==0) {for (int w=0;w<n/v[i].first;w++)
                                 cout<<v[i].second; return 0;}

         if (h/v[0].first==k-1) { ind=v[i].second; po=i;}
         else break;
         }
      if (ind!=v[0].second) {cout<<ind; n-=v[po].first;}
      else {for (int w=0;w<n/v[0].first;w++)
                               cout<<v[0].second; return 0;}

     } while(n>0);
}


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
   for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

  if (v[0].first>n) {cout<<-1; return 0;}

 int i=0;
 do { int k=n/v[0].first;
     // if (n%v[0].first==0) {for (int i=0;i<n/v[0].first;i++)
       //                     cout<<v[0].second; return 0;}

      int ind=v[0].second; int po=0;
      for (int i=1;i<9;i++)
      { int h=n-v[i].first;
         if (h<0) {break;}

        // if (n%v[i].first==0) {for (int w=0;w<n/v[i].first;w++)
          //                       cout<<v[i].second; return 0;}

         if (h/v[0].first==k-1) {  if (ind<v[i].second)
         	                       {ind=v[i].second; po=i;}}
         else break;
         }
      if (ind!=v[0].second) {cout<<ind; n-=v[po].first;}
      else {for (int w=0;w<n/v[0].first;w++)
                               cout<<v[0].second; return 0;}

     } while(n>0);
}


#include <iostream>
using namespace std;
typedef unsigned long long ull;
int main() {
int n,a,x;
cin>>n;
cin>>a;
int m=a, b=1;
for (int i=1;i<9;i++)
{ cin>>x;
  if (x<=m) {m=x; b=i+1;}}
  if (m>n) {cout<<-1; return 0;}
  for (int i=0;i<n/m;i++)
  cout<<b;}


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
   for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

  if (v[0].first>n) {cout<<-1; return 0;}

 int i=0;
 do { int k=n/v[0].first;
      if (n%v[0].first==0) {for (int i=0;i<n/v[0].first;i++)
                            cout<<v[0].second; return 0;}

      int ind=v[0].second; int po=0;
      for (int i=1;i<9;i++)
      { int h=n-v[i].first;
         if (h<0) {break;}
         if (n%v[i].first==0) {for (int w=0;w<n/v[i].first;w++)
                               cout<<v[i].second; return 0;}

         if (h/v[0].first==k-1) { ind=v[i].second; po=i;}
         else break;
         }
      if (ind!=v[0].second) {cout<<ind; n-=v[po].first;}
      else {for (int w=0;w<n/v[0].first;w++)
                               cout<<v[0].second; return 0;}

     } while(n>0);
}


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
   for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

  if (v[0].first>n) {cout<<-1; return 0;}

 int i=0;
 do { int k=n/v[0].first;
     // if (n%v[0].first==0) {for (int i=0;i<n/v[0].first;i++)
       //                     cout<<v[0].second; return 0;}

      int ind=v[0].second; int po=0;
      for (int i=1;i<9;i++)
      { int h=n-v[i].first;
         if (h<0) {break;}
        // if (n%v[i].first==0) {for (int w=0;w<n/v[i].first;w++)
          //                       cout<<v[i].second; return 0;}

         if (h/v[0].first==k-1) { ind=v[i].second; po=i;}
         else break;
         }
      if (ind!=v[0].second) {cout<<ind; n-=v[po].first;}
      else {for (int w=0;w<n/v[0].first;w++)
                               cout<<v[0].second; return 0;}

     } while(n>0);
}


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
 for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

 int i=0; int k;
 do {  k=n/v[0].first; int ind=v[0].second; int nb=n/v[0].first; int po=0;
 	   for (int j=0;j<9;j++)
       { if (n/v[j].first==k) {ind=v[j].second; nb=n/v[j].first; po=j;}
         else break;}
         if (k>0) {u.push_back(make_pair(ind,nb));
                   n-=nb*v[po].first;}
    }
                   while(k>0);

       if (u.size()==0) {cout<<-1; return 0;}

       for (int i=0;i<u.size();i++)
       { for (int j=0;j<u[i].second;j++)
          {cout<<u[i].first;}}
 }


#include <bits/stdc++.h>
using namespace std;

int main()
{int n,x;
 vector<pair <int,int>> v,u;
 cin>>n;
   for (int i=1;i<10;i++)
 {cin>>x; v.push_back(make_pair(x,i));}
 sort(v.begin(),v.end());

  if (v[0].first>n) {cout<<-1; return 0;}

 int i=0;
 do { int k=n/v[0].first;

      int ind=v[0].second; int po=0;
      for (int i=1;i<9;i++)
      { int h=n-v[i].first;
         if (h<0) {break;}

         if (h/v[0].first==k-1) {  if (ind<v[i].second)
         	                       {ind=v[i].second; po=i;}}
         else break;
         }
      if (ind!=v[0].second) {cout<<ind; n-=v[po].first;}
      else {for (int w=0;w<n/v[0].first;w++)
                               cout<<v[0].second; return 0;}

     } while(n>0);
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	ll v; cin>>v;
	ll arr[10];
	for (ll i = 1; i <= 9; ++i)
		cin>>arr[i];
	ll maximum_count = 0;
	ll maximum_digit = -1;
	for (ll i = 9; i >= 1; --i)
	{
		ll count = v/arr[i];
		if(count > maximum_count ||	(maximum_digit != -1 &&count == maximum_count && arr[i] < arr[maximum_digit])){
			maximum_count = count;
			maximum_digit = i;
		}
.   }
	ll left = v - maximum_count * arr[maximum_digit];
	vector<ll> starts;
	for (ll i = 0; i < maximum_count; ++i)
	{
		for (ll i = 9; i > maximum_digit; --i)
		{
			if(left >= arr[i] - arr[maximum_digit])
			{
				starts.push_back(i);
				left -= (arr[i] - arr[maximum_digit]);
				break;
			}
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
	{
		for (ll i = 0; i < starts.size(); ++i)
			cout<<starts[i];
		for (ll i = 1; i <= maximum_count - starts.size(); ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	int v; cin>>v;
	int arr[10];
	for (int i = 1; i <= 9; ++i)
		cin>>arr[i];
	int maximum_count = 0;
	int maximum_digit = -1;
	for (int i = 9; i >= 1; --i)
	{
		int count = v/arr[i];
		if(count > maximum_count){
			maximum_count = count;
			maximum_digit = i;
		}
	}
	int left = v - maximum_count * arr[maximum_digit];
	int first = maximum_digit;
	for (int i = 9; i > maximum_digit; --i)
	{
		if(left >= arr[i] - arr[maximum_digit])
		{
			first = i;
			break;
		}
	}

	if(maximum_digit == -1)
		cout<<-1;
	else{
		cout<<first;
		for (int i = 1; i < maximum_count; ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	ll v; cin>>v;
	ll arr[10];
	for (ll i = 1; i <= 9; ++i)
		cin>>arr[i];
	ll maximum_count = 0;
	ll maximum_digit = -1;
	for (ll i = 9; i >= 1; --i)
	{
		ll count = v/arr[i];
		if(count > maximum_count){
			maximum_count = count;
			maximum_digit = i;
		}
	}
	ll left = v - maximum_count * arr[maximum_digit];
	vector<ll> starts;
	for (ll i = 0; i < maximum_count; ++i)
	{
		for (ll i = 9; i > maximum_digit; --i)
		{
			if(left >= arr[i] - arr[maximum_digit])
			{
				starts.push_back(i);
				left -= (arr[i] - arr[maximum_digit]);
				break;
			}
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
	{
		for (ll i = 0; i < starts.size(); ++i)
			cout<<starts[i];
		for (ll i = 1; i <= maximum_count - starts.size(); ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	ll v; cin>>v;
	ll arr[10];
	for (ll i = 1; i <= 9; ++i)
		cin>>arr[i];
	ll maximum_count = 0;
	ll maximum_digit = -1;
	for (ll i = 9; i >= 1; --i)
	{
		ll count = v/arr[i];
		if(count > maximum_count ||	(count == maximum_count && arr[i] < arr[maximum_digit])){
			maximum_count = count;
			maximum_digit = i;
		}
.   }
	ll left = v - maximum_count * arr[maximum_digit];
	vector<ll> starts;
	for (ll i = 0; i < maximum_count; ++i)
	{
		for (ll i = 9; i > maximum_digit; --i)
		{
			if(left >= arr[i] - arr[maximum_digit])
			{
				starts.push_back(i);
				left -= (arr[i] - arr[maximum_digit]);
				break;
			}
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
	{
		for (ll i = 0; i < starts.size(); ++i)
			cout<<starts[i];
		for (ll i = 1; i <= maximum_count - starts.size(); ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	int v; cin>>v;
	int arr[10];
	for (int i = 1; i <= 9; ++i)
		cin>>arr[i];
	int maximum_count = 0;
	int maximum_digit = -1;
	for (int i = 9; i >= 1; --i)
	{
		int count = v/arr[i];
		if(count > maximum_count){
			maximum_count = count;
			maximum_digit = i;
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
		for (int i = 0; i < maximum_count; ++i)
			cout<<maximum_digit;
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	int v; cin>>v;
	int arr[10];
	for (int i = 1; i <= 9; ++i)
		cin>>arr[i];
	int maximum_count = 0;
	int maximum_digit = -1;
	for (int i = 9; i >= 1; --i)
	{
		int count = v/arr[i];
		if(count > maximum_count){
			maximum_count = count;
			maximum_digit = i;
		}
	}
	int left = v - maximum_count * arr[maximum_digit];
	int first = maximum_digit;
	vector<int> starts;
	for (int i = 0; i < maximum_count; ++i)
	{
		for (int i = 9; i > maximum_digit; --i)
		{
			if(left >= arr[i] - arr[maximum_digit])
			{
				first = i;
				starts.push_back(i);
				left -= (arr[i] - arr[maximum_digit]);
				break;
			}
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
	{
		for (int i = 0; i < starts.size(); ++i)
			cout<<starts[i];
		for (int i = 1; i <= maximum_count - starts.size(); ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	ll v; cin>>v;
	ll arr[10];
	for (ll i = 1; i <= 9; ++i)
		cin>>arr[i];
	ll maximum_count = 0;
	ll maximum_digit = -1;
	for (ll i = 9; i >= 1; --i)
	{
		ll count = v/arr[i];
		if(count > maximum_count ||	(maximum_digit != -1 &&count == maximum_count && arr[i] < arr[maximum_digit])){
			maximum_count = count;
			maximum_digit = i;
		}
  }
	ll left = v - maximum_count * arr[maximum_digit];
	vector<ll> starts;
	for (ll i = 0; i < maximum_count; ++i)
	{
		for (ll i = 9; i > maximum_digit; --i)
		{
			if(left >= arr[i] - arr[maximum_digit])
			{
				starts.push_back(i);
				left -= (arr[i] - arr[maximum_digit]);
				break;
			}
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
	{
		for (ll i = 0; i < starts.size(); ++i)
			cout<<starts[i];
		for (ll i = 1; i <= maximum_count - starts.size(); ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	int v; cin>>v;
	int arr[10];
	for (int i = 1; i <= 9; ++i)
		cin>>arr[i];
	int maximum_count = 0;
	int maximum_digit = -1;
	for (int i = 9; i >= 1; --i)
	{
		int count = v/arr[i];
		if(count > maximum_count){
			maximum_count = count;
			maximum_digit = i;
		}
	}
	int left = v - maximum_count * maximum_digit;
	int first = maximum_digit;
	for (int i = 9; i > maximum_digit; --i)
	{
		if(left >= arr[i] - arr[maximum_digit])
		{
			first = i;
			break;
		}
	}

	if(maximum_digit == -1)
		cout<<-1;
	else{
		cout<<first;
		for (int i = 1; i < maximum_count; ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed<<setprecision(12);
	ll v; cin>>v;
	ll arr[10];
	for (ll i = 1; i <= 9; ++i)
		cin>>arr[i];
	ll maximum_count = 0;
	ll maximum_digit = -1;
	for (ll i = 9; i >= 1; --i)
	{
		ll count = v/arr[i];
		if(count > maximum_count ||	(count == maximum_count && arr[i] < arr[maximum_digit])){
			maximum_count = count;
			maximum_digit = i;
		}
 }
	ll left = v - maximum_count * arr[maximum_digit];
	vector<ll> starts;
	for (ll i = 0; i < maximum_count; ++i)
	{
		for (ll i = 9; i > maximum_digit; --i)
		{
			if(left >= arr[i] - arr[maximum_digit])
			{
				starts.push_back(i);
				left -= (arr[i] - arr[maximum_digit]);
				break;
			}
		}
	}
	if(maximum_digit == -1)
		cout<<-1;
	else
	{
		for (ll i = 0; i < starts.size(); ++i)
			cout<<starts[i];
		for (ll i = 1; i <= maximum_count - starts.size(); ++i)
			cout<<maximum_digit;
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

void solve(int a[],int v,string k,int* ans){
    if(v==0||v<*min_element(a+1,a+10)){
        if(k.length()==0) return;
        int x = stoi(k);
        *ans = max(*ans,x);
    }
    for(int i=1;i<=9;i++){
        if(a[i]<=v){
            k+='0'+i;
            solve(a,v-a[i],k,ans);
            k.pop_back();
        }
    }
}

int main(){
    int v;
    cin>>v;
    int a[10];
    for(int i=1;i<=9;i++){
        cin>>a[i];
    }
    string k;
    int ans=-1;
    solve(a,v,k,&ans);
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int v;
    cin>>v;
    int a[10];
    int max_num=INT_MAX;
    int ans2=0;
    for(int i=1;i<=9;i++){
        cin>>a[i];
        if(a[i]<=max_num){
            max_num=a[i];
            ans2 = i;
        }
    }
    int max_x=-1;
    int ans=0;
    for(int i=1;i<=9;i++){
         int x = 1;
         if(v-a[i]<0){
            continue;
         }
         x+=(v-a[i])/(*min_element(a+1,a+10));
         if(x>=max_x){
             max_x=x;
            ans = i;
         }
    }
    if(ans==0){
        cout<<-1<<endl;
    }
    else{
        cout<<ans;
        v-=a[ans];
        while(v-a[ans2]>=0){
            cout<<ans2;
            v-=a[ans2];
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

void solve(int a[],int v,string k,int* ans){
    if(v==0||v<*min_element(a+1,a+10)){
        if(k.length()==0) return;
        int x = stoi(k);
        *ans = max(*ans,x);
    }
    for(int i=1;i<=9;i++){
        if(a[i]<=v){
            k+='0'+i;
            solve(a,v-a[i],k,ans);
            k.pop_back();
        }
    }
}

int main(){
    int v;
    cin>>v;
    int a[10];
    for(int i=1;i<=9;i++){
        cin>>a[i];
    }
    string k;
    int ans=0;
    solve(a,v,k,&ans);
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int v;
    cin>>v;
    int a[10];
    int max_num=INT_MAX;
    int ans2=0;
    for(int i=1;i<=9;i++){
        cin>>a[i];
        if(a[i]<=max_num){
            max_num=a[i];
            ans2 = i;
        }
    }
    int max_x=-1;
    int ans=0;
    for(int i=1;i<=9;i++){
         int x = 1;
         if(v-a[i]<0){
            continue;
         }
         x+=(v-a[i])/(*min_element(a+1,a+10));
         if(x>=max_x){
             max_x=x;
            ans = i;
         }
    }
    if(ans==0){
        cout<<-1<<endl;
    }
    else{
        cout<<ans;
        v-=a[ans];
        while(v-ans2>=0){
            cout<<ans2;
            v-=ans2;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int v;
    cin>>v;
    int a[10];
    for(int i=1;i<=9;i++){
        cin>>a[i];
    }
    int max_x=-1;
    int ans=0;
    for(int i=1;i<=9;i++){
         int x = 1;
         if(v-a[i]<0){
            continue;
         }
         x+=(v-a[i])/(*min_element(a+1,a+10));
         if(x>=max_x){
             max_x=x;
            ans = i;
         }
    }
    if(ans==0){
        cout<<-1<<endl;
    }
    else{
        cout<<ans;
        v-=a[ans];
        while(v>0){
            int x = min_element(a+1,a+10)-a;
            cout<<x;
            v-=*min_element(a+1,a+10);
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

void solve(int a[],int v,string k,long long int* ans){
    if(v==0||v<*min_element(a+1,a+10)){
        if(k.length()==0) return;
        long long int x = stoi(k);
        *ans = max(*ans,x);
    }
    for(int i=1;i<=9;i++){
        if(a[i]<=v){
            k+='0'+i;
            solve(a,v-a[i],k,ans);
            k.pop_back();
        }
    }
}

int main(){
    int v;
    cin>>v;
    int a[10];
    for(int i=1;i<=9;i++){
        cin>>a[i];
    }
    string k;
    long long int ans=-1;
    solve(a,v,k,&ans);
    cout<<ans<<endl;

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int v;
    cin>>v;
    int a[10];
    int min_val=INT_MAX;
    for(int i=1; i<=9; i++)
    {
        cin>>a[i];
        min_val =min(min_val,a[i]);
    }
    int max_len = v/min_val;
    if(max_len==0)
    {
        cout<<-1<<endl;
    }
    else
    {
        int t =1;
        for(int i=9; i>=1; i--)
        {
            while(v-a[i]>=0&&(v-a[i])/min_val==max_len-t)
            {
                cout<<i;
                v-=a[i];
                t++;
            }
        }
    }

}


#include<iostream>
using namespace std;
int main()
{
    int v;
    cin>>v;
    double r=1000000,a;
    int digit,cost;
    for(double i=1;i<=9;i++)
    {
        cin>>a;
        if(a/i<=r)
        {
            r=a/i;
            digit=i;
            cost=a;

        }
    }
    if(v<a)
    cout<<-1;
    else
    {
        while(v>=a)
        {
            cout<<digit;
            v-=a;
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    int v;
    cin>>v;
    int a[10]={0};
    a[0]=1000000;
    int min;
    for(int i=1;i<=9;i++)
    {
        cin>>a[i];
        if(a[i]<=a[min])min=i;
    }
    int d = v/a[min];
    if(d==0)
    cout<<-1;
    else
    {
        int no[d];
        for(int i=0;i<d;i++)
        no[i]=min;
        int b= v-d*a[min];
        int k=0;
        while(b>0)
        {
            b+=a[min];
            for(int i=9;i>min;i--)
            {
                if(b>=a[i])
                {
                    b-=a[i];
                    no[k++]=i;
                    break;
                }
                if(i==min+1)
                b=0;
            }
        }
        for(int i=0;i<d;i++)
        cout<<a[i];
    }

}


#include<iostream>
using namespace std;
int main()
{
    int v;
    cin>>v;
    double r=1000000,a;
    int digit,cost;
    for(double i=1;i<=9;i++)
    {
        cin>>a;
        if(a/i<=r)
        {
            r=a/i;
            digit=i;
            cost=a;

        }
    }
    if(v<a)
    cout<<-1;
    else
    {
        while(v>=a)
        {
            cout<<i;
            v-=a;
        }
    }
}