module Main where
-- import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
import Data.Maybe
-- import qualified Data.Map as M
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad

solve :: Int -> [Int] -> [Int] -> Int
solve n s = iter 0 where
    iter ac [] = ac
    iter ac (t:ts) = iter (ac + if find t then 1 else 0) ts
    tableS = listArray (0, n-1) s
    find t = iter 0 (n-1) where
        iter l r 
            | l >  r    = False
            | v == t    = True
            | v <  t    = iter (d+1) r
            | otherwise = iter l (d-1) where
                d = div (l+r) 2
                v = tableS ! d

readLine :: IO [Int]
readLine = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main :: IO() 
main = do
    n <- readLn :: IO Int
    s <- readLine
    q <- readLn :: IO Int
    t <- readLine
    print $ solve n s t

