#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
bool pass[100000 + 5];
vector<vector<int> > circle;
int work[100000 + 5], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &work[i]);
  int pos1 = -1, pos2 = -1;
  int is_odd = 0;
  for (int i = 1; i <= n; ++i) {
    if (pass[i]) continue;
    vector<int> v;
    int j = i;
    while (!pass[j]) {
      pass[j] = true;
      v.push_back(j);
      j = work[j];
    }
    circle.push_back(v);
    if (v.size() == 1) pos1 = i;
    if (v.size() == 2) pos2 = circle.size() - 1;
    if (v.size() > 2 && (v.size() & 1)) is_odd = 1;
  }
  if (pos1 != -1) {
    printf("YES\n");
    for (int i = 1; i <= n; ++i)
      if (i != pos1) {
        printf("%d %d\n", i, pos1);
      }
    return 0;
  }
  if (is_odd || pos2 == -1) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  printf("%d %d\n", circle[pos2][0], circle[pos2][1]);
  for (int i = 0; i < circle.size(); ++i) {
    if (i != pos2)
      for (int j = 0; j < circle[i].size(); ++j) {
        printf("%d %d\n", circle[i][j], circle[pos2][j % 2]);
      }
  }
  return 0;
}
