#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;

#define itn int
#define int long long
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define pii pair<int, int>
#define ff first
#define ss second
#define sz(a) (int)(a).size()
#define ll long long
#define ld long double

mt19937 rnd(time(0));

int ans(int n, int m, int T, vector <int> &a, vector <int> &b){
    vector <int> st;
    vector <int> nxt(n, n);

    for (int i = 0; i < n; ++i){
        while (!st.empty() && a[st.back()] > a[i]){
            nxt[st.back()] = i;
            st.pop_back();
        }
        st.push_back(i);
    }
    itn cur = 0;

    vector <int> p(n + 1);
    for (itn i = 0; i < n; ++i){
        p[i + 1] = p[i] + a[i];
    }

    for (itn i = 0; i < m; ++i){
        cur = max(cur, T / a[b[i]]);
    }

    int i = 0, j = b[i];
    while (i < m){
        j = nxt[b[i]];
        while (i + 1 < m && b[i + 1] < j){
            i++;
        }
        int sm = p[j] - p[b[i]];
        if (sm < T) {
            cur = max(cur, (T - sm) / a[j] + (j - b[i]));
        }
        i++;
    }

    return cur;
}

void solve(){
    int n, m, T;
    cin >> n >> m >> T;
    vector <int> a(n), b(m);
    for (auto &x: a) cin >> x;
    for (auto &x: b) {
        cin >> x;
        x--;
    }

    int cur = ans(n, m, T, a, b);
    reverse(all(a));
    for (int i = 0; i < m; ++i){
        b[i] = n - b[i] - 1;
    }
    reverse(all(b));

    cout << max(cur, ans(n, m, T, a, b)) << '\n';
}

signed main(){
    cin.tie(nullptr) ->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t = 1;
//    cin >> t;
    while (t--){
        solve();
    }
}