program main
implicit None
	integer(8)::n,i,pa,qa,ra,sa,pb,qb,rb,sb,t
	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(2*i-1)
		b(i) = v(2*i)
	enddo
	
	call a1(a,n,pa,qa,ra,sa)
	call a1(b,n,pb,qb,rb,sb)
	
	if(ra == rb)then
		t = 2*n-pa-pb
		else if(pa-qa > pb-qb)then
		t = 2*n-pa-qb
		else
		t = 2*n-qa-pb
	endif
	
	print 101,t
101 format(i0)
end program main
 
subroutine h2(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 h2
 
subroutine a1(a,n,p,q,r,s)
	integer(8)::n,p,q,r,s,t
	integer(8)::a(n)
	
	call h2(a,n)
	p =0
	q =0
	t =1
	r =0
	s =0
	do i = 2,n
		if(a(i) == a(i-1))then
			t = t + 1
			else
			if(t > p)then
				q = p
				p = t
				s = r
				r = a(i-1)
				t =1
				else if(t > q)then
					q = t
					s = a(i-1)
					t =1
			endif
		endif
	enddo
	
	if(t > p)then
		q = p
		p = t
		s = r
		r = a(i-1)
		else if(t > q)then
			q = t
			s = a(i-1)
	endif
end subroutine a1