module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

range (x:y:ys) = (x, y) : range (y:ys)
range _ = []

speed (l, r) v x
  | x <= l    = v + (l - x)
  | x <= r    = v
  | otherwise = v + (x - r)

main :: IO ()
main = do
  n  <- readInt
  ts <- map fromIntegral <$> scanl1 (+) <$> ((0:) . (0:)) <$> (++ [0]) <$> readInts
  vs <- map fromIntegral <$> (0 :) <$> (++ [0]) <$> readInts
  let end = last ts
      calc x = minimum $ map ($ x) speeds
        where speeds = zipWith speed (range ts) vs
      metric = map calc $ takeWhile (<= end) (iterate (+ 0.5) 0)
      areas = foldr f (0.0, 0.0) metric
        where f b (s, a) = (s + (a + b) / 4, b) 

  putStrLn $ doubleFmt (fst areas)

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"
