#include "bits/stdc++.h"
#pragma GCC optimize("unroll-loops", "Ofast")
using namespace std;
#define ll long long
const int inf = 2e9;
const ll INF = 2e18;

//#define int ll
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

random_device dev;
mt19937 rnd(dev());

template<typename T1, typename T2>
istream& operator >> (istream &in, pair<T1, T2> &a) {
    in >> a.first >> a.second;
    return in;
}

template<typename T1, typename T2>
ostream& operator << (ostream &out, pair<T1, T2> &a) {
    out << a.first << " " << a.second;
    return out;
}

template<typename T>
istream& operator >> (istream &in, vector<T> &a) {
    for (int i = 0; i < a.size(); i++)
        in >> a[i];
    return in;
}

template<typename T>
ostream& operator << (ostream &out, vector<T> &a) {
    for (auto &i: a)
        cout << i << " ";
    return out;
}

template<typename T>
T msMx(multiset<T> &ms) {
    auto it = ms.end();
    it--;
    return *it;
}

const ll MOD = 1e9 + 7;

ll modPw(ll a, ll n) {
    ll res = 1;
    for (; n > 0; n /= 2, a = (a * a) % MOD) {
        if (n & 1)
            res = (res * a) % MOD;
    }
    return res;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, m, T;
    cin >> n >> m >> T;
    vector<ll> a(n), b(m);
    cin >> a >> b;
    vector<ll> pref(n + 1, 0);
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + a[i];
    }

    vector<int> maxL(n), maxR(n);
    iota(maxL.begin(), maxL.end(), 0);
    iota(maxR.begin(), maxR.end(), 0);

    for (int i = 0; i < n; i++) {
        ll sum = 0;
        for (int j = i; j >= 0; j--) {
            if (sum <= T)
                maxL[i] = j;
            else
                break;
            sum += a[j];
        }
    }
//    int l = 0, r = 0;
//    ll sum = a[0];
//    while (r < n) {
//        if (sum <= T) {
//            maxL[r] = min(maxL[r], l);
//            maxR[l] = max(maxR[l], r);
//            r++;
//        } else {
//            l++;
//        }
//    }
    vector<ll> ans(n, 0);
    for (int i = 0; i < n; i++) {
        int leftJ = maxL[i];
        ll sum = pref[i + 1] - pref[leftJ];
        if (pref[i + 1] < T)
            ans[i] = ((T - pref[i + 1]) / a[0]);
        else
            ans[i] = i + 1 - leftJ;
//        ans[i] = T / a[i];
//        for (int j = i - 1; j >= 0; j--) {
//            if (sum >= T)
//                break;
//            ans[i] = max(ans[i], (T - sum) / a[j] + i - j);
//            sum += a[j];
//        }
//        sum = a[i];
//        for (int j = i + 1; j < n; j++) {
//            if (sum >= T)
//                break;
//            ans[i] = max(ans[i], (T - sum) / a[j] + j - i);
//            sum += a[j];
//        }
    }
    ll mx = 0;
    for (int i: b) {
        mx = max(ans[i - 1], mx);
    }
    cout << mx << "\n";
}
