program main
  implicit none
  integer :: n, a(100)
  integer :: cons(100)
  read(*, *) n
  read(*, *) a(1:n)
  cons = consecutives(n, a(1:n))
  cons(:) = cons(:) / 2
  write(*, "(i0)") sum(cons)
  contains
  function consecutives(n, a)
    implicit none
    integer, intent(in) :: n, a(n)
    integer :: consecutives(100)
    integer :: i, j, last
    consecutives(:) = 0
    last = 9999999
    j = 0
    do i = 1, n
      if (a(i) /= last) then
        last = a(i)
        j = j + 1
      end if
      consecutives(j) = consecutives(j) + 1
    end do
  end function consecutives
end program main
