import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:a:b:xs)=sum$(zipWith(\y x->min b$a*(y-x))=<<tail)xs