#include <bits/stdc++.h>
using namespace std;
int p[100010], n, pos, po, odd;
vector<vector<int> > v;
bool vis[100010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  pos = po = -1;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    vector<int> vs;
    int j = i;
    while (!vis[j]) {
      vs.push_back(j);
      vis[j] = 1;
      j = p[j];
    }
    v.push_back(vs);
    if (vs.size() == 1) pos = i;
    if (vs.size() == 2) po = v.size() - 1;
    if (vs.size() > 2 && (vs.size() & 1)) odd = 1;
  }
  if (pos != -1) {
    puts("YES");
    for (int i = 1; i <= n; i++) {
      if (i != pos) {
        printf("%d %d\n", i, pos);
      }
    }
    return 0;
  }
  if (odd || po == -1) {
    puts("NO");
    return 0;
  }
  puts("YES");
  printf("%d %d\n", v[po][0], v[po][1]);
  for (int i = 0; i < v.size(); i++) {
    if (i == po) continue;
    for (int j = 0, k = 0; j < v[i].size(); j++, k ^= 1) {
      printf("%d %d\n", v[i][j], v[po][k]);
    }
  }
  return 0;
}
