public int MinNumber(int[] S) {
        Arrays.sort(S);
        int max = 0;
        for (int s : S) {
            if (max >= s - 1) {
                max += s;
            } else {
                break;
            }
        }
        return max + 1;

    }