#include <bits/stdc++.h>
using namespace std;
int p[100005], mark[100005];
vector<int> Set[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    int x = i, num = 0;
    if (mark[x]) continue;
    while (!mark[x]) {
      num++;
      mark[x] = 1;
      x = p[x];
    }
    Set[num].push_back(i);
  }
  memset(mark, 0, sizeof(mark));
  if (Set[1].size()) {
    puts("YES");
    int x = Set[1][0];
    for (int i = 1; i <= n; i++)
      if (i != x) printf("%d %d\n", i, x);
  } else if (Set[2].size()) {
    int x = Set[2][0];
    for (int i = 3; i <= n; i += 2)
      if (Set[i].size()) {
        puts("NO");
        return 0;
      }
    puts("YES");
    printf("%d %d\n", x, p[x]);
    for (int i = 2; i <= n; i += 2)
      for (int j = 0; j < Set[i].size(); j++) {
        int y = Set[i][j];
        if (x == y) continue;
        while (!mark[y]) {
          mark[y] = 1;
          printf("%d %d\n", x, y);
          x = p[x];
          y = p[y];
        }
      }
  } else
    puts("NO");
  return 0;
}
