The ans I am getting is right but its still failing all the test cases?
Can you tell what's wrong with my code?
Change this in your code
int s=a[n-1];
Why initialising s with a[0] is wrong?
minimum ans can be the max element in the original array.