program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,ans=0
    integer(int64), allocatable:: a(:)

    read*, n
    allocate(a(n))
    do i=1,n; read*, a(i); end do
    
    ans = sum(a)
    do i=1,n-1
        if (btest(a(i),0_8)) then
            if (a(i+1)==0) then
                ans=ans-1
            else
                a(i+1)=a(i+1)-1
            end if
        end if
    end do
    print'(i0)', ans/2
end program main