import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Solution {
    public int MoreThanHalfNum_Solution(int [] array) {
        if(array == null || array.length == 0){
            return -1;
        }
        return Arrays.stream(array)
            .boxed()
            .collect(Collectors.toMap(e->e,e->1,Integer::sum))
            .entrySet()
            .stream()
            .filter(e->e.getValue() > array.length/2)
            .collect(Collectors.toList())
            .get(0)
            .getKey();
    }
}