program incenters
  implicit none
  real(8), parameter :: pi = 3.14159265358979d0
  integer :: n, l, t, i, j, k, m = 0
  real(8) :: v(3000,2) = 0.d0, c(2) = 0.d0, s(0:3000,2) = 0.d0, tmp(2)
  real(8) :: di, dj, dk
  character(48) :: sx, sy
  read(*,*) n, l
  do i = 1, n
    read(*,*) t
    v(i,1) = cos(2.d0*pi*real(t,8)/real(l,8))
    v(i,2) = sin(2.d0*pi*real(t,8)/real(l,8))
    s(i,:) = s(i-1,:)+v(i,:)
  end do
  do i = 1, n-2
    do j = i+1, n-1
      if (m > 1000000) then
        tmp = s(n,:)-s(j,:)
        di = d(v(j,:),tmp/real(n-j,8))
        dj = d(tmp/real(n-j,8),v(i,:))
        dk = d(v(i,:),v(j,:))
        c = c+(real(n-j,8)*(di*v(i,:)+dj*v(j,:))+dk*tmp)/(di+dj+dk)
      else
        do k = j+1, n
          m = m+1
          di = d(v(j,:),v(k,:))
          dj = d(v(k,:),v(i,:))
          dk = d(v(i,:),v(j,:))
          c = c+(di*v(i,:)+dj*v(j,:)+dk*v(k,:))/(di+dj+dk)
        end do
      end if
    end do
  end do
  c = 6.d0*c/(real(n,8)*real(n-1,8)*real(n-2,8))
  write(sx,'(f32.16)') c(1)
  write(sy,'(f32.16)') c(2)
  write(*,'(a,x,a)') trim(adjustl(sx)), trim(adjustl(sy))
contains
  real(8) function d(v1,v2)
    real(8), intent(in) :: v1(2), v2(2)
    d = sqrt(dot_product(v1-v2,v1-v2))
  end
end program incenters