program main
  implicit none
  integer :: i, s[*]
  s = this_image()
  sync all
  if (this_image() == 1) then
    do i = 2, num_images()
      s = s + s[i]
    end do
    print *, "The sum of integers from 1 to", num_images(), "is", s
  end if
end program
