#include <bits/stdc++.h>

using namespace std;
using ll = long long;

pair<ll,ll> tree[1200002]; //

vector<ll> a;

void build(ll i,ll l,ll r){
    if (r-l==1){
        tree[i] = {l,l};
        return;
    }
    ll m = (r+l)/2;
    build(i*2+1,l,m);
    build(i*2+2,m,r);
    auto [i1,i2] = tree[i*2+1];
    auto [j1,j2] = tree[i*2+2];
    if (a[i1] == a[j1]){
        tree[i] = {i1,j2};
        return;
    }
    if (a[i1]<a[j1]){
        tree[i] = {i1,i2};
    }else{
        tree[i] = {j1,j2};
    }
}

ll search(ll i,ll l,ll r,ll q_l,ll q_r){
    if (r<=q_l || q_r<=l){
        return a.size()-1;
    }
    if (q_l <= l && r<= q_r){
        return tree[i].first;
    }
    ll m = (r+l)/2;
    ll i1 = search(i*2+1,l,m,q_l,q_r);
    ll i2 = search(i*2+2,m,r,q_l,q_r);
    if (a[i1]<a[i2]){
        return i1;
    }else{
        return i2;
    }
}

ll search_left(ll i,ll l,ll r,ll val){
    if (r-l==1){
        return tree[i].first;
    }
    ll m = (r+l)/2;
    if (a[tree[i].first]>=val){
        return a.size()-1;
    }
    if (a[tree[i*2+1].first]<val){
        return search_left(i*2+1,l,m,val);
    }else{
        return search_left(i*2+2,m,r,val);
    }
}

ll search1(ll i,ll l,ll r,ll q_l,ll q_r,ll val){
    if (r<=q_l || q_r<=l){
        return a.size()-1;
    }
    if (q_l <= l && r<=q_r){
        return search_left(i,l,r,val);
    }
    ll m = (r+l)/2;
    ll i1 = search1(i*2+1,l,m,q_l,q_r,val);
    ll i2 = search1(i*2+2,m,r,q_l,q_r,val);
    if (a[i1]<val){
        return i1;
    }else{
        return i2;
    }
}

// ===================

ll search_right(ll i,ll l,ll r,ll val){
    if (r-l==1){
        return tree[i].second;
    }
    ll m = (r+l)/2;
    if (a[tree[i].first]>=val){
        return a.size()-1;
    }
    if (a[tree[i*2+2].second]<val){
        return search_right(i*2+2,m,r,val);
    }else{
        return search_right(i*2+1,l,m,val);
    }
}

ll search2(ll i,ll l,ll r,ll q_l,ll q_r,ll val){
    if (r<=q_l || q_r<=l){
        return a.size()-1;
    }
    if (q_l <= l && r<=q_r){
        return search_right(i,l,r,val);
    }
    ll m = (r+l)/2;
    ll i1 = search2(i*2+1,l,m,q_l,q_r,val);
    ll i2 = search2(i*2+2,m,r,q_l,q_r,val);
    if (a[i2]<val){
        return i2;
    }else{
        return i1;
    }
}

int main(){
    ll n,m,t;
    cin >> n >> m >> t;
    a.resize(n);
    a.push_back(INT_MAX);
    vector<ll> b(m);
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    for (ll i=0;i<m;i++){
        cin >> b[i];
        b[i]--;
    }

    build(0,0,n);

    vector<ll> left(n),right(n);

    for (ll i=0;i<n;i++){
        left[i] = search2(0,0,n,0,i,a[i]);
        right[i] = search1(0,0,n,i+1,n,a[i]);
    }

    vector<ll> pref(n+1,0);
    for (ll i=0;i<n;i++){
        pref[i+1] = pref[i] + a[i];
    }
    ll ans = 0;
    ll last = right[b[0]];

    for (auto i : b){
        ans = max(ans,t/a[i]);
        ll i1 = right[i];
        while (i1!=n){
            ll sum = pref[i1+1] - pref[i];
            // cout << i1 << ' ' << sum << endl;
            ll ans1 = 0;
            if (t>=sum){
                ans1 += i1-i+1;
                ans1 += (t-sum)/a[i1];
            }else{
                break;
            }
            i1 = right[i1];
            ans = max(ans,ans1);    
        }
        i1 = left[i];
        while (i1!=n){
            ll sum = pref[i+1] - pref[i1];
            ll ans1 = 0;
            if (t>=sum){
                ans1 += i-i1+1;
                ans1 += (t-sum)/a[i1];
            }else{
                break;
            }
            ans = max(ans,ans1);
            // cout << '?' << ans1 << endl;
            i1 = left[i1];
        }
    }
    cout << ans;
}