public void merge(int[] arr, int p, int q, int r) {

		int length = arr.length;
		int[] tempArray = new int[length];

		for (int i = 0; i < length; i++) {
			tempArray[i] = arr[i];
		}

		int temp = p;
		int i = p, j = q + 1;
		for (; i <= q && j <= r;) {
			if (tempArray[i] < tempArray[j]) {
				arr[temp++] = tempArray[i];
				i++;
			} else {
				// System.out.println("Array indexes p :"+p+" q :"+q+" r :"+r+" i :"+i+" j :"+j);
				n = n + (q + 1) - i;
				arr[temp++] = tempArray[j];
				j++;
			}
		}

		while (i <= q) {
			arr[temp++] = tempArray[i];
			i++;
		}

		while (j < r) {
			arr[temp++] = tempArray[j];
			j++;
		}
	}