#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using str = string;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<str>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vpi = vector<pair<int,int>>;
#define rsz resize
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) begin(x),end(x)
#define sor(x) sort(begin(x),end(x));
#define FOR(i,a,b) for(ll i=a; i<(ll)b; ++i)
#define ROF(i,a,b) for(ll i=a-1; i>=b; --i)
#define TRAV(a, x) for(auto& a:x)
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define u_map unordered_map
#define u_set unordered_set
#define u_multiset unordered_multiset
void setPrec() { cout << fixed << setprecision(15); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void setIO(str s = "") {
    unsyncIO(); setPrec();
    if(sz(s)) setIn(s+".in"), setOut(s+".out");
}

int main() {
	setIO();
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll cyan = a, red = 0;
	FOR(i,1,a+1) {  // no more than A 
		// A+Bx <= D * Cx --> x = A/(CD-B) -> no more than a
		cyan += b;
		red += c;
		if(cyan <= d*red) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

template<typename T>
vector<T> dijkstra(int s,vector<vector<pair<int,T>>> &G){
    const T TINF=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n=G.size();
    vector<T> d(n,TINF);
    vector<int> b(n,-1);//previous point
    priority_queue<P,vector<P>,greater<P>> q;
    d[s]=0;
    q.emplace(d[s],s);
    while(!q.empty()){
        P p=q.top();q.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.first;
            T c=e.second;
            if(d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                q.emplace(d[u],u);
            }
        }
    }
    return d;
}

template<typename T>
struct edge{
    int src,to;//src source
    T cost;
    edge(int to,T cost):src(-1),to(to),cost(cost){}
    edge(int src,int to,T cost):src(src),to(to),cost(cost){}
};
 
//空を返したら負のループ
template<typename T>
vector<T> BellmanFord(vector<edge<T>> &edges,int V,int s){
    const auto TINF=numeric_limits<T>::max();
    vector<T> dist(V,TINF);
    dist[s]=0;
    for(int i=0;i<V-1;i++){
        for(auto &e:edges){
            if(dist[e.src]==TINF) continue;
            dist[e.to]=min(dist[e.to],dist[e.src]+e.cost);
        }
    }
    for(auto &e:edges){
        if(dist[e.src]==TINF) continue;
        if(dist[e.src]+e.cost<dist[e.to]) return vector<T>();
    }
    return dist;
}



signed main(){
    int n,m;cin>>n>>m;
    vector<ll> w(n);
    cin>>w;
    vector<pair<ll,ll>> b(m);
    rep(i,m){
        ll l,v;cin>>l>>v;
        b[i]={v,l};// weight, length
        for(auto &a:w){
            if(a>v){
                cout<<-1<<endl;
                return 0;
            }
        }
    }

    sort(ALL(b),[](pair<ll,ll> lhs,pair<ll,ll> rhs){
        if(lhs.first==rhs.first) return lhs.second>rhs.second;
        return lhs.first<rhs.first;
    });
    vector<pair<ll,ll>> bridge;
    rep(i,m){
        if(bridge.empty() or bridge.back().second<b[i].second) bridge.push_back(b[i]);
    }

    ll res=LINF;
    vector<int> ord(n);
    iota(ALL(ord),0);
    do{
        vector<vector<pair<int,ll>>> g(n);
        rep(i,n){
            int u=ord[i];
            ll wsum=w[u];
            for(int j=i+1;j<n;j++){
                int v=ord[j];
                wsum+=w[v];
                auto ite=lower_bound(ALL(bridge),make_pair(wsum,-LINF));
                ll cost=(ite==bridge.begin()?0ll:prev(ite)->second);
                g[i].push_back({j,cost});
            }
        }
        vector<ll> d(n,0);
        d[0]=0;
        rep(i,n){
            for(auto [to,c]:g[i]){
                chmax(d[to],d[i]+c);
            }
        }
        chmin(res,d[n-1]);
    }while(next_permutation(ALL(ord)));
    cout<<res<<endl;
    return 0;
}
