#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
vector<int> g[100500];
int vis[100500], a[100500];
int n, one, two;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      int x = i;
      while (!vis[x]) {
        vis[x] = 1;
        g[i].push_back(x);
        x = a[x];
      }
      if ((int)g[i].size() == 1) one = i;
      if ((int)g[i].size() == 2) two = i;
    }
  if (one) {
    puts("YES");
    for (int i = 1; i <= n; i++)
      if (i != one) printf("%d %d\n", i, one);
  } else if (two) {
    int gg = 0;
    for (int i = 1; i <= n; i++)
      if (((int)g[i].size()) & 1) gg = 1;
    if (!gg) {
      puts("YES");
      printf("%d %d\n", two, a[two]);
      for (int i = 1; i <= n; i++)
        if (g[i].size() && i != two) {
          for (int j = 0; j < (int)g[i].size(); j++)
            printf("%d %d\n", g[two][j & 1], g[i][j]);
        }
    } else
      puts("NO");
  } else
    puts("NO");
  return 0;
}
