#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

const int mod = 10;

struct Modular {
    int x;

    Modular(int x = 0): x(x) {}

    friend Modular operator+(Modular a, Modular b) {
        int res = a.x + b.x;
        return res - (res >= mod ? mod : 0);
    }

    friend Modular operator-(Modular a, Modular b) {
        int res = a.x - b.x;
        return res + (res < 0 ? mod : 0);
    }

    friend Modular operator*(Modular a, Modular b) {
        return ll(a.x) * b.x % mod;
    }
};

ll get(int ind, int k, vector<ll> &pr, ll T) {
    if (ind < k) {
        if (pr[k + 1] - pr[ind] > T) {
            return 0;
        }
        return k - ind + 1 + (T - pr[k + 1] + pr[ind]) / (pr[ind + 1] - pr[ind]);
    } else {
        if (pr[ind + 1] - pr[k] > T) {
            return 0;
        }
        return ind - k + 1 + (T - pr[ind + 1] + pr[k]) / (pr[ind + 1] - pr[ind]);
    }
}

vector<int> opt;

void calc(int l, int r, int ql, int qr, vector<ll> &pr, ll T) {
    if (l > r) {
        return;
    }
    int mid = (l + r) / 2;
    opt[mid] = mid;
    ll cur = -1e18;
    for(int i = ql; i <= qr; ++i) {
        ll res = get(i, mid, pr, T);
        if(res > cur) {
            cur = res;
            opt[mid] = i;
        }
    }
    calc(l, mid - 1, ql, opt[mid], pr, T);
    calc(mid + 1, r, opt[mid], qr, pr, T);
}

void solve() {
    int n, m;
    ll T;
    cin >> n >> m >> T;
    vector<ll> ar(n), pr(n + 1);
    opt.resize(n);
    for(int i = 0; i < n; ++i) {
        cin >> ar[i];
        pr[i + 1] = ar[i] + pr[i];
    }
    calc(0, n - 1, 0, n - 1, pr, T);
    ll mx = 0;
    for(int i = 0; i < m; ++i) {
        int ind;
        cin >> ind;
        --ind;
        mx = max(mx, get(opt[ind], ind, pr, T));
    }
    cout << mx;
}

signed main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("C:\\Users\\User\\aboab\\input.txt", "r", stdin);
#endif
    solve();
}