#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <assert.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<typename T>
istream& operator>>(istream& in, vector<T>& arr) {
    for (ll i = 0; i < (ll)arr.size(); ++i) {
        in >> arr[i];
    }
    return in;
}

template<typename T>
ostream& operator<<(ostream& out, vector<T>& arr) {
    for (auto el : arr) {
        out << el;
    }
    return out;
}
const ll INF = 1e18;

struct el {
    ll mn = INF;
    ll id = -1;
};

struct segmentTree {
    vector<el> tree;

    el merge(el left, el right) {
        if (left.mn < right.mn) {
            return {left};
        }
        return right;
    }

    void build(ll v, ll l, ll r, vector<ll>& arr) {
        if (l + 1 == r) {
            tree[v] = {arr[l], l};
            return;
        }
        ll mid = (l + r) / 2;
        build(2 * v, l, mid, arr);
        build(2 * v + 1, mid, r, arr);
        tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
    }

    segmentTree(vector<ll>& arr) {
        ll n = arr.size();
        tree.resize(4 * n);
        build(1, 0, n, arr);
    }

    el get(ll v, ll l, ll r, ll ql, ll qr) {
        if (r <= ql || qr <= l) {
            return {};
        }
        if (ql <= l && r <= qr) {
            return tree[v];
        }
        ll mid = (l + r) / 2;
        return merge(get(2 * v, l, mid, ql, qr), get(2 * v + 1, mid, r, ql, qr));
    }
};

ll f(vector<ll>& pref, vector<ll>& crr, vector<ll>& arr, ll mid, ll t, ll i) {
    ll sum = pref[crr[i]] - pref[crr[i] - mid];
    ll cnt = max(0ll, t - sum) / arr[crr[i] - mid];
    if (t - sum >= 0) {
        return cnt + mid;
    }
    return 0;
}

ll f2(vector<ll>& pref, vector<ll>& crr, vector<ll>& arr, ll mid, ll t, ll i) {
    ll sum = pref[crr[i] + mid - 1] - pref[crr[i] - 1];
    ll cnt = max(0ll, t - sum) / arr[crr[i] + mid - 2];
    if (t - sum >= 0) {
        return cnt + mid;
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, m, t;
    cin >> n >> m >> t;
    vector<ll> arr(n), brr(m);
    cin >> arr >> brr;
    vector<ll> crr = brr;
    reverse(brr.begin(), brr.end());
    brr.push_back(0);
    reverse(brr.begin(), brr.end());
    brr.push_back(n);
    vector<ll> pref(1, 0);
    for (auto el : arr) {
        pref.push_back(pref.back() + el);
    }
    segmentTree segm(arr);
    vector<el> all;
    for (ll i = 1; i <= m + 1; ++i) {
        all.push_back(segm.get(1, 0, n, brr[i - 1], brr[i]--));
    }
    ll ans = 0;
    for (ll i = 0; i + 1 < (ll)all.size(); ++i) {
        ll l = 1, r = crr[i] - all[i].id;
        while(r - l > 1) {
            ll mid = (l + r) / 2;
            if (f(pref, crr, arr, mid, t, i) < f(pref, crr, arr, mid + 1, t, i)) {
                r = mid + 1;
            } else {
                l = mid - 1;
            }
        }
        for (ll j = l; j <= r; ++j) {
            ans = max(ans, f(pref, crr, arr, j, t, i));
        }
        l = 1, r = all[i + 1].id - crr[i] + 2;
        while(r - l > 1) {
            ll mid = (l + r) / 2;
            if (f2(pref, crr, arr, mid, t, i) < f2(pref, crr, arr, mid + 1, t, i)) {
                r = mid + 1;
            } else {
                l = mid - 1;
            }
        }
        for (ll j = l; j <= r; ++j) {
            ans = max(ans, f2(pref, crr, arr, j, t, i));
        }
    }
    cout << ans;
}