C+
C NAME:
C	ArrI8GetMinMax
C PURPOSE:
C	Get min and max of integer*8 array
C CALLING SEQUENCE:
	subroutine ArrI8GetMinMax(N,A,AMin,AMax)
C CALLS:
C	BadI8
C SEE ALSO:
C	Array_Info
C-
	    integer	N
	    integer*8	A(*)
	    integer*8	AMin
	    integer*8	AMax

	integer*8	BadI8
	integer*8	ibad

	ibad = BadI8()

	if (N .gt. 0) then		! Check all elements
	    AMin = A(1)			! Pick up initial values
	    AMax = A(1)
	    do I=2,N			! Loop over rest of array
		AMin = min(AMin,A(I))
		AMax = max(AMax,A(I))
	    end do

	else if (N .lt. 0) then		! Exclude ibad values
	    AMin = ibad			! Initialize to 'bad' value
	    AMax = ibad

	    I = 1			! Find first non-ibad value
	    do while (I .le. -N .and. A(I) .eq. ibad)
		I = I+1
	    end do

	    if (I .le. -N) then		! Non-ibad value found
		AMin = A(I)		! Initialize
		AMax = A(I)
		J = I+1
		do I=J,-N		! Loop over rest of array
		    if (A(I) .ne. ibad) then
			AMin = min(AMin,A(I))
			AMax = max(AMax,A(I))
		    end if
		end do
	    end if

	else
	    AMin = ibad			! Initialize to 'bad' value
	    AMax = ibad

	end if

	return
	end
