Hey buddy your code is messed up , just put your code on ideone and run it and share the link . You can format your code by adding special chacter in the beginning and at end of your code . add ` special character 3 times in start and end . this special chacter is just above tab in standard keyboard and below of esc key .
You are getting wrong answer because you are not taking all the input , as soon as you found first 7 values you break out of loop and remaining elements of array is left , which is giving wrong answer . So take all the input and as soon as your set size becomes 7 store it into ans and print afterwards.