#include <bits/stdc++.h>
#define int long long
#define double long double

using namespace std;

const int inf = 1e10;

struct line {
    double k, b;
    int i;
    double at(int x) {
        return k * x + b;
    }
    double intersect(line o) {
        return (o.b - b) / (k - o.k);
    }
    line() {}
    line(double k, double b, int i) : k(k), b(b), i(i) {}
};

line null(0, -inf, -1);

mt19937 rng(179);

struct node {
    int x, y;
    line l;
    node *left, *right;
    node(int x) : x(x) {
        left = right = nullptr;
        l = null;
        y = rng();
    }
};

node *root = nullptr;

void add(node *root, line l) {
    if (root == nullptr) return;
    if (root->l.at(root->x) < l.at(root->x)) {
        swap(root->l, l);
    }
    if (l.k > 0) {
        add(root->right, l);
    } else {
        add(root->left, l);
    }
}

line get(node *root, int x) {
    if (root == nullptr) return null;
    // cout << root->x << ": " << root->l.i << "\n";
    line cur;
    if (root->x < x) {
        cur = get(root->right, x);
    } else {
        cur = get(root->left, x);
    }
    if (root->l.at(x) > cur.at(x)) {
        cur = root->l;
    }
    // cout << root->x << ": " << cur.i << "\n";
    // cout << x << "\n";
    // cout << root->l.at(x) << " " << cur.at(x) << "\n";
    return cur;
}

node* merge(node *root1, node *root2) {
    if (root1 == nullptr) {
        return root2;
    }
    if (root2 == nullptr) {
        return root1;
    }
    if (root1->y > root2->y) {
        root1->right = merge(root1->right, root2);
        return root1;
    } else {
        root2->left = merge(root1, root2->left);
        return root2;
    }
}

signed main() {
    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;
    vector<int> pref(n);
    pref[0] = a[0];
    for (int i = 1; i < n; i++) {
        pref[i] = pref[i - 1] + a[i];
    }
    vector<int> xs;
    for (int i : pref) xs.push_back(-i);
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    // reverse(xs.begin(), xs.end());
    for (int i : xs) {
        root = merge(root, new node(i));
    }
    // reverse(xs.begin(), xs.end());
    vector<int> dpl(n);
    for (int i = 0; i < n; i++) {
        // add(root, line((double)1 / a[i], (double)(t + pref[i]) / a[i] - i, i));
        add(root, line((double)1 / a[i], (double)(t + pref[i]) / a[i] - i, i));
        int j = get(root, -pref[i]).i;
        if (j == -1) assert(false);
        dpl[i] = i - j + (t - pref[i] + pref[j]) / a[j];
        // cout << i << " " << j << "\n";
    }
    root = nullptr;
    for (int i : xs) {
        root = merge(root, new node(-i));
    }
    vector<int> dpr(n);
    // for (int i = n - 1; i >= 0; i--) {
    //     int ival = 0;
    //     if (i > 0) ival = pref[i - 1];
    //     add(root, line((double)1 / a[i], (double)(t - ival) / a[i] + i, i));
    //     int j = get(root, pref[i]).i;
    //     if (j > i) {
    //         dpr[i] = j - i + (t - pref[j - 1] + ival) / a[j];
    //     }
        // for (int j = i + 1; j < n; j++) {
        //     int ival = 0;
        //     if (i > 0) ival = pref[i - 1];
        //     if (pref[j - 1] - ival > t) break;
        //     int cnt = j - i + (t - pref[j - 1] + ival) / a[j];
        //     dpr[i] = max(dpr[i], cnt);
        // }
    // }
    // for (int i : dpl) cout << i << " ";
    // cout << "\n";
    // for (int i : dpr) cout << i << " ";
    // cout << "\n";
    int ans = 0;
    for (int i : b) {
        i--;
        ans = max(ans, dpl[i]);
        ans = max(ans, dpr[i]);
    }
    cout << ans << "\n";
}