program stream
  integer(8) :: n,m, i, j, k, l, ans
  integer(8),allocatable :: x(:),y(:),z(:),w(:)

  read *, n, m 
  ans = 0
  allocate(x(m),y(m),z(m-1),w(m-1))
  read *, x
  do i = 1, m
    y(i) = minval(x)
    x(minloc(x)) = 200000
  end do

  !print '(i0)', y
  
  do j = 1, m-1
    z(j) = y(j+1) - y(j)
  end do

  !print '(i0)', z
  
  do k = 1, m-1
    w(k) = minval(z)
    z(minloc(z)) = 300000
  end do

  !print '(i0)', w
  
  if (n >= m) then
    print '(i0)', 0
  else
    do l = 1, m-n
      ans = ans + w(l)
    end do
    print '(i0)', ans
  end if
  stop
end program