#include <bits/stdc++.h>
#define ll long long
#define len(x) (int)x.size()
#define ld long double
#define all(x) x.begin(), x.end()
const ll mod1 = 1e9 + 7;

using namespace std;

void print(vector<int> &a){
    for(auto x : a){
        cout << x << ' ';
    }
    cout << '\n';
}

void print(vector<ll> &a){
    for(auto x : a){
        cout << x << ' ';
    }
    cout << '\n';
}

void print(vector<char> &a){
    for(auto x : a){
        cout << x << ' ';
    }
    cout << '\n';
}

void print(vector<string> &a){
    for(auto x : a){
        cout << x << ' ';
    }
    cout << '\n';
}

void print(vector<pair<int, int>> &a){
    for(auto x : a){
        cout << x.first << ' ' << x.second << '\n';
    }
}

void print(vector<vector<int>> &a){
    for(auto x : a){
        print(x);
    }
}

void print(vector<vector<ll>> &a){
    for(auto x : a){
        print(x);
    }
}

//#define int ll
//#define mtask

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n);
    vector<ll> pref(n + 1);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        pref[i + 1] = pref[i] + a[i];
    }
    vector<int> b(m);
    for(int i = 0; i < m; ++i){
        cin >> b[i];
        --b[i];
    }

    auto get = [&](int st, int j){
        if(st > j){
            if(pref[st + 1] - pref[j + 1] > t) return (int)-1e9;
            return st - j + (t - (int)(pref[st + 1] - pref[j + 1])) / a[j];
        }
        else{
            if(pref[j] - pref[st] > t) return (int)-1e9;
            return j - st + (t - (int)(pref[j] - pref[st])) / a[j];
        }
    };

    int ans = 0;
    int ptr = 0;
    int pr = 0;
    for(int i = 0; i < m; ++i){
        while(pr <= b[i]){
            if(get(b[i], ptr) < get(b[i], pr)){
                ptr = pr;
            }
            ++pr;
        }
        ans = max(ans, get(b[i], ptr));
    }
    pr = n - 1;
    for(int i = m - 1; i >= 0; --i){
        while(pr >= b[i]){
            if(get(b[i], ptr) < get(b[i], pr)){
                ptr = pr;
            }
            --pr;
        }
        ans = max(ans, get(b[i], ptr));
    }
    cout << ans << '\n';

}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
#ifdef mtask
    int tt;
    cin >> tt;
    while(tt--)
#endif
        solve();
}