N = gets.to_i A = gets.split.map(&:to_i) cnt = 0 N.times do |i| a = A[i] b = A[(i + 1) % N] cnt += 1 if a > b end puts [2, cnt].min