#include <bits/stdc++.h>
using namespace std;
#define int int64_t
const int MAXN = int(3e5) + 10;
vector<int> a(MAXN);
vector<int> pref(MAXN, 0);
int t;
int get(int l, int r, int ind) {
    int sum = pref[r] - pref[l - 1];
    if (sum > t) {
        return -1;
    }
    return r - l + 1 + (t - sum) / a[ind];
}
void solve() {
    int n, m;
    cin >> n >> m >> t;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    vector<int> lf(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        lf[i] = i - 1;
        while (lf[i] > 0) {
            if (a[lf[i]] <= a[i]) {
                break;
            }
            lf[i] = lf[lf[i]];
        }
    }
    vector<int> rf(n + 1, n + 1);
    for (int i = n; i >= 1; i--) {
        rf[i] = i + 1;
        while (rf[i] <= n) {
            if (a[rf[i]] <= a[i]) {
                break;
            }
            rf[i] = rf[rf[i]];
        }
    }
    vector<int> dp(n + 1, 0);
    int ans = 0;
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (lf[i] == 0) {
            dp[i] = i;
            continue;
        }
        int ss1 = get(dp[lf[i]], i, dp[lf[i]]);
        int ss2 = get(lf[i], i, lf[i]);
        int ss3 = get(i, i, i);
        if (ss3 > ss1 && ss3 > ss2) {
            dp[i] = i;
            continue;
        }
        if (ss2 > ss1 && ss2 > ss3) {
            dp[i] = lf[i];
            continue;
        }
        dp[i] = dp[lf[i]];
    }
    vector<int> suf(n + 2);
    suf[n] = n;
    for (int i = n - 1; i >= 1; i--) {
        if (rf[i] == n + 1) {
            suf[i] = i;
            continue;
        }
        int ss1 = get(i, suf[rf[i]], suf[rf[i]]);
        int ss2 = get(i, rf[i], rf[i]);
        int ss3 = get(i, i, i);
        if (ss3 >= ss1 && ss3 >= ss2) {
            suf[i] = i;
            continue;
        }
        if (ss2 >= ss1 && ss2 >= ss3) {
            suf[i] = rf[i];
            continue;
        }
        suf[i] = suf[rf[i]];
    }
    for (int j = 0; j < m; j++) {
        int i = b[j];
        ans = max(ans, get(i, i, i));
        ans = max(ans, get(dp[i], i, dp[i]));
        ans = max(ans, get(i, suf[i], suf[i]));
    }
    cout << ans;
}
int32_t main() {
    /*ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
