import qualified Data.ByteString.Char8 as B
import Data.Char
import Data.List

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  getLine
  bs <- readInts
  print $ solve bs

solve :: [Int] -> Int
solve (b:bs) = sum $ zipWith min (b:b:bs) ((b:bs) ++ [10^5])
