//#pragma GCC optimize("O3")
//#pragma GCC target("avx, avx2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ALL(X) (X).begin(), (X).end()
#define sz(X) (int)(X.size())

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned int ui;
typedef long double ld;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll n, m, T;

#define int ll

int solve(vector<ll>& a, vector<ll>& b) {
	vector<ll> pref(n + 1);
	pref[0] = 0;
	for (int i = 1; i <= n; ++i) {
		pref[i] = pref[i - 1] + a[i - 1];
	}	
	vector<int> ls_r(n);
	vector<pair<ll, int>> st;
	for (int i = n - 1; i >= 0; --i) {
		while (!st.empty() && st.back().first >= a[i]) {
			st.pop_back();
		}
		ls_r[i] = (st.empty() ? n : st.back().second);
		st.emplace_back(a[i], i);
	}
	ll ans = 0;
	int ptr = 0;
	int cpos = b[0];
	while (ptr < m) {
		if (ls_r[cpos] == n || (ptr < m - 1 && b[ptr + 1] <= cpos)) {
			ll d = (T - pref[cpos] + pref[b[ptr]]) / a[cpos] + cpos - b[ptr];
			ans = max(ans, d);
			++ptr;
			if (ptr < m) {
				cpos = b[ptr];
			}
		} else {
			ll d1 = (T - pref[cpos] + pref[b[ptr]]) / a[cpos] + cpos - b[ptr];
			ll d2 = (T - pref[ls_r[cpos]] + pref[b[ptr]]) / a[ls_r[cpos]] + ls_r[cpos] - b[ptr];
			if (pref[ls_r[cpos]] - pref[b[ptr]] <= T && d2 >= d1) {
				cpos = ls_r[cpos];
			} else {
				ans = max(ans, d1);
				++ptr;
				if (ptr < m) {
					cpos = b[ptr];
				}
			}
		}
	} 
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> T;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<ll> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
		--b[i];
	}
	int ans = solve(a, b);
	reverse(ALL(a));
	reverse(ALL(b));
	for (int i = 0; i < m; ++i) {
		b[i] = n - b[i] - 1;
	}
	ans = max(ans, solve(a, b));
	cout << ans << '\n';
	return 0;
}