#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
mt19937 rnd(time(NULL));
#define int long long
vector<int>tree; vector<int>a;
void build(int i, int l, int r){
    if(l + 1 == r){
        tree[i] = l; return;
    }
    build(2 * i + 1, l, (l + r) / 2); build(2 * i + 2, (l + r) / 2, r);
    if(a[tree[2 * i + 1]] > a[tree[2 * i + 2]]) tree[i] = tree[2 * i + 2];
    else tree[i] = tree[2 * i + 1];
}
int get(int i, int l, int r, int tl, int tr){
    if(l >= tr || r <= tl) return -1;
    if(l >= tl && r <= tr) return tree[i];
    auto first = get(2 * i + 1, l, (l + r) / 2, tl, tr);
    auto second = get(2 * i + 2, (l + r) / 2, r, tl, tr);
    if(first == -1) return second;
    if(second == -1) return first;
    if(a[first] > a[second]) return second;
    return first;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int m, n, T; cin >> n >> m >> T;
    vector<int>b(m); a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    tree.resize(4 * n); build(0, 0, n);
    vector<int>pref(n + 1);
    for(int i = 0; i < n; i++) pref[i + 1] = pref[i] + a[i];
    vector<int>ans(n); ans[0] = 0;
    for(int i = 1; i < n; i++){
        int val = pref[i + 1] - pref[ans[i - 1]];
        {
            int first = (T - val) / a[ans[i - 1]] + (i - ans[i - 1] + 1);
            int ind = get(0, 0, n, ans[i - 1] + 1, i + 1);
            int second = (T - (pref[i + 1] - pref[ind])) / a[ind];
            if(second + (i + 1 - ind) > first) ans[i] = ind;
            else ans[i] = ans[i - 1];
        }
    }
    vector<int>right(n); right[n - 1] = n - 1;
    for(int i = n - 2; i >= 0; i--){
        int val = pref[right[i + 1] + 1] - pref[i];
        {
            int first = (T - val) / a[right[i + 1]] + (right[i + 1] - i + 1);
            int ind = get(0, 0, n, i, right[i + 1]);
            int second = (T - (pref[ind + 1] - pref[i])) / a[ind];
            if(second + (ind + 1 - i) > first) right[i] = ind;
            else right[i] = right[i + 1];
        }
    }
    int mx = 0;
    for(int _ = 0; _ < m; _++){
        int i = b[_] - 1;
        mx = max(mx, (T - pref[i + 1] + pref[ans[i]]) / a[ans[i]] + (i + 1 - ans[i]));
        mx = max(mx, (T - pref[right[i] + 1] + pref[i]) / a[right[i]] + (right[i] + 1 - i));
    }
    cout << mx;
    return 0;
}