#include <bits/stdc++.h>

using namespace std;

int n, m, t;

int getl(int ind, vector<int>& a) {
    int ans = 0;
    int cur = 0;
    for (int i = ind; i >= 0; i--) {
        if (cur >= t) break;
        ans = max(ans, ind - i + (t - cur) / a[i]);
        cur += a[i];
    }
    return ans;
}

int getr(int ind, vector<int>& a) {
    int ans = 0;
    int cur = 0;
    int last = 0, lastt = 0, f = 0;
    for (int i = ind; i < n; i++) {
        if (cur >= t) break;
        //cout << i - ind + (t - cur) / a[i] << ' ';
        ans = max(ans, i - ind + (t - cur) / a[i]);
        int lastt = i - ind + (t - cur) / a[i];
        cur += a[i];
        if (last <= lastt && !f) {
            last = lastt;
            continue;
        }
        if (last > lastt && !f) {
            f = 1;
        }
        if (last >= lastt && f) {
            last = lastt;
            continue;
        }
        exit(1);
    }
    return ans;
}

long long get(int ind, vector<long long>& pref, vector<pair<int, int>>& sa) {
    long long ans = 0;
    for (auto [val, i] : sa) {
        long long cur = 0;
        if (ind < i) cur = pref[i] - pref[ind];
        else cur = pref[ind + 1] - pref[i + 1];
        ans = max(ans, abs(i - ind) + (t - cur) / val);
    }
    return ans;
}

int get(int st, int ind, vector<int>& a, vector<long long>& pref) {
    long long summ = 0;
    if (ind > st) summ = pref[ind] - pref[st];
    else summ = pref[st + 1] - pref[ind + 1];
    if ((t - summ) <= 0) return -1;
    return abs(ind - st) + (t - summ) / a[ind];
}

void solve1() {
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    for (auto& i : b) i--;
    int ans = 0;
    for (int it = 0; it < m; it++) {
        //cout << getl(b[it], a) << ' ' << getr(b[it], a) << '\n';
        ans = max(getl(b[it], a), ans);
        ans = max(getr(b[it], a), ans);
        //cout <<'\n';
    }
    cout << ans << '\n';
}

void solve() {
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    for (auto& i : b) i--;
    vector<long long> pref(n + 1);
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + a[i];
    }
    vector<pair<int, int>> sa;
    for (int i = 0; i < n; i++) {
        sa.push_back({a[i], i});
    }
    sort(sa.begin(), sa.end());
    //cout << "AAA";
    long long ans = 0;
    for (int it = 0; it < m; it++) {
        //cout << getl(b[it], a) << ' ' << getr(b[it], a) << '\n';
        //cout << get(b[it], pref, sa) << '\n';
        ans = max(get(b[it], pref, sa), ans);
        //cout <<'\n';
    }
    cout << ans << '\n';
}

void solve2() {
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    vector<vector<int>> q(21);
    int ind = 0;
    for (auto& i : a) {
        cin >> i;
        q[i].push_back(ind++);
    }
    for (auto& i : b) cin >> i;
    for (auto& i : b) i--;
    vector<long long> pref(n + 1);
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + a[i];
    }
    int ans = 0;
    for (auto& it : b) {
        for (int j = 1; j <= 20; j++) {
            auto x = lower_bound(q[j].begin(), q[j].end(), it);
            if (x != q[j].end()) {
                    //cout << '!' << get(it, *x, a, pref) << '\n';
                ans = max(ans, get(it, *x, a, pref));
            }
            if (x != q[j].begin()) {
                x--;
                //cout << '?' << get(it, *x, a, pref) << '\n';
                ans = max(ans, get(it, *x, a, pref));
            }
        }
        //cout << ans << '\n';
    }
    cout << ans << '\n';
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    solve();
}
