#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using  namespace  std;

#define int long long
signed  main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    int n, m, T;
    cin >> n >> m >> T;

    vector<int> a(n);
    vector<int> b(m);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0 ;i  < m;i++)
        cin >> b[i];

    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        int sm = 0, ln = 0;
        for (int j = i; j > -1; j--) {
            if (T - sm < 0)
                break;
            if (ln > 30)
                break;
            l[i] = max(l[i], (T - sm) / a[j] + ln);
            sm += a[j];
            ln += 1;
        }
    }
    vector<int> r(n);
    for (int i = 0; i < n; i++)
    {
        int sm = 0, ln = 0;
        for (int j = i; j < n; j++) {
            if (T - sm < 0)
                break;
            if (ln > 30)
                break;
            r[i] = max(r[i], (T - sm) / a[j] + ln);
            sm += a[j];
            ln += 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        b[i]--;
        if (ans < max(r[b[i]], l[b[i]]))
        {
            ans = max(r[b[i]], l[b[i]]);
        }
    }

    cout << ans;
}