#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
int a[M], mark[M];
int32_t main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == i) {
      cout << "YES" << endl;
      for (int j = 1; j <= n; j++)
        if (i != j) cout << i << ' ' << j << endl;
      return 0;
    }
  }
  int ras = 0;
  for (int i = 1; i <= n; i++) {
    if (mark[i]) continue;
    if (i == a[a[i]]) ras = i;
    int p = a[i];
    mark[i] = 1;
    int len = 1;
    while (p != i) {
      mark[p] = 1, len++;
      p = a[p];
    }
    if (len & 1) return cout << "NO" << endl, 0;
  }
  if (!ras) return cout << "NO" << endl, 0;
  cout << "YES" << endl;
  cout << ras << ' ' << a[ras] << endl;
  memset(mark, 0, sizeof mark);
  mark[ras] = mark[a[ras]] = 1;
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      cout << i << ' ' << ras << endl;
      mark[i] = 1;
      int p = a[i];
      int l = 0;
      while (p != i) {
        mark[p] = 1;
        cout << p << ' ';
        if (l & 1)
          cout << ras;
        else
          cout << a[ras];
        cout << endl;
        p = a[p];
        l++;
      }
    }
  return 0;
}
