#include <bits/stdc++.h>
using namespace std;
int I;
vector<int> cycle[100005];
int p[100005];
bool vis[100005];
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = true;
  cycle[I].push_back(u);
  dfs(p[u]);
}
int main() {
  I = 0;
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  int bicenter = -1;
  int unicenter = -1;
  int center, bcenter[2];
  for (int u = 0; u < N && unicenter == -1; u++) {
    if (!vis[u]) {
      dfs(u);
      if (cycle[I].size() == 1) {
        unicenter = I;
        center = u;
      }
      if (cycle[I].size() == 2) {
        bicenter = I;
        bcenter[0] = cycle[I][0];
        bcenter[1] = cycle[I][1];
      }
      I++;
    }
  }
  if (unicenter != -1) {
    printf("YES\n");
    for (int u = 0; u < N; u++) {
      if (u == center) continue;
      printf("%d %d\n", u + 1, center + 1);
    }
  } else if (bicenter != -1) {
    bool good = true;
    for (int i = 0; i < I && good; i++)
      if (cycle[i].size() % 2 == 1) good = false;
    if (!good) {
      printf("NO\n");
    } else {
      printf("YES\n");
      printf("%d %d\n", bcenter[0] + 1, bcenter[1] + 1);
      for (int i = 0; i < I; i++) {
        if (i == bicenter) continue;
        for (int j = 0; j < cycle[i].size(); j++) {
          printf("%d %d\n", cycle[i][j] + 1, bcenter[j % 2] + 1);
        }
      }
    }
  } else {
    printf("NO\n");
  }
}
