#include <bits/stdc++.h>
using namespace std;
int next_int() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) {
    c = getchar();
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  return x;
}
const int max_n = 1e5;
int n, a[max_n];
int main() {
  n = next_int();
  for (int i = 0; i < n; i++) {
    a[i] = next_int();
    a[i]--;
  }
  for (int i = 0; i < n; i++)
    if (a[i] == i) {
      printf("YES\n");
      for (int j = 0; j < n; j++)
        if (i != j) {
          printf("%d %d\n", i + 1, j + 1);
        }
      return 0;
    }
  vector<vector<int>> c;
  for (int i = 0; i < n; i++) {
    static vector<char> used(n);
    if (used[i]) {
      continue;
    }
    vector<int> tmp = {i};
    while (!used[tmp.back()]) {
      used[tmp.back()] = true;
      tmp.push_back(a[tmp.back()]);
    }
    tmp.pop_back();
    if (tmp.size() & 1) {
      printf("NO");
      return 0;
    }
    c.push_back(tmp);
    if (tmp.size() == 2) {
      swap(c[0], c.back());
    }
  }
  if (c[0].size() != 2) {
    printf("NO");
    return 0;
  }
  printf("YES\n%d %d", c[0][0] + 1, c[0][1] + 1);
  for (vector<int> a : c) {
    if (a == c[0]) {
      continue;
    }
    static int i = 0;
    for (int j : a) {
      printf("\n%d %d", c[0][i] + 1, j + 1);
      i = 1 - i;
    }
  }
}
