fork download
  1. n=int(input())
  2. l=list(map(int,input().split()))
  3. x="{0:063b}"
  4. for i in range(n):
  5. l[i] = x.format(l[i])# we are converting every element to it's binary form
  6. #with 63 length.
  7.  
  8. c=[0]*63
  9. for i in l:
  10. for j in range(63):
  11. c[j]+=int(i[j]) # counting number of 1 for every bits.
  12. # now for every bit, number of 1 is c[i] and number of 0 is n-c[i].
  13. #no we have to make our ans, so for any bit if number of 0 is greater than number of
  14. #number of 1 then we have to choose 1 , if no of 1 is gretaer than we will choose
  15. # 0 and in case if both no of 1 and 0 are equal we can choose either 1 or 0 ,
  16. # but we will choose 0 , as we have to find minimum x.
  17. ans=""
  18. for i in range(63):
  19. if c[i]>=n-c[i]:
  20. ans+='0'
  21. else:
  22. ans+='1'
  23. print(int(ans,2))
  24.  
Success #stdin #stdout 0.02s 9552KB
stdin
5
10 12 5 7 19
stdout
9223372036854775800