#include <bits/stdc++.h>
#include <bits/extc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimize("unrool-looops")
#endif

std::random_device rd;
std::mt19937_64 gen(rd());

#define int ll

using namespace __gnu_pbds;
using ll = long long;

template<class T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5, inf = 1e9 + 7;

std::array<int, N + 1> a, b;
std::array<ll, N + 1> pref, best;

struct SegmentTree {
    struct node {
        int min = inf, fmin = N, lmin = 0;

        node() = default;

        node(int _min, int _fmin, int _lmin) : min(_min), fmin(_fmin), lmin(_lmin) {}
    };

    static node merge(const node &l, const node &r) {
        node res;
        res.min = std::min(l.min, r.min);
        if (l.min == res.min) {
            res.fmin = l.fmin;
            res.lmin = l.lmin;
        }
        if (r.min == res.min) {
            res.fmin = std::min(res.fmin, r.fmin);
            res.lmin = std::max(res.lmin, r.lmin);
        }
        return res;
    }

    std::array<node, 4 * (N + 1)> t;

    void build(int v, int l, int r) {
        if (l + 1 == r) {
            t[v] = {a[l], l, l};
            return;
        }
        int m = (r + l) / 2;
        build(2 * v, l, m);
        build(2 * v + 1, m, r);
        t[v] = merge(t[2 * v], t[2 * v + 1]);
    }

    node get(int v, int l, int r, int ql, int qr) {
        if (qr <= l || r <= ql) {
            return t[0];
        }
        if (ql <= l && r <= qr) {
            return t[v];
        }
        int m = (r + l) / 2;
        return merge(get(2 * v, l, m, ql, qr), get(2 * v + 1, m, r, ql, qr));
    }
};

SegmentTree tr;

void not_main() {
    int n, m, t;
    std::cin >> n >> m >> t;
    for (int i = 1; i <= n; ++i) {
        std::cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    tr.build(1, 1, n + 1);
    for (int i = 1; i <= m; ++i) {
        std::cin >> b[i];
    }
    for (int i = 1; i <= n; ++i) {
        int l = 0, r = i;
        while (r - l > 1) {
            int len = (r + l) / 2;
            if (pref[i] - pref[i - len] <= t) {
                l = len;
            } else {
                r = len;
            }
        }
        int left = i - l;
        l = 0, r = n - i + 1;
        while (r - l > 1) {
            int len = (r + l) / 2;
            if (pref[i + len] - pref[i - 1] <= t) {
                l = len;
            } else {
                r = len;
            }
        }
        int right = i + l;
        int ind = tr.get(1, 1, n + 1, left, i + 1).lmin;
        best[i] = std::max(best[i], i - ind + (t - pref[i] + pref[ind]) / a[ind]);
        ind = tr.get(1, 1, n + 1, i, right + 1).fmin;
        best[i] = std::max(best[i], ind - i + (t - pref[ind - 1] + pref[i - 1]) / a[ind]);
    }
    ll ans = 0;
    for (int i = 1; i <= m; ++i) {
        ans = std::max(ans, best[b[i]]);
    }
    std::cout << ans << '\n';
}

signed main() {
    std::ios_base::sync_with_stdio(false);
#ifndef LOCAL
    std::cin.tie(nullptr);
#endif
    int tests = 1;
    // std::cin >> tests;
    while (tests--) {
        not_main();
    }
    return 0;
}