#include <bits/stdc++.h>
using namespace std;
int main() {
  int max;
  cin >> max;
  int p[max + 1];
  for (int i = 1; i <= max; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= max; i++) {
    if (p[i] == i) {
      cout << "YES" << endl;
      for (int j = 1; j <= max; j++) {
        if (i != j) {
          cout << i << " " << j << endl;
        }
      }
      return 0;
    }
  }
  int i = 0;
  int j = 0;
  for (int k = 1; k <= max; k++) {
    if (p[p[k]] == k) {
      i = k;
      j = p[k];
      break;
    }
  }
  if (i == 0) {
    cout << "NO" << endl;
    return 0;
  }
  int arr[max + 1];
  for (int k = 0; k <= max; k++) {
    arr[k] = 0;
  }
  for (int k = 1; k <= max; k++) {
    int t = k;
    while (arr[t] == 0) {
      arr[t] = 1;
      t = p[t];
      if (arr[t] != 0) {
        cout << "NO" << endl;
        return 0;
      }
      arr[t] = 2;
      t = p[t];
    }
  }
  cout << "YES" << endl;
  cout << i << " " << j << endl;
  for (int k = 1; k <= max; k++) {
    if (arr[k] == 1 && k != i && k != j) {
      cout << i << " " << k << endl;
    }
    if (arr[k] == 2 && k != i && k != j) {
      cout << j << " " << k << endl;
    }
  }
  return 0;
}
