main = print =<< solver <$> readLn <*> (map read . words <$> getLine) <*> (map read . words <$> getLine)

solver :: Int -> [Int] -> [Int] -> Double
solver n t v = (/8.0) $ realToFrac (sum xs)
    where
        ts = scanl (+) 0 t
        pln = zip ts (0 : v)
        nln = zip ts (v ++ [0])
        flat_xs = concat $ zipWith (\x y -> (take (x * 2)) (repeat (4 * y))) t v
        xs = zipWith f [1..(last ts * 2)] flat_xs
        filtmap g h = (fmap h) . (filter g)
        f x y = minimum ((fmap (\(a, b) -> 4*b + 2*x - 4*a - 1) (filter ((x >) . (2*) . fst) pln)) ++ (fmap (\(a, b) -> 4*b + 4*a - 2*x + 1) (filter ((x <=) . (2*) . fst) nln)) ++ [y])