#include <bits/stdc++.h>
const int N = 100010;
using namespace std;
int n;
int tmp = 0;
int a[N], vis[N], p[N][2];
void READ() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}
int CHK(int A, int B) {
  for (int i = 1; i <= n; i++) {
    if (vis[i] || i == A || i == B) continue;
    int pos = i, cnt = 0;
    while (!vis[pos]) {
      vis[pos] = 1;
      tmp++;
      cnt++;
      if (cnt & 1)
        p[tmp][0] = A, p[tmp][1] = pos;
      else
        p[tmp][0] = B, p[tmp][1] = pos;
      pos = a[pos];
    }
    if (cnt & 1) return 0;
  }
  printf("YES\n");
  printf("%d %d\n", A, B);
  for (int i = 1; i <= tmp; i++) printf("%d %d\n", p[i][0], p[i][1]);
  return 1;
}
int SOLVE() {
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) {
      printf("YES\n");
      for (int j = 1; j <= n; j++)
        if (j != i) printf("%d %d\n", j, i);
      return 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[a[i]] == i) return CHK(a[i], i);
  }
  return 0;
}
int main() {
  READ();
  if (SOLVE() == 0) printf("NO\n");
  return 0;
}
