import bisect def solve(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) P = list(map(int, data[1:N+1])) S = [] # Maintained as a sorted list result = [] current_array = P.copy() for i in range(N, 0, -1): possible_js = list(range(1, i + 1, 2)) # Generate 1, 3, 5,... <= i # Try positions in reverse order to avoid shifting issues possible_js.sort(reverse=True) found = False for j in possible_js: pos = j - 1 # Convert to 0-based index if pos >= len(current_array): continue # Skip if position is beyond current array's length candidate = current_array[pos] # Check if candidate is valid (min or second min in S + candidate) valid = False if not S: valid = True else: if len(S) == 1: valid = True else: # S is sorted, so check if candidate <= S[1] if candidate <= S[1]: valid = True if valid: # Remove from current array current_array.pop(pos) # Add to S in sorted order bisect.insort(S, candidate) # Append to result (will be reversed later) result.append((candidate, j)) found = True break if not found: print("No") return # Reverse the result to get the correct order result.reverse() print("Yes") for x, y in result: print(x, y) solve()