#include <bits/stdc++.h>
#define int long long
#define double long double

using namespace std;

signed main() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(n), b(m);
    for (int& i : a) cin >> i;
    for (int& i : b) cin >> i;
    vector<int> pref(n);
    pref[0] = a[0];
    for (int i = 1; i < n; i++) {
        pref[i] = pref[i - 1] + a[i];
    }
    vector<int> dpl(n), dpr(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            if (pref[i] - pref[j] > t) continue;
            int cnt = i - j + (t - pref[i] + pref[j]) / a[j];
            dpl[i] = max(dpl[i], cnt);
        }
        for (int j = n - 1; j > i; j--) {
            int ival = 0;
            if (i > 0) ival = pref[i - 1];
            if (pref[j - 1] - ival > t) continue;
            int cnt = j - i + (t - pref[j - 1] + ival) / a[j];
            dpr[i] = max(dpr[i], cnt);
        }
    }
    // for (int i : dpl) cout << i << " ";
    // cout << "\n";
    // for (int i : dpr) cout << i << " ";
    // cout << "\n";
    int ans = 0;
    for (int i : b) {
        i--;
        ans = max(ans, dpl[i]);
        ans = max(ans, dpr[i]);
    }
    cout << ans << "\n";
}