#include<bits/stdc++.h>

using namespace std;

#define int long long
vector<int> p, a;
int t;

int fr(int i, int j) {
    if (abs(p[j] - p[i]) > t) return 0;
    return j - i + (t - abs(p[j] - p[i])) / a[j];
}

int fl(int j, int i) {
    if (abs(p[i + 1] - p[j + 1]) > t) return 0;
    return i - j + (t - abs(p[i + 1] - p[j + 1])) / a[j];
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    int n, m;
    cin >> n >> m >> t;
    a.resize(n);
    vector<int> b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];
    int r = n - 1;
    p.resize(n + 1);
    for (int i = 0; i < n; ++i) p[i + 1] = p[i] + a[i];
    vector<int> ar(n), al(n);
    ar[n - 1] = n - 1;
    int mn = a[n- 1];
    for (int i = n - 2; i >= 0; --i) {
        if(a[i] <= mn){
            mn = a[i];
            ar[i] = i;
            r = i;
            continue;
        }
        while (r - 1 >= i && fr(i, r - 1) >= fr(i, r)) r--;
        ar[i] = r;
    }
    int l = 0;
    mn = a[0];
    for (int i = 1; i < n; ++i) {
        if(a[i] <= mn){
            mn = a[i];
            al[i] = i;
            l = i;
            continue;
        }
        while (l + 1 <= i && fl(l + 1, i) >= fl(l, i) )l++;
        al[i] = l;
    }
    int ans = 0;
    for (int i: b) {
        i--;
        ans = max(ans, fl(al[i], i));
        ans = max(ans, fr(i, ar[i]));
    }
    cout << ans << '\n';
    return 0;
}