public int removeDuplicates(int[] A) {
    	if (A.length == 0) return 0;
    	int n = 0;
        for (int i = 0; i < A.length; i++) {
			int num = A[n];
			while (i<A.length && A[i]==num){
				i++;
			}
			
			if (i<A.length && A[i]!=num){
				n = n+1;
				A[n] = A[i];
			}
		}
        return n+1;
    }