public void sortAndCountOpti(int []array, int lowIndex, int highIndex){
		if(lowIndex==highIndex)
			return;
		
		int midIndex = (lowIndex+highIndex)/2;
		
		this.sortAndCountOpti(array, lowIndex, midIndex);
		this.sortAndCountOpti(array, midIndex+1, highIndex);
		
		int i = lowIndex;
		int j = midIndex+1;
		int n = i;
		while (i <=midIndex && j <=highIndex) {
			if (array[i] <= array[j]) {
				sortedArray[n] = array[i];
				n++;
				i++;
			} else {
				sortedArray[n] = array[j];
				n++;
				j++;
				this.count += midIndex - i + 1;
			}
		}

		// j reaches highIndex first
		for (; i<=midIndex; i++, n++) {
			sortedArray[n] = array[i];
		}

		for (; j <=highIndex; j++, n++) {
			sortedArray[n] = array[j];
		}

		//copy sortedArray back to array for section[lowIndex, highIndex]
		for(int k=lowIndex;k<=highIndex;k++){
			array[k]=sortedArray[k];
		}
	}