#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int p[N], used[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; i++) {
    if (p[i] == i) {
      cout << "YES\n";
      for (int j = 1; j <= n; j++) {
        if (i == j) continue;
        cout << i << " " << j << "\n";
      }
      return;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    int j = i, length = 0;
    while (!used[j]) {
      used[j] = 1;
      length++;
      j = p[j];
    }
    if (length & 1) {
      cout << "NO";
      return;
    }
  }
  memset(used, 0, sizeof used);
  for (int i = 1; i <= n; i++) {
    int j = p[i];
    if (p[j] == i) {
      cout << "YES\n";
      cout << i << " " << j << "\n";
      for (int l = 1; l <= n; l++) {
        if (l == i || l == j || used[l]) continue;
        int v = l, xr = 0;
        while (!used[v]) {
          used[v] = 1;
          cout << v << " " << (xr == 0 ? i : j) << "\n";
          xr ^= 1;
          v = p[v];
        }
      }
      return;
    }
  }
  cout << "NO";
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  solve();
}
