#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define int long long

signed main() {
	int n, m, T;
	cin >> n >> m >> T;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector <int> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		b[i]--;
	}

	vector <int> ans(n);
	vector <pair <int, int>> st;
	vector <int> prefa(n + 1);
	for (int i = 0; i < n; i++) {
		prefa[i + 1] = prefa[i] + a[i];
	}
	for (int i = 0; i < n; i++) {
		while (st.size() && st.back().first >= a[i]) {
			st.pop_back();
		}
		st.push_back({ a[i], i });
		for (int kk = st.size() - 1; kk >= 0; kk--) {
			int j = st[kk].second;
			int dist = prefa[i + 1] - prefa[j];
			if (dist > T) break;
			ans[i] = max(ans[i], (T - dist) / a[j] + i - j + 1);
		}
	}

	st.clear();
	for (int i = n - 1; i >= 0; i--) {
		while (st.size() && st.back().first >= a[i]) {
			st.pop_back();
		}
		st.push_back({ a[i], i });
		for (int kk = st.size() - 1; kk >= 0; kk--) {
			int j = st[kk].second;
			int dist = prefa[j + 1] - prefa[i];
			if (dist > T) break;
			ans[i] = max(ans[i], (T - dist) / a[j] + j - i + 1);
		}
	}

	int answer = 0;
	for (auto i : b) {
		answer = max(answer, ans[i]);
	}
	cout << answer;
}