#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  scanf("%d", &N);
  int perm[N];
  for (int c = 0; c < N; c++) {
    scanf("%d", &perm[c]);
    perm[c]--;
    if (perm[c] == c) {
      c++;
      cout << "YES" << endl;
      for (int d = 1; d <= N; d++) {
        if (d == c) {
          continue;
        } else {
          cout << c << " " << d << endl;
        }
      }
      return 0;
    }
  }
  bool found2 = false;
  int twoCs;
  bool visited[N];
  for (int c = 0; c < N; c++) {
    visited[c] = false;
  }
  int numVisited = 0;
  int curr = 0;
  while (numVisited < N) {
    while (visited[curr]) {
      curr++;
    }
    int currCycleSize = 0;
    while (!visited[curr]) {
      currCycleSize++;
      numVisited++;
      visited[curr] = true;
      curr = perm[curr];
    }
    if (currCycleSize == 2) {
      found2 = true;
      twoCs = curr;
    }
    if (currCycleSize % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (!found2) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  int twoCs2 = perm[twoCs];
  cout << twoCs + 1 << " " << twoCs2 + 1 << endl;
  visited[twoCs] = false;
  visited[twoCs2] = false;
  numVisited = 2;
  curr = 0;
  while (numVisited < N) {
    while (!visited[curr]) {
      curr++;
    }
    while (visited[curr]) {
      int currN = twoCs;
      if (numVisited % 2 == 1) {
        currN = twoCs2;
      }
      cout << currN + 1 << " " << curr + 1 << endl;
      visited[curr] = false;
      curr = perm[curr];
      numVisited++;
    }
  }
  return 0;
}
