@ryuamakusa
I'll quote the lines where u went wrong
>>y12 -2y1+1 + y22 -2y2+4 +....... yn2 -2yn + n2=0
>>now you can group the terms as
>>(y1-1)2 + (y2-2)2 +.......(yn-n)2 =0 ------------(1)
Do think that this step is correct. Can u get that expression by opening the brackets?