      program sp805     	! AS data for 20000 events
      implicit none
      integer i, j

      character dummy*10
      integer Ns, hh1,mm1,ss1,ms1, hh2,mm2,ss2,ms2
      integer s1,  s2,  ds12
      parameter( Ns = 20000 )

      real*8 sum, deltaT
      parameter( deltaT=3600 )
      data   sum / 0d0 /
      integer iCNT,CNTperHOUR(10000)
      data         CNTperHOUR/10000*0/

      integer day, hou, min, sec
      real*8 ave

      open(1,file='070109.DAT')

      read(1,*) dummy
      read(1,*) dummy
      read(1,*) dummy

      read(1, '(3i2,i7)') hh1,mm1,ss1,ms1
        s1  = hh1*60*60 + mm1*60 + ss1

      do i=1,Ns-1

        read(1, '(3i2,i7)') hh2,mm2,ss2,ms2
        s2  = hh2*60*60 + mm2*60 + ss2
        ds12= s2 - s1
        if(ds12.lt.0) then
            ds12 = ds12 + 24*60*60
        endif

        sum = sum + ds12
        iCNT= ___ / ______ + _
        CNTperHOUR(iCNT) = __________(____) + _

        hh1 = hh2
        mm1 = mm2
        ss1 = ss2
        ms1 = ms2
        s1  = s2
      enddo

      close(1)

      write(*,'(4x,a5,f12.1,a4)')'sum =',sum,' sec'

      day =   sum/(24*60*60)
      hou =  (sum-day*24*60*60)/(60*60)
      min = ((sum-day*24*60*60)-hou*60*60)/60
      sec = ((sum-day*24*60*60)-hou*60*60)-min*60
      write(*,'(4x,4(i3,a1))') day,'d',hou,'h',min,'m',sec,'s'

      ave = sum / ( Ns - 1 ) 
      write(*,'(4x,a5,1pe12.5,a4,i10)') 'ave =',ave,' sec',  iCNT

      open(2,file='sp805.dat')
      do j=1,iCNT
        write(2,*) j+0.5, CNTperHOUR(j)
      enddo
      close(2)

      stop
      end