//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#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 = 100;

void counter(vector<int> &a, vector<int> &dp, int t) {
    int n = (int)a.size();
    vector<ll> pref(n + 1);
    for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + a[i - 1];
    vector<int> opt(n);
    dp[0] = t / a[0];
    for (int i = 1; i < n; ++i) {
        for (int j = opt[i - 1]; j + K < min(i, opt[i - 1] + K); ++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(0, 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;
                }
            }
        }
    }
}

vector<int> x, y;

void solve() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    x.resize(n);
    y.resize(n);
    counter(a, x, t);
    reverse(a.begin(), a.end());
    counter(a, y, 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;
}
