#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <ctime>
#include <random>
#include <map>
#include <set>
#define ll long long
#define nl '\n'
#define emp emplace_back
#define all(x) x.begin(), x.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define popcnt __builtin_popcount
#define ffs __builtin__ffs
#define ss second
#define ff first
//#include <ext/pb_ds/assoc_container.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("avx")
//#pragma GCC target("avx2")

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll INF = 1e9;

const ll mod = 998244353;

mt19937 rnd(time(nullptr));

template<typename T>
istream &operator >>(istream &in, vector<T> &arr) {
    for (auto &x : arr) {
        in >> x;
    }
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, vector<T> &arr) {
    for (auto &x : arr) {
        out << x << ' ';
    }
    out << '\n';
    return out;
}

void solve() {
    ll n, m, t;
    cin >> n >> m >> t;
    vector<ll> a(n);
    cin >> a;
    vector<ll> b(m);
    cin >> b;
    for (auto &x : b) {
        --x;
    }
    ll last = -1;
    ll ans = 0;
    b.emp(n);
    for (ll i = 0; i < m; ++i) {
        ll j = b[i];
        ll s = 0;
        ll kol = 0;
        for (; j > last; --j) {
            ans = max(ans, kol + (t - s) / a[j]);
            s += a[j];
            ++kol;
        }
        s = kol = 0;
        for (j = b[i]; j < b[i + 1]; ++j) {
            ans = max(ans, kol + (t - s) / a[j]);
            s += a[j];
            ++kol;
        }
        last = b[i];
    }
    cout << ans;
}

int main() {
#ifdef CLOCK
    ll time1 = clock();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll tpk = 1;

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

    while (tpk--) {
        solve();
        cout << nl;
    }

#ifdef CLOCK
    cout << clock() - time1 << " ms";
#endif
}