#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define ll long long

vector<ll> pref;
vector<ll> a;

ll sum(ll l, ll r) {
    if (l > r) {
        return 0;
    }
    if (l == 0) {
        return pref[r];
    }
    return pref[r] - pref[l - 1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m, t;
    cin >> n >> m >> t;
    a.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> b(m);
    for (ll i = 0; i < m; i++) {
        cin >> b[i];
        b[i]--;
    }
    pref.resize(n);
    pref[0] = a[0];
    for (ll i = 1; i < n; i++) {
        pref[i] = pref[i - 1] + a[i];
    }
    ll answer = 0;
    for (ll i = 0; i < m; i++) {
        if (b[i] > t) {
            continue;
        }
        answer = max(answer, t / a[b[i]]);
        ll l = i;
        ll r = n - (m - i);
        ll l1 = l - 1;
        ll r1 = b[i];
        while (r1 - l1 > 1) {
            ll m1 = (l1 + r1) / 2;
            if (sum(m1, b[i]) <= t) {
                r1 = m1;
            } else {
                l1 = m1;
            }
        }
        for (ll i1 = r1; i1 <= b[i]; i1++) {
            ll answer1 = b[i] - i1;
            ll sum1 = t - sum(i1 + 1, b[i]);
            answer1 += sum1 / a[i1];
            answer = max(answer, answer1);
        }
        l1 = b[i] - 1;
        r1 = r + 1;
        while (r1 - l1 > 1) {
            ll m1 = (l1 + r1) / 2;
            if (sum(b[i], m1) <= t) {
                l1 = m1;
            } else {
                r1 = m1;
            }
        }
        for (ll i1 = b[i]; i1 <= l1; i1++) {
            ll answer1 = i1 - b[i];
            ll sum1 = t - sum(b[i], i1 - 1);
            answer1 += sum1 / a[i1];
            answer = max(answer, answer1);
        }
    }
    cout << answer;
}