#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, mark[MAXN], a[MAXN];
int Check(int x) {
  int ans = 0;
  while (mark[x] == 0) {
    mark[x] = 1;
    x = a[x];
    ans++;
  }
  return ans;
}
void PRINT(int x, int y) {
  if (mark[x] && mark[y]) return;
  mark[x] = mark[y] = 1;
  printf("%d %d\n", x, y);
  PRINT(a[x], a[y]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    if (mark[a[i]] == 0)
      if (Check(a[i]) == 1) {
        printf("YES\n");
        for (int j = 1; j <= n; j++)
          if (a[j] != a[i]) printf("%d %d\n", a[i], a[j]);
        return 0;
      }
  int tmp = -1;
  fill(mark, mark + n + 1, 0);
  for (int i = 1; i <= n; i++)
    if (mark[a[i]] == 0) {
      int x = Check(a[i]);
      if (x == 2) tmp = a[i];
      if (x % 2) {
        printf("NO");
        return 0;
      }
    }
  if (tmp == -1) {
    printf("NO");
    return 0;
  }
  fill(mark, mark + n + 1, 0);
  printf("YES\n");
  mark[tmp] = mark[a[tmp]] = 1;
  printf("%d %d\n", tmp, a[tmp]);
  for (int i = 1; i <= n; i++)
    if (mark[i] == 0) PRINT(tmp, a[i]);
  return 0;
}
