import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    bs <- getIntList
    print $ (head bs) + (solve bs)

solve [] = 0
solve [b] = b
solve (b1 : b2 : bs) = (min b1 b2) + (solve (b2 : bs))