static int problem1(int[]A,int t) {
		Arrays.sort(A);
		int count=0;
		for (int l=0, r=A.length-1;l<r;) {
			int nl=l+1, nr=r-1;
			while (nl<r&&A[nl]==A[l])++nl;
			if (nl==r) {
				if (A[l]+A[r]==t) count+=(r-l+1)/2;
				break;
			}
			while (nr>l&&A[nr]==A[r])--nr;
			int sum=A[l]+A[r];
			if (sum==t) {count+=Math.min(nl-l, r-nr);l=nl;r=nr;}
			else if (sum<t)l=nl;
			else r=nr;
		}
		return count;
	}