#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
// #include <bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());

using ll = long long;
using ld = long double;

const int N = 300000;
ll prefSum[N + 1];
int r[N], l[N];
int a[N];
int n, m;
ll T;

void getRight(int L, int R, int mini, int maxi) {
    int mid = (L + R) >> 1;
    ll cur = -1, ind = 0;
    for (int i=max(mini, mid); i <= maxi && T - prefSum[i] + prefSum[mid] >= 0; ++i) {
        ll ri = (i - mid) + (T - prefSum[i] + prefSum[mid]) / a[i];
        if (cur < ri) {
            cur = ri;
            ind = i;
        }
    }
    r[mid] = ind;
    if (R - L > 1) {
        getRight(L, mid, mini, ind);
        getRight(mid, R, ind, maxi);
    }
}

void getLeft(int L, int R, int mini, int maxi) {
    int mid = (L + R) >> 1;
    ll cur = -1, ind = 0;
    for (int i=min(mid, maxi); i >= mini && T - prefSum[mid + 1] + prefSum[i + 1] >= 0; --i) {
        ll le = (mid - i) + (T - prefSum[mid + 1] + prefSum[i + 1]) / a[i];
        if (cur < le) {
            cur = le;
            ind = i;
        }
    }
    l[mid] = ind;
    if (R - L > 1) {
        getLeft(L, mid, mini, ind);
        getLeft(mid, R, ind, maxi);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> T;
    for (int i=0; i < n; ++i) {
        cin >> a[i];
        prefSum[i + 1] = prefSum[i] + a[i];
    }
    vector <int> b(m);
    for (int i=0; i < m; ++i) {
        cin >> b[i];
        b[i]--;
    }
    getRight(0, n, 0, n - 1);
    getLeft(0, n, 0, n - 1);
    ll ans = 0;
    for (int e : b) {
        ll le = (e - l[e]) + (T - prefSum[e + 1] + prefSum[l[e] + 1]) / a[l[e]];
        ll ri = (r[e] - e) + (T - prefSum[r[e]] + prefSum[e]) / a[r[e]];
        ans = max(ans, max(le, ri));
        ans = max(ans, T / a[e]);
    }
    cout << ans << "\n";
    return 0;
}
