#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];
}

ll f(ll ind1, ll ind2, ll t) {
    if (ind1 == ind2) {
        return t / a[ind1];
    }
    if (ind1 < ind2) {
        ll answer = ind2 - ind1;
        ll sum1 = t - sum(ind1 + 1, ind2);
        if (sum1 < 0) {
            return 0;
        }
        answer += sum1 / a[ind1];
        return answer;
    } else {
        ll answer = ind1 - ind2;
        ll sum1 = t - sum(ind2, ind1 - 1);
        if (sum1 < 0) {
            return 0;
        }
        answer += sum1 / a[ind1];
        return answer;
    }
}

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++) {
        answer = max(answer, t / a[b[i]]);
        ll l1 = -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;
            }
        }
        ll l2 = r1;
        ll r2 = b[i];
        while (r2 - l2 > 2) {
            ll m1 = l2 + (r2 - l2) / 2;
            ll m2 = r2 - (r2 - l2) / 2;
            if (f(m1, b[i], t) < f(m2, b[i], t)) {
                l2 = m1;
            } else {
                r2 = m2;
            }
        }
        for (ll i1 = -1000; i1 <= 1000; i1++) {
            if (l2 + i1 >= r1 && l2 + i1 <= b[i]) {
                answer = max(answer, f(l2 + i1, b[i], t));
            }
        }
        l1 = b[i] - 1;
        r1 = n;
        while (r1 - l1 > 1) {
            ll m1 = (l1 + r1) / 2;
            if (sum(b[i], m1) <= t) {
                l1 = m1;
            } else {
                r1 = m1;
            }
        }
        l2 = b[i];
        r2 = l1;
        while (r2 - l2 > 2) {
            ll m1 = l2 + (r2 - l2) / 2;
            ll m2 = r2 - (r2 - l2) / 2;
            if (f(m1, b[i], t) < f(m2, b[i], t)) {
                l2 = m1;
            } else {
                r2 = m2;
            }
        }
        for (ll i1 = -1000; i1 <= 1000; i1++) {
            if (l2 + i1 >= b[i] && l2 + i1 <= l1) {
                answer = max(answer, f(l2 + i1, b[i], t));
            }
        }
    }
    cout << answer;
}