program main
  implicit none
  integer :: n, i, ts, ptr, cnt
  integer, allocatable :: t(:), v(:), dp1(:), dp2(:), v2(:), v3(:)
  read *, n
  allocate (t(n), v(n))
  read *, t
  read *, v
  ts = sum(t)
  allocate (v2(0:ts), v3(1:ts), dp1(0:ts), dp2(0:ts))

  ! 各時刻の最高制限速度
  v2 = 10 ** 9
  v2(0) = 0
  v2(ts) = 0
  ptr = 0
  do i = 1, n
    v2(ptr:ptr + t(i)) = min(v2(ptr:ptr + t(i)), v(i))
    ptr = ptr + t(i)
  end do

  ! 各half-時刻の最高制限速度 v3(i) は i-0.5の最高速度 (i = 1, ..., ts)
  ptr = 0
  do i = 1, n
    v3(ptr + 1:ptr + t(i)) = v(i)
    ptr = ptr + t(i)
  end do

  ! 加速制約による最高速度
  dp1(0) = 0
  do i = 1, ts
    dp1(i) = min(dp1(i - 1) + 1, v2(i))
  end do

  ! 減速制約による最高速度
  dp2(ts) = 0
  do i = ts - 1, 0, -1
    dp2(i) = min(dp2(i + 1) + 1, v2(i))
  end do

  dp1 = min(dp1, dp2)

  ! 三角屋根補正
  cnt = 0
  do i = 1, ts  ! i-0.5を扱う
    if (dp1(i - 1) == dp1(i) .and. dp1(i) < v3(i)) then
      cnt = cnt + 1
    end if
  end do

  print "(f0.6)", sum(dp1) + 0.25d0 * cnt
end program main
