private static long getMinimaOfAND(long[] arr) {

        int maxLen = 0;
        String[] bin = new String[arr.length];
        for (int i = 0; i < arr.length; i++) {
            bin[i] = Long.toBinaryString(arr[i]);
            if(bin[i].length() > maxLen) {
                maxLen = bin[i].length();
            }
        }
        
        String andRet = "";
        for (int i = 0; i < maxLen; i++) {
            
            boolean found0 = false;
            for (int j = 0; j < bin.length; j++) {
                
                int index = bin[j].length() - i - 1;
                if(index >=0) {
                    char c = bin[j].charAt(index);
                    if(c == '0') {
                        found0 = true;
                        break;
                    }
                } else {
                    found0 = true;
                    break;
                }
            }
            
            if(found0) {
                andRet = "0" + andRet;
            } else {
                andRet = "1" + andRet;
            }
        }
        
        return Long.parseLong(andRet, 2);
    }