program main
implicit None
	integer(8)::n,i,p(2),q(2),r(2),s(2)
	integer(8),allocatable::v(:),a(:),b(:)
	
	read*,n
	allocate(v(n),a(n/2),b(n/2))
	
	read*,v
	n = n/2
	if(minval(v) == maxval(v))then
		print 101,n
		stop
	endif
	
	do i = 1,n
		a(i) = v(i*2-1)
		b(i) = v(i*2)
	enddo
	
	call h1(a,n)
	call h1(b,n)
	
	p =0;q =0;r =0;s =0
	
	call a1(a,n,p,q)
	call a1(b,n,r,s)
	
	if(q(1) /= s(1))then
		print 101,2*n-p(1)-r(1)
		stop
	endif
	
	if(p(1)+r(2) > p(2)+r(1))then
		print 101,2*n-p(1)-r(2)
		else
			print 101,2*n-p(2)-r(1)
	endif
	
101 format(i0)
end program main

subroutine h1(a,n)
implicit None
	integer(8)::a(n),x
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie)
		a(ie) = a(1)
		a(1) = x
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h1

subroutine a1(a,n,p,q)
Implicit None
integer(8)::n,p(2),q(2),i,t=1
integer(8)::a(n)
	do i = 2,n
		if(a(i) == a(i-1))then
			t = t+1
			else
			if (t > p(1))then
				p(2) = p(1)
				p(1) = t
				q(2) = q(1)
				q(1) = a(i-1)
				t = 1
				else if(t > p(2))then
				p(2) = t
				q(2) = a(i-1)
				t = 1
			endif
		endif
	enddo
	
	if (t > p(1))then
		p(2) = p(1)
		p(1) = t
		q(2) = q(1)
		q(1) = a(i-1)
		t = 1
		else if(t > p(2))then
		p(2) = t
		q(2) = a(i-1)
		t = 1
	endif
end subroutine a1