#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int main() {
  int n;
  cin >> n;
  int i, j, k;
  int flag = 0;
  int index = 0;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == i) index = i;
  }
  if (index) {
    cout << "YES" << endl;
    for (i = 1; i <= n; i++) {
      if (index != i) cout << index << ' ' << i << endl;
    }
    return 0;
  }
  for (i = 1; i <= n; i++) {
    if (i == arr[arr[i]]) index = i;
  }
  int visited[n + 1];
  int ans[n + 1][2];
  memset(ans, 0, sizeof(ans));
  memset(visited, 0, sizeof(visited));
  int s = 0;
  int currindex;
  if (index) {
    visited[index] = 1;
    visited[arr[index]] = 1;
    for (i = 1; i <= n; i++) {
      s = 0;
      if (!visited[i]) {
        currindex = i;
        ans[i][s]++;
        visited[i] = 1;
        s ^= 1;
        currindex = arr[i];
        while (currindex != i) {
          ans[currindex][s] = 1;
          s ^= 1;
          visited[currindex] = 1;
          currindex = arr[currindex];
        }
        if (s) {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
    cout << "YES" << endl;
    cout << index << ' ' << arr[index] << endl;
    for (i = 1; i <= n; i++) {
      if (ans[i][0]) {
        cout << index << ' ' << i << endl;
      }
      if (ans[i][1]) {
        cout << arr[index] << ' ' << i << endl;
      }
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
