N=int(input())
A=list(map(int,input().split()))
cnt=0
a=N//2
for i in range(1,a+1):
  if (2*i-1==A[2*i-2]) or (2*i==A[2*i-1]):
    cnt+=1
if N%2==0:
  print(cnt)
else:
  if A[0]==1 and A[-1]==N:
    print(cnt+1)
  elif A[-1]!=N:
    print(cnt)
  else:
    cnta=0
    for i in range(1,a+1):
      if (2*i==A[2*i-1]) or (2*i+1==A[2*i]):
        cnta+=1
    print(min(cnt,cnta))