#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
bool vis[100010];
vector<int> v[100010];
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    memset(vis, 0, sizeof vis);
    int one = -1, two = -1;
    int ct = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[i]) continue;
      int z = i;
      do {
        v[ct].push_back(z);
        vis[z] = 1;
        z = a[z];
      } while (z != i);
      if (v[ct].size() == 1) one = i;
      if (v[ct].size() == 2) two = ct;
      ct++;
    }
    if (one >= 0) {
      puts("YES");
      for (int i = 1; i <= n; i++) {
        if (i != one) printf("%d %d\n", one, i);
      }
    } else if (two >= 0) {
      bool ok = 1;
      for (int i = 0; i < ct; i++) {
        if (v[i].size() % 2 != 0) {
          ok = 0;
          break;
        }
      }
      if (!ok)
        puts("NO");
      else {
        puts("YES");
        printf("%d %d\n", v[two][0], v[two][1]);
        for (int i = 0; i < ct; i++) {
          if (i == two) continue;
          for (int j = 0; j < v[i].size(); j++) {
            if (j & 1)
              printf("%d %d\n", v[two][1], v[i][j]);
            else
              printf("%d %d\n", v[two][0], v[i][j]);
          }
        }
      }
    } else {
      puts("NO");
    }
  }
  return 0;
}
