program abc116c
  implicit none
  integer n
  integer, dimension(:), allocatable :: h, a

  read *, n
  allocate(h(n), a(n + 1))
  read *, h
  a = [h, 0] - [0, h]
  print *, sum(a, a > 0)
end program abc116c
