public void MedianMaintanance() {
		int maxLowHalf = 0; // then this heap is null
		int minHighHalf = 10001; // when this heap is null
		int curElement = 0;

		for (int i = 0; i < this.arrayLen; i++) {
			// insert i;
			curElement = originalArray[i];
			if (lowHalf.peek() != null)
				maxLowHalf = lowHalf.peek();
			if (highHalf.peek() != null)
				minHighHalf = highHalf.peek();

			if (curElement < maxLowHalf) {// insert to lower half
				lowHalf.add(curElement);
			} else if (curElement > minHighHalf) {
				highHalf.add(curElement);
			} else {// maxLowHalf<= curElement <=minHighHalf, put in highHalf,
					// will re-balance later
				highHalf.add(curElement);
			}

			// re-balance the two heaps if needed;
			if (highHalf.size() - lowHalf.size() > 1) {
				lowHalf.add(highHalf.poll());
			}else if(lowHalf.size()-highHalf.size() > 0){ //always make lowHalf the smaller set
				highHalf.add(lowHalf.poll());
			}

			// get the current median;
			//because the two heaps are balanced, so their size difference should <1;
			if (lowHalf.size() < highHalf.size()) {
				medianArray[i] = highHalf.peek();
			} else {
				medianArray[i] = lowHalf.peek();
			}
		}
	}