#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

//#include <ext/pb_ds/assoc_containe.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

//template <class T> order_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//find_by_orede, order_of_key

#define int long long
#define all(a) (a).begin(), (a).end()

#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")


const int inf = 1e18;

int n, m, t;
vector<int> pref, a;

int get(int i, int j) {
	if (i >= j) return pref[i + 1] - pref[j + 1];
	return pref[j] - pref[i];
}

int check(int i, int j) {
	if (get(i, j) > t) return -inf;

	return abs(i - j) + (t - get(i, j)) / a[j];
}


void solve() {
	 cin >> n >> m >> t;
	a.resize(n);
	pref.resize(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		pref[i + 1] = pref[i] + a[i];
	}
	vector<int> lf(n), rt(n);
	{
		vector<int> st;
		for (int i = 0; i < n; ++i) {
			while (st.size() && a[i] <= a[st.back()]) st.pop_back();
			if (st.empty()) lf[i] = -1;
			else lf[i] = st.back();
			st.push_back(i);
		}
	}
	{
		vector<int> st;
		for (int i = n - 1; i >= 0; --i) {
			while (st.size() && a[i] <= a[st.back()]) st.pop_back();
			if (st.empty()) rt[i] = n;
			else rt[i] = st.back();
			st.push_back(i);
		}
	}
	vector<int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i]; --b[i];
	}
	int cnt = 0;


	{
		int ls = -1;
		for (int i = 0; i < m; ++i) {
			int st = b[i];
			while (st > ls) {
				cnt = max(cnt, check(b[i], st));
				st = lf[st];
			}
			ls = b[i];
		}
	}

	{
		int ls = n;
		for (int i = m - 1; i >= 0; --i) {
			int st = b[i];
			while (st < ls) {
				cnt = max(cnt, check(b[i], st));
				st = rt[st];
			}
			ls = b[i];
		}

	}
	cout << cnt;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1; //cin >> t;
	while (t--) solve();
}