      subroutine qepsalg(n,s,E)
      real*16 s(n),E(n,n+1)
      write(*,1)
    1 format(/)
      if(n.lt.2) then
        write(*,2)
    2   format(1x,'n too small')
      end if
      do 20 i=1,n
        do 10 j=1,n+1
          E(i,j)=0.q0
   10   continue
   20 continue
      do 30 i=1,n
        E(i,2)=s(i)
   30 continue
      do 50 k=3,n+1
        do 40 m=1,n+2-k
          if(E(m+1,k-1).eq.E(m,k-1)) goto 50
          E(m,k)=E(m+1,k-2)+1.q0/(E(m+1,k-1)-E(m,k-1))
   40   continue
   50 continue
      return
      end
