-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf

import qualified Data.ByteString.Char8 as C
import Data.Maybe

-- fromJustとかいうの初めて知った
 
main = print . solve . map (fst . fromJust . C.readInt) . C.words =<< C.getContents

solve (n:x:a) = ans where
    sm = sum a
    ans = f [2..n] [sm] a x
    f [] r _  _  = minimum r
    f (_:xs) r ar xx = f xs r2 ar2 (xx + x) where
        ar2 = zipWith min a $ [last ar] ++ ar
        r2 = (xx + sum ar2) : r
