#!/bin/bash

name=()
time=()
read total
for ((i=0; i < ${total}; i++)); do
        read n t
        name=("${name[@]}" $n)
        time=("${time[@]}" $t)
done

read target

for ((i=0; i < ${total}; i++)); do
        if [ ${target} = ${name[$i]} ]; then 
                break   
        fi      
done
let i++
slp=0
for ((; i < ${total}; i++)); do
        slp=$((${slp}+${time[$i]}))
done
echo $slp

exit