PROGRAM mesos_oros
  IMPLICIT NONE

  DOUBLE PRECISION :: x, s
  INTEGER  :: n

  PRINT *, "Dwse thetiko arithmo. An dwseis arnhtiko, to diabasma"
  PRINT *, "arithmwn stamata kai ypologizetai o mesos oros twn arithmwn" 
  PRINT *, "poy edwses"
  
  s = 0.0d0
  n = 0
  DO 
     PRINT *, "Dwse arithmo"
     READ *, x
     
     IF (x < 0.0d0) EXIT
     s = s + x
     n = n + 1
  END DO

  IF (n == 0) THEN 
     PRINT *, "Den edwses kanena thetiko!"
  ELSE
     PRINT *, "o mesos oros einai:", s / n
  END IF

END PROGRAM mesos_oros
