public int getMajorityElement(int[] a) {
		
		if (a == null || a.length == 0) { throw new IllegalArgumentException();}
		
		/* Initialize potential majority candidate as element at index 0;
		 * Update it every time count decreases to 0 */
		int count = 1;
		int mCandidateIndex = 0;	
		
		/* Phase #1: determine a potential majority candidate */
		for (int i = 1; i < a.length; i++) {
			
			if (a[i] == a[mCandidateIndex]) {
				count += 1;
			}else {
				count -= 1;
			}
			
			if (count == 0) {
				count = 1;
				mCandidateIndex = i;
			}
		
		}
		
		/* Phase #2: Verify if the majority candidate actually is one */
		int mCandidateElement = a[mCandidateIndex];
		int majority = (int) Math.floor(a.length / 2);
		for (int i = 0; i < a.length; i++) {
			if (a[i] == mCandidateElement) {
				count += 1;
			}
		}
		System.out.println("MCandiate: " + mCandidateElement + " Num: " + count + " Maj: " + majority);
		if (count >= majority) {
			return mCandidateElement;	
		}else {
			return -1;
		}
		
		
	}