{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Char
import Data.Complex
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Maybe
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,m,k] <- r'
    as <- r n
    bs <- r m
    let aScan = U.scanl1 (+) as
    let bScan = U.scanl1 (+) bs

    bScanMut <- U.thaw bScan

    res <- U.imapM (\i a -> solve (i+1) a bScanMut k) aScan

    print $ U.maximum res

solve :: Int -> Int -> UM.IOVector Int -> Int -> IO Int
solve numA tforA bScan k = let tforB = k - tforA
    in  if tforB < 0 then return 0
            else do
                numB <- binarySearchR bScan tforB
                return $ numA + numB
