private static int halfNum(int [] input){
int count = 1;
int temp = input[0];
for(int i=1;i<input.length;i++){
if(temp == input[i]){
count++;
}else{
count--;
if(count == 0){
count = 1;
temp = input[i];
}
}
}
return count > input.length/2 ? temp :0;
}