#include <bits/stdc++.h>
using namespace std;
int n, x, y, p[100001], was[100001], l[100001], num[100001], xx, yy, tk;
int len;
void dfs(int ver) {
  len++;
  was[ver] = 1;
  num[ver] = len % 2;
  if (!was[p[ver]]) dfs(p[ver]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  xx = -1;
  for (int i = 1; i <= n; i++) {
    if (!was[i]) {
      len = 0;
      dfs(i);
      if (len == 1) {
        cout << "YES" << endl;
        for (int j = 1; j <= n; j++) {
          if (i != j) {
            cout << i << ' ' << j << endl;
          }
        }
        return 0;
      } else if (len == 2) {
        xx = i;
        yy = p[xx];
      } else if (len % 2 == 1) {
        tk++;
      }
    }
  }
  if (tk || xx == -1) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  cout << xx << ' ' << yy << endl;
  for (int i = 1; i <= n; i++) {
    if (num[i] && i != xx && i != yy) {
      cout << xx << ' ' << i << endl;
    } else if (!num[i] && i != xx && i != yy) {
      cout << yy << ' ' << i << endl;
    }
  }
  return 0;
}
