#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_LOG = 19;
int solve2(int n, int m, int T, vector<int> a, vector<int> b){
    int ans = 0;
    for (int B : b){
        int i = B - 1;
        int nw = a[i];
        ans = max(ans, T / a[i]);
        for (int j = i - 1; j >= 0; --j){
            if (nw > T){
                break;
            }
            ans = max(ans, abs(i - j) + (T - nw) / a[j]);
            nw += a[j];
        }
        nw = a[i];
        for (int j = i + 1; j < n; ++j){
            if (nw > T){
                break;
            }
            ans = max(ans, abs(i - j) + (T - nw) / a[j]);
            nw += a[j];
        }
    }
    return ans;
}
int solve(int n, int M, int T, vector<int> a, vector<int> b){
    vector<int> pref(n + 1);
    for (int i = 1; i <= n; ++i){
        pref[i] = pref[i - 1] + a[i - 1];
    }
    vector<int> to(n, -1), to2(n, -1);
    stack<int> lol;
    for (int i = n - 1; i >= 0; --i){
        while(!lol.empty() && a[lol.top()] >= a[i]){
            lol.pop();
        }
        int j = -1;
        if (!lol.empty()){
            j = lol.top();
        }
        if (j != -1){
            to[i] = j;
        }
        lol.push(i);
    }
    while(!lol.empty()){
        lol.pop();
    }
    for (int i = 0; i < n; ++i){
        while(!lol.empty() && a[lol.top()] >= a[i]){
            lol.pop();
        }
        int j = -1;
        if (!lol.empty()){
            j = lol.top();
        }
        if (j != -1){
            to2[i] = j;
        }
        lol.push(i);
    }
    vector<vector<int>> binup(n, vector<int>(MAX_LOG)), binup2(n, vector<int>(MAX_LOG));
    auto build = [](int n, vector<vector<int>> &binup, vector<int> to){
        for (int i = 0; i < n; ++i){
            if (to[i] != -1) {
                binup[i][0] = to[i];
            }
            else{
                binup[i][0] = i;
            }
        }
        for (int j = 1; j < MAX_LOG; ++j){
            for (int i = 0; i < n; ++i){
                binup[i][j] = binup[binup[i][j - 1]][j - 1];
            }
        }
    };
    build(n, binup, to);
    build(n, binup2,  to2);
    auto get = [](int v, const vector<vector<int>> &binup, int k){
        for (int j = MAX_LOG; j >= 0; --j){
            if (k - (1 << j) >= 0){
                v = binup[v][j];
                k -= (1 << j);
            }
        }
        return v;
    };
    int ans = 0;
    auto get2 = [&](int st, int f){
        if (pref[f + 1] - pref[st + 1] > T){
            return -1LL;
        }
        int ans = 0;
        ans += abs(f - st);
        int y = T - (pref[f] - pref[st]);
        ans += y / a[f];
        return ans;
    };
    auto get3 = [&](int st, int f){
        if (pref[st] - pref[f] > T){
            return -1LL;
        }
        int ans = 0;
        ans += abs(f - st);
        int y = T - (pref[st + 1] - pref[f + 1]);
        ans += y / a[f];
        return ans;
    };
    for (int B = 0; B < M; ++B){
        int i = b[B] - 1;
        int l = 0, r = n;
        int ans2 = 0;
        while(l + 1 < r){
            int m = (r + l) / 2;
            int x = get(i, binup, m);
            int y = get(i, binup, m - 1);
            int f = get2(i, x);
            int s = get2(i, y);
            if (f == -1){
                r = m;
                continue;
            }
            if (f > s){
                l = m;
                ans2 = f;
            }
            else{
                r = m;
            }
        }
        ans = max({ans, T / a[i], ans2});
        l = 0, r = n;
        ans2 = 0;
        while(l + 1 < r){
            int m = (r + l) / 2;
            int x = get(i, binup2, m);
            int y = get(i, binup2, m - 1);
            int f = get3(i, x);
            int s = get3(i, y);
            if (f == -1){
                r = m;
                continue;
            }
            if (f > s){
                l = m;
                ans2 = f;
            }
            else{
                r = m;
            }
        }
        ans = max(ans, ans2);
    }
    return ans;
}
mt19937 rnd{123};
int gen(int MAX){
    int y = rnd() % MAX;
    if (!y){
        ++y;
    }
    return y;
}
vector<int> gen2(int n, int MAX){
    vector<int> k(n);
    for (int i = 0; i < n; ++i){
        k[i] = gen(MAX);
    }
    return k;
}
signed main() {
//    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tests = 100;
    while (tests--) {
//        int n = gen(1000000), m = gen(n), T = gen(10000);
//        vector<int> a = gen2(n, 1012039123), b = gen2(m, n);
//        cout << n << " " << m << " " << T << "\n";
//        solve(n,m,T,a,b);
//        for (auto i: a) {
//            cout << i << " ";
//        }
//        cout << "\n";
//        for (auto i: b) {
//            cout << i << " ";
//        }
//        if (solve(n, m, T, a, b) != solve2(n, m, T, a, b)) {
//            cout << "KIT\n";
//            cout << n << " " << m << " " << T << "\n";
//            for (auto i: a) {
//                cout << i << " ";
//            }
//            cout << "\n";
//            for (auto i: b) {
//                cout << i << " ";
//            }
//            cout << "\n" << solve(n, m, T, a, b) << " " << solve2(n, m, T, a, b);
//            exit(0);
//        } else {
//            cout << "OK\n";
//        }
        int n,m,T;
        cin >> n >> m >> T;
        vector<int> a(n), b(m);
        for (int &i : a){
            cin >> i;
        }
        for (int & i : b){
            cin >> i;
        }
        cout << solve(n,m,T,a,b) << "\n";
    }
}

//10 6 2873
//7 17 15 12 2 11 1 1 15 7
//2 1 1 4 1 9-
//        int i = b[B] - 1;
//        int nw = 0;
//        int v = i;
//        ans = max(ans, T / a[i]);
//        int was = -1;
//        while(v != -1){
//            nw += to[v].second;
//            v = to[v].first;
//            if (v == -1){
//                break;
//            }
//            if (nw > T){
//                break;
//            }
//            if (abs(i - v) + (T - nw) / a[v] < was){
//                break;
//            }
//            was = abs(i - v) + (T - nw) / a[v];
//            ans = max(ans, was);
//        }
//        v = i, nw = 0;
//        was = -1;
//        while(v != -1){
//            nw += to2[v].second;
//            v = to2[v].first;
//            if (v == -1){
//                break;
//            }
//            if (nw > T){
//                break;
//            }
//            if (abs(i - v) + (T - nw) / a[v] < was){
//                break;
//            }
//            was = abs(i - v) + (T - nw) / a[v];
//            ans = max(ans, was);
//        }