public int getLengthOfMaxBitonicSubArray(int[] a)
			throws IllegalArgumentException {

		if (a == null || a.length == 0) {
			throw new IllegalArgumentException();
		}

		/*
		 * Keep track of sequence lengths:
		 * (1) from low to high: check a[i] <= a[i + 1] condition
		 * (2) from high to low: check a[i] >= a[i - 1] condition
		 */
		int[] inc = new int[a.length];
		int[] dec = new int[a.length];

		/* 
		 * Value of inc[i]: length of monotically increasing sequence
		 * ending at position i
		 */
		inc[0] = 1;
		for (int i = 1; i < a.length; i++) {
			if (a[i] > a[i - 1]) {
				inc[i] = inc[i - 1] + 1;
			} else {
				inc[i] = 1;
			}
		}

		/* 
		 * Value of inc[i]: length of monotically decreasing sequence
		 * starting at position i
		 */

		dec[a.length - 1] = 1;
		for (int i = a.length - 2; i >= 0; i--) {
			if (a[i + 1] < a[i]) {
				dec[i] = dec[i + 1] + 1;
			} else {
				dec[i] = 1;
			}
		}

		/* To compute the MAXIMUM LENGTH of any bitonic sequence
		 * in the array, traverse EVERY i, compute inc[i] + dec[i], and
		 * keep track of the MAXIMUM sum observed.
		 */
		int maxLength = 0;
		for (int i = 0; i < a.length; i++) {
			if (inc[i] + dec[i] - 1 > maxLength) {
				maxLength = inc[i] + dec[i] - 1;
			}
		}

		return maxLength;
	}