public int longestConsecutive(int[] num) {
		if(num==null || num.length==0) return 0;
		
		Set<Integer> set=new HashSet<Integer>();
		for(int tmp:num){
			set.add(tmp);
		}
		
		int max=0;
		int tmp=0;
		for(int value:num){
			if(set.isEmpty()) break;
			tmp=getCount(set,value,false)+getCount(set,value+1,true);
			if(tmp>max){
				max=tmp;
			}
		}
		return max;
	}