#include <bits/stdc++.h>
using namespace std;
int sc[100001];
int ori[100001];
int main() {
  int n;
  memset(sc, -1, sizeof(sc));
  memset(ori, -1, sizeof(ori));
  cin >> n;
  bool a1 = false;
  int c1;
  for (int i = 0; i < n; i++) {
    cin >> ori[i + 1];
    if (ori[i + 1] == i + 1) {
      a1 = true;
      c1 = i + 1;
    }
  }
  if (a1) {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) {
      if (i != c1) cout << i << " " << c1 << endl;
    }
  } else {
    int c2, c3;
    bool a2 = false;
    for (int i = 1; i <= n; i++) {
      if (sc[i] == -1) {
        int h = 1;
        sc[i] = 1;
        int next = ori[i];
        while (next != i) {
          h++;
          sc[next] = h;
          next = ori[next];
        }
        if (h == 2) {
          a2 = true;
          c2 = i;
          c3 = ori[i];
        }
        if (h % 2 == 1) {
          a2 = false;
          break;
        }
      }
    }
    if (a2) {
      cout << "YES" << endl;
      cout << c2 << " " << c3 << endl;
      for (int i = 1; i <= n; i++) {
        if (i != c2 && i != c3) {
          if (sc[i] % 2 == 1)
            cout << i << " " << c2 << endl;
          else
            cout << i << " " << c3 << endl;
        }
      }
    } else
      cout << "NO" << endl;
  }
  return 0;
}
