#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#define int long long

using namespace std;
using ll = long long;
using ld = long double;
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 3e5 + 69;
const int K = 50;

vector<int> counter(vector<int> a, int t) {
    int n = (int)a.size();
    vector<int> pref(n + 1);
    for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i - 1];
    vector<int> opt(n), dp(n);
    dp[0] = t / a[0];
    for (int i = 1; i < n; ++i) {
        for (int j = opt[i - 1]; j + K < i; ++j) {
            if (pref[i + 1] - pref[j] <= t) {
                int now = i - j + 1 + (t - pref[i + 1] + pref[j]) / a[j];
                if (now > dp[i]) {
                    dp[i] = now;
                    opt[i] = j;
                }
            }
        }
        for (int j = max(0ll, i - K); j <= i; ++j) {
            if (pref[i + 1] - pref[j] <= t) {
                int now = i - j + 1 + (t - pref[i + 1] + pref[j]) / a[j];
                if (now > dp[i]) {
                    dp[i] = now;
                    opt[i] = j;
                }
            }
        }
    }
    return dp;
}

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    auto x = counter(a, t);
    reverse(a.begin(), a.end());
    auto y = counter(a, t);
    reverse(y.begin(), y.end());
    int ans = 0;
    for (int i = 0; i < m; ++i) {
        int w;
        cin >> w;
        --w;
        ans = max(ans, max(x[w], y[w]));
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
