#ifndef LOCAL
  #pragma GCC optimize("Ofast,unroll-loops")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
  #pragma GCC target("avx,avx2,fma")
#endif

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define all(x) begin(x), end(x)
#define isz(x) (int)size(x)

constexpr int buffer_size = 1 << 20;
constexpr char my_flush = '@';

char read_char() {
  static char cache[buffer_size];
  static int pos = 0;
  static int sz = 0;
  if (pos == sz) {
    sz = fread(cache, 1, buffer_size, stdin);
    pos = 0;
  }
  if (pos == sz) {
    return EOF;
  }
  return cache[pos++];
}

void write_char(char c) {
  static char cache[buffer_size];
  static int pos = 0;
  if (pos == buffer_size || c == my_flush) {
    fwrite(cache, 1, pos, stdout);
    pos = 0;
  }
  if (c != my_flush) {
    cache[pos++] = c;
  }
}

template<typename T>
void write_num(T x) {
  char st[64];
  int pos = 0;
  if (x < 0) {
    write_char('-');
    x = -x;
  }
  do {
    st[pos++] = char('0' + x % 10);
    x /= 10;
  } while (x > 0);
  while (pos > 0) {
    write_char(st[--pos]);
  }
}

template<typename T>
T read_num() {
  bool sign = false;
  char c;
  T res = 0;
  for (;;) {
    c = read_char();
    if (c == '-') {
      sign = true;
    }
    if (!isdigit(c)) {
      break;
    }
    res = res * 10 + (c - '0');
  }
  return res;
}

string read_str() {
  string ans;
  char c;
  for (;;) {
    c = read_char();
    if (isalnum(c) || isgraph(c)) {
      ans.push_back(c);
    } else {
      break;
    }
  }
  return move(ans);
}

void print_str(const string& s) {
  for (auto c : s) {
    write_char(c);
  }
}

constexpr int memory_size = 2e8;
int pos = 0;
char memory_cache[memory_size];
void* operator new(size_t n) {
  return memory_cache + exchange(pos, pos + n);
}
void operator delete(void*) {}
void operator delete(void*, size_t) {}

void solve() {
  int n, m, T;
  // cin >> n >> m >> T;
  n = read_num<int>();
  m = read_num<int>();
  T = read_num<int>();
  vector<int> a(n);
  for (auto& it : a) {
    // cin >> it;
    it = read_num<int>();
  }
  vector<int> b(m);
  for (auto& it : b) {
    // cin >> it;
    it = read_num<int>();
  }
  vector<ll> p(n + 1);
  for (int i = 0; i < n; ++i) {
    p[i + 1] = p[i] + a[i];
  }
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i) {
    for (int j = i; j >= 0; --j) {
      if (p[i + 1] - p[j + 1] > T) break;
      cnt[i] = max<ll>(cnt[i], (i - j) + (T - (p[i + 1] - p[j + 1])) / a[j]);
    }
    for (int j = i; j < n; ++j) {
      if (p[j] - p[i] > T) break;
      cnt[i] = max<ll>(cnt[i], (j - i) + (T - (p[j] - p[i])) / a[j]);
    }
  }
  int ans = 0;
  for (auto it : b) {
    ans = max(ans, cnt[it - 1]);
  }
  cout << ans << '\n';
}

signed main() {
  cin.tie(0)->sync_with_stdio(0);
  int t = 1;
  // cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}