// semenInRussia 2025
#pragma GCC optimize("Ofast,unroll-loops")
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

int solve1(vector<int> &a, vector<int> &b, int n, int m, int T) {
  vector<int64_t> pref(n + 1);

  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + a[i];
  }

  int64_t ans = 0;

  for (int j : b) {
    // first i; that sum[j + 1] - sum[i + 1] >= 0
    int l = -1;
    int r = j + 1;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (pref[j + 1] - pref[m] <= T) {
        r = m;
      } else {
        l = m;
      }
    }

    int i = r;

    auto sum = pref[j + 1] - pref[i + 1];
    if (i > j) {
      sum = pref[i] - pref[j];
    }
    auto rst = T - sum;
    if (rst >= 0) {
      ans = max(ans, (rst / a[i]) + abs(i - j));
    }
  }

  return ans;
}

int solve2(vector<int> &a, vector<int> &b, int n, int m, int T) {
  vector<int64_t> pref(n + 1);

  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + a[i];
  }

  int64_t ans = 0;

  for (int j : b) {
    for (int i = max(0, j - T); i < min(n, j + T); i++) {
      auto sum = pref[j + 1] - pref[i + 1];
      if (i > j) {
        sum = pref[i] - pref[j];
      }
      auto r = T - sum;
      if (r >= 0) {
        ans = max(ans, (r / a[i]) + abs(i - j));
      }
    }
  }

  return ans;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n, m, T;
  cin >> n >> m >> T;

  vector<int> a(n), b(m);

  for (int &x : a) {
    cin >> x;
  }

  for (int &x : b) {
    cin >> x;
    --x;
  }

  // assert(solve1(a, b, n, m, T) == solve2(a, b, n, m, T));
  cout << solve1(a, b, n, m, T);
}
