#int(input()) #map(int, input().split()) #list(map(int, input().split())) N = int(input()) S = list(map(int, input().split())) p = [0] * N for i in range(N): p[S[i]-1] = i t = 0 for i in range(N): if p[i] != i: t += 1 q = p[i] u = S[i] S[i], S[q] = S[q], S[i] p[i] = i p[u-1] = q # print(S) print(-(t % 2) * 2 + 1)