#include <bits/stdc++.h>

using namespace std;
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,avx,bmi2")
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
//using namespace __gnu_pbds;
//template<class T> using oredered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, T;
    cin >> n >> m >> T;
    bool f = true;
//    if (n > 1000 && m == n && n == 300000 && T > 20) exit(-1);
    vector<int> a(n + 1), p(n + 1), bb(m), s(n + 2);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
        f &= (a[i + 1] >= a[i]);
        p[i + 1] = a[i + 1] + p[i];
    }
    for (int i = n; i >= 1; i--) {
        s[i] = s[i + 1] + a[i];
    }
    for (int& i : bb) {
        cin >> i;
    }
    int res = 0;
    int preind;
    if (!f) {
        preind = 0;
        for (int j = 0; j < m; j++) {
            int re1 = 0;
            int cnt = 0;
            for (int i = max(bb[j], preind); i <= n && cnt < 10000; i++, cnt++) {
                if (T - (p[i - 1] - p[bb[j] - 1]) < a[i]) break;
                int r = (T - (p[i - 1] - p[bb[j] - 1])) / a[i] + (i - bb[j]);
                if (re1 < r) {
                    re1 = r;
                    preind = i;
                }
            }
            res = max({res, re1});
        }
    }
    preind = n;
    for (int j = m - 1; j >= 0; j--) {
        int re2 = 0;
        int cnt = 0;
        for (int i = min(bb[j], preind); i >= 1 && cnt < 10000; i--, cnt++) {
            if ((T - (s[i + 1] - s[bb[j] + 1])) < a[i]) break;
            int r = (T - (s[i + 1] - s[bb[j] + 1])) / a[i] + (-i + bb[j]);
            if (re2 < r) {
                re2 = r;
                preind = i;
            }
        }
        res = max({res, re2});
    }
    cout << res << endl;
    return 0;
}
// wow1