#ifdef ONLINE_JUDGE
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;

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

//int new_tnode(ll x, int tl, int tr, int l = 0, int r = 0);

template<class T>
struct TNode {
    T x;
    int tl, tr;
    int l = 0;
    int r = 0;
    T def;
    function<T(T, T)> sum;

    TNode(T x, T def, function<T(T, T)> sum, int tl, int tr, int l = 0, int r = 0) :
            x(x), def(def), sum(sum), tl(tl), tr(tr), l(l), r(r) {

    }

    // TNode() = default;
    TNode get_l() const {
        return l ? l : TNode<T>(def, tl, (tl + tr) / 2);
    }

    TNode get_r() const {
        return r ? r : TNode<T>(def, (tl + tr) / 2, tr);
    }

    T get(int ll, int rr) {
        if (tr <= ll || rr <= tl) return def;
        if (ll <= tl && tr <= rr) return x;
        return sum(get_l().get(ll, rr), get_r().get(ll, rr));
    }

    void insert(int i, T y) {
        if (tl == i && i + 1 == tr) {
            x = y;
        }
        int tm = (tl + tr) / 2;
        if (i < tm) {
            get_l().insert(i, y);
        } else {
            get_r().insert(i, y);
        }
        x = sum(get_l().x, get_r().x);
    }

};

//vector<TNode> tn(1);

//int new_tnode(ll x, int tl, int tr, int l, int r) {
//    tn.emplace_back(x, tl, tr, l, r);
//    return (int) tn.size() - 1;
//}

//template<class T>
//struct Tree {
//    TNode<T> root;
//    int n, N;
//    T def;
//    function<T(T, T)> sum;
//    Tree(int n, T def, function<T(T, T)> sum): n(n), def(def), sum(sum) {
//        int st = 0;
//        while ((1 << st) < n) ++st;
//        N = (1 << st);
//        root = TNode<T>(def, sum, 0, N);
//    }
//};

#define int long long

void solve() {
    int n, m, T;
    cin >> n >> m >> T;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        --b[i];
    }
    int gt = 0;
    int gcnt = 0;
    vector<int> dp(n, 0);
    set<array<int, 3>> st;
    st.insert({ll(1e18), ll(1e18), ll(1e18)});

    auto sol = [&](int i) {
        dp[i] = max(dp[i], T / a[i]);
        gcnt += a[i];
        gt++;

        auto it = st.lower_bound({a[i], -1, -1});
        while (it != st.end()) {
            st.erase(*it);
            it = st.lower_bound({a[i], -1, -1});
        }

        while (st.size() > 0) {
            auto [aj, cnt, t] = *(--st.end());
            if ((T - gcnt + cnt) / aj + gt - t < T / a[i]) {
                st.erase({aj, cnt, t});
            } else {
                break;
            }
        }


        st.insert({a[i], gcnt, gt});

        auto [aj, cnt, t] = *st.begin();
        int nw = (T - gcnt + cnt) / aj + gt - t;
        dp[i] = max(dp[i], nw);

    };

    for (int i = 0; i < n; ++i) {
        sol(i);
    }
    st.clear();
    st.insert({ll(1e18), ll(1e18), ll(1e18)});
    for (int i = n - 1; i >= 0; --i) {
        sol(i);
    }


    int mx = 0;
    for (int i = 0; i < m; ++i) {
        mx = max(mx, dp[b[i]]);
    }
    cout << mx;
}

signed main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    for (int test = 0; test < t; ++test) {
        solve();
        cout << '\n';
    }
    cerr << clock() / 1000.0;
    return 0;
}
