_,b,*a=$<.read.split.map &:to_f x=y=0 a.map{|e|x+=a*b**(a-1);y+=a!=-1?b**(a+1)/(a+1):Math.log(b)} p x p y