    #include <bits/stdc++.h>
    #define int long long
    using namespace std;

    const int INF = 2e16;

    signed main() {
        int n, m, t;
        cin >> n >> m >> t;
        vector<int> arr(n), a(m);
        vector<pair<int,int>> all;
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
            all.emplace_back(arr[i], i);
        }
        for (int i = 0; i < m; i++) {
            cin >> a[i];
            a[i]--;
        }
        vector<int> ans(n), used(n);
        sort(all.begin(), all.end());
        for (int i = 0; i < min((int)all.size(), (int)10000); i++) {
            int j = all[i].second;
            int sm = 0;
            for (int k = j; k < n; k++) {
                if (used[k] == 1) {
                    break;
                }
                sm += arr[k];
                if (sm > t) {
                    break;
                }
                ans[k] = max(ans[k], k - j + 1 + (t - sm) / arr[j]);
                // cout << ans[k] << " " << k << "\n";
            }
            sm = 0;
            for (int k = j; k >= 0; k--) {
                if (used[k] == 1) {
                    break;
                }
                sm += arr[k];
                if (sm > t) {
                    break;
                }
                
                ans[k] = max(ans[k], j - k + 1 + (t - sm) / arr[j]);
                // cout << ans[k] << ' ' << k << "\n";
                
            }
            used[j] = 1;
        }
        int mx1 = 0;
        for (auto x: a) {
            mx1 = max(mx1, ans[x]);
        }
        cout << mx1;
    }