#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>

using namespace std;

#define ll long long 
#define vc vector
#define str string
#define sz(a) (a).size()
#define its(a) (a).begin(), (a).end()
#define itsr(a) (a).rbegin(), (a).rend()
#define scan(a) for (auto &_i:(a)) cin >> _i;

void solve() {
	ll n, m, T; cin >> n >> m >> T;
	vc<ll> a(n); scan(a);
	vc<ll> b(m); scan(b);

	vc<ll> tr(4 * n);
	auto rsq = [&](auto rsq, int v, int l, int r, int el, ll x) -> void {
		if (r - l == 1) {
			tr[v] = x;
			return;
		}
		int mid = (r + l) >> 1;
		if (el < x) rsq(rsq, 2 * v + 1, l, mid, el, x);
		else rsq(rsq, 2 * v + 2, mid, r, el, x);
		tr[v] = tr[2*v+1] + tr[2*v+2];
		};

	ll P = 0;

	vc<ll> ansR(n);
	for (int i = 0;i < n;++i) {
		vc<tuple<ll, ll, ll>> rm = { { a[i], 0, 0} };
		ll cur = a[i];
		for (int j = i+1;j < n;++j) {
			if (cur > T) break;
			if (a[j] < get<0>(rm.back())) rm.push_back({ a[j], cur, j-i });
			cur += a[j];
		}
		vc<ll> vals;
		for (auto [e, s, k] : rm) {
			if (T - s < 0) continue;
			ansR[i] = max(ansR[i], k + (T - s) / e);
			vals.push_back(k + (T - s) / e);
		}
		pair<ll, ll> mx = { -1, 0 };
		for (int j = 0;j < sz(vals);++j) {
			mx = max(mx, { vals[j], j });
		}
		if (sz(vals)) {
			for (int j = 0;j < mx.second - 1;++j) {
				if (vals[j] > vals[j + 1]) cout << 1 / P;
			}
			for (int j = mx.second;j < sz(vals) - 1;++j) {
				if (vals[j] < vals[j + 1]) cout << 1 / P;
			}
		}

	}
	vc<ll> ansL(n);
	for (int i = 0;i < n;++i) {
		vc<tuple<ll, ll, ll>> rm = { { a[i], 0, 0} };
		ll cur = a[i];
		for (int j = i -1;j >= 0;--j) {
			if (cur > T) break;
			if (a[j] < get<0>(rm.back())) rm.push_back({ a[j], cur, i-j });
			cur += a[j];
		}
		vc<ll> vals;
		for (auto [e, s, k] : rm) {
			if (T - s < 0) continue;
			ansL[i] = max(ansL[i], k + (T - s) / e);
			vals.push_back(k + (T - s) / e);
		}
		pair<ll, ll> mx = { -1, 0 };
		for (int j = 0;j < sz(vals);++j) {
			mx = max(mx, { vals[j], j });
		}
		if (sz(vals)) {
			for (int j = 0;j < mx.second-1;++j) {
				if (vals[j] > vals[j + 1]) cout << 1/P;
			}
			for (int j = mx.second;j < sz(vals)-1;++j) {
				if (vals[j] < vals[j + 1]) cout << 1 / P;
			}
		}
	}
	ll ans = 0;
	for (auto i : b) ans = max({ ans, ansL[i - 1], ansR[i - 1] });
	cout << ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll _t = 1;
	// cin >> _t;
	while (_t--)
		solve();
}
