#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ceil(a, b) (((a) + (b) - 1) / (b))
const int INF = 2e9 + 7;
const ll LINF = 1e18 + 7;
const int mxN = 3e5 + 10;

ll a[mxN], pref[mxN], T;
ll get(int l, int r) {
    if(l > r) return 0;
    ll ans = pref[r];
    if(l) ans -= pref[l - 1];
    return ans;
}
ll calc(int s, int t) {
    return abs(s - t) + (T - (s <= t ? get(s, t - 1) : get(t + 1, s))) / a[t];
}
void solve() {
    int n, m;
    cin >> n >> m >> T;
    vector<ll> ans(n), near(30, -1);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        pref[i] = (i ? pref[i - 1] : 0) + a[i];
    }
    for(int i = 0; i < n; ++i) {
        int lb = -1, rb = i + 1;
        while(lb + 1 < rb) {
            int mid = (lb + rb) / 2;
            if(get(mid, i) > T) lb = mid;
            else rb = mid;
        }
        if(rb <= i) ans[i] = calc(i, rb);
        lb = i - 1, rb = n;
        while(lb + 1 < rb) {
            int mid = (lb + rb) / 2;
            if(get(i, mid) > T) rb = mid;
            else lb = mid;
        }
        if(i <= lb) ans[i] = max(ans[i], calc(i, lb));
    }
    for(int i = 0; i < n; ++i) {
        near[a[i]] = i;
        for(int k = 1; k < siz(near); ++k) {
            if(near[k] == -1) continue;
            ans[i] = max(ans[i], calc(i, near[k]));
        }
    }
    near.assign(siz(near), -1);
    for(int i = n - 1; i >= 0; --i) {
        near[a[i]] = i;
        for(int k = 1; k < siz(near); ++k) {
            if(near[k] == -1) continue;
            ans[i] = max(ans[i], calc(i, near[k]));
        }
    }
    ll mx = 0;
    for(int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        mx = max(mx, ans[x - 1]);
    }
    cout << mx;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cout << fixed; cout.precision(8);
#ifdef INEYOK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
}
