static boolean ok(){
        int[] maxIndex = new int[1<<chosenCount];
        maxIndex[0] = -1;
        for(int i=1; i<(1<<chosenCount); i++){
            for(int pos=0; pos<chosenCount; pos++){
                if((i&(1<<pos))!=0){
                    int j = i^(1<<pos);
                    int offset = 0;
                    if(j!=0) offset = sum[maxIndex[j]];
                    int l = maxIndex[j]+1, r=n-1;
                    while(l<r){
                        int mid = (r-l+1)/2+l;
                        if(sum[mid]-offset<=chosen.get(pos)){
                            l = mid;
                        } else{
                            r = mid-1;
                        }
                    }
                    if(l==n-1) return true;
                    maxIndex[i] = Math.max(maxIndex[i],l);
                }
            }
        }
        return false;
    }