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

#define int long long

const int maxn = 3e5 + 52, inf = 8e18, mod = 1e9 + 7;


void solve() {
    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n + 1), p(n + 1), b(m), s(n + 2);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
        p[i + 1] = a[i + 1] + p[i];
    }
    for (int i = n; i >= 1; i--) {
        s[i] = s[i + 1] + a[i];
    }
    int res = 0;
    for (int& i : b) cin >> i;
    for (int j = 0; j < m; j++) {
        int re1 = 0, preind = 0;
        for (int i = max(b[j], preind); i <= n; i++) {
            if (T - (p[i - 1] - p[b[j] - 1]) < a[i]) break;
            int r = (T - (p[i - 1] - p[b[j] - 1])) / a[i] + (i - b[j]);
            if (re1 < r) {
                re1 = r;
                preind = i;
            }
        }
        res = max({res, re1});
    }
    for (int j = 0; j < m; j++) {
        int re2 = 0, preind = 0;
        for (int i = b[j]; i >= max(1ll, preind); i--) {
            if ((T - (s[i + 1] - s[b[j] + 1])) < a[i]) break;
            int r = (T - (s[i + 1] - s[b[j] + 1])) / a[i] + (-i + b[j]);
            if (re2 < r) {
                re2 = r;
                preind = i;
            }
        }
        res = max({res, re2});
    }
    cout << res << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
// wow1