Here we know x can only be 1 or -1. so if it is 1 ans is 2.if x is -1, for n even ans will be 2if x is -1 and n is odd ans will ne -2.so we can see evenfor negative x also ans is 2 while sgn you were using would give ans -2 so you can see 2 sgn(x) is wrong.so ans will be 2 ecxept when x is -1 and n is odd then it will be -2.