#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]];
        }
    }
    int lst = 0;
    int ans = 0;
    for (int i = 0; i < m; i++) {
        int ind = b[i];
        while (ind > lst) {
            ans = max(ans, get(ind, b[i], ind));
            ind = lf[ind];
        }
        lst = b[i];
    }
    lst = n + 1;
    for (int i = m - 1; i >= 0; i--) {
        int ind = b[i];
        while (ind < lst) {
            ans = max(ans, get(b[i], ind, ind));
            ind = rf[ind];
        }
        lst = b[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();
    }
}
