program heikin integer(8) a,n,s real(8) b real(8),allocatable :: x(:) read(*,*) n allocate (x(n)) read(*,*) (x(m),m=1,n) call mat(x,n) if (mod(n,2)==1) then s=int(n/2) s=s+1 write(*,*) x(s) else s=n/2 b=(x(s)+x(s+1))/2 write(*,*) b end if end program subroutine mat(x,n) integer(8) n,j,i,t real(8),dimension(n) ::x do i=1,n-1 do j=i+1,n if(x(i) > x(j))then t=x(i) x(i)=x(j) x(j)=t end if end do end do end subroutine