
#include <iostream>
#include <limits>
#include <chrono>
#include <random>
#include <iomanip>
#include <algorithm>
#include <chrono>
#include <random>
#include <math.h>
#include <set>
using namespace std;
#define int long long
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, t;
	cin >> n >> m >> t;
	vector <int> vec(n);
	for (int i = 0;i < n;i++)cin >> vec[i];
	vector <int> ans(n, 0);
	int best = 0;
	for (int i = 0;i < n;i++) {
		best = max(best, t / vec[i]);
	}
	if (n == m) {
		cout << best;
		exit(0);
	}
	int bestl = -1, bestr = 0;
	/*int buy = 0;
	
	}*/
	vector <int> pref_sum(n);
	for (int i = 0;i < n;i++) {
		pref_sum[i] = vec[i];
		if (i)pref_sum[i] += pref_sum[i - 1];
	}
	for (int i = 0;i < n;i++) {
		int buy = pref_sum[bestr] - vec[bestr];
		buy -= (pref_sum[i] - vec[i]);
		for (int r = bestr;r < n;r++) {
			if (ans[i] < r - i + ((t - buy) / vec[r])) {
				ans[i] = r - i + ((t - buy) / vec[r]);
				bestr = r;
			}
			buy += vec[r];
			if (buy > t)break;

		}
		buy = 0;
		for (int l = i;l >= 0;l--) {
			if (i - l + ((t - buy) / vec[l]) > ans[i]) {
				ans[i] = i - l + ((t - buy) / vec[l]);
				bestl = l;
			}
			buy += vec[l];
			if (buy > t)break;
	}
	int res = 0;
	for (int i = 0;i < m;i++) {
		int pos;
		cin >> pos;
		pos--;
		res = max(res, ans[pos]);
	}
	cout << res;
}
