#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
int num[N];
struct Node {
  int x, y;
} ans[N];
int vis[N], cnt, flag;
void DFS(int x, int y, int d) {
  if (!flag) return;
  if (vis[y]) {
    if (d % 2) {
      flag = 0;
    }
    return;
  }
  vis[x] = vis[y] = 1;
  ans[cnt++] = (Node){x, y};
  DFS(num[x], num[y], d + 1);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &num[i]);
    }
    int rec1 = 0, rec2 = 0;
    for (int i = 1; i <= n; i++) {
      if (num[i] == i) {
        rec1 = i;
      }
      if (num[num[i]] == i) {
        rec2 = i;
      }
    }
    if (rec1) {
      printf("YES\n");
      for (int i = 1; i <= n; i++) {
        if (i != rec1) {
          printf("%d %d\n", rec1, i);
        }
      }
    } else if (rec2) {
      flag = 1;
      cnt = 0;
      vis[rec2] = vis[num[rec2]] = 1;
      ans[cnt++] = (Node){rec2, num[rec2]};
      for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
          DFS(rec2, i, 0);
        }
      }
      if (!flag) {
        printf("NO\n");
      } else {
        printf("YES\n");
        for (int i = 0; i < cnt; i++) {
          printf("%d %d\n", ans[i].x, ans[i].y);
        }
      }
    } else
      printf("NO\n");
  }
  return 0;
}
