#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int arr[100009], vis[100009];
void no() {
  printf("NO\n");
  exit(0);
}
int main() {
  int a;
  scanf("%d", &a);
  for (int i = 1; i <= a; i++) scanf("%d", arr + i);
  int n = -1, m1 = -1, m2 = -1;
  for (int i = 1; i <= a; i++)
    if (arr[i] == i) {
      n = i;
      break;
    }
  if (~n) {
    printf("YES\n");
    for (int i = 1; i <= a; i++)
      if (i != n) printf("%d %d\n", i, n);
    return 0;
  }
  for (int i = 1; i <= a; i++)
    if (arr[arr[i]] == i) {
      m1 = i;
      m2 = arr[i];
      break;
    }
  if (m1 == -1 or m2 == -1) no();
  vis[m1] = vis[m2] = 1;
  vector<int> d[2];
  for (int i = 1; i <= a; i++)
    if (!vis[i]) {
      int cur = arr[i];
      int fr = 1;
      d[fr ^ 1].push_back(i);
      vis[i] = 1;
      while (cur != i) {
        vis[cur] = 1;
        d[fr].push_back(cur);
        fr = (1 - fr);
        cur = arr[cur];
      }
      if (fr) no();
    }
  int kind[] = {m1, m2};
  printf("YES\n%d %d\n", m1, m2);
  for (int i = 0; i < 2; i++)
    for (typeof((d[i]).begin()) it = (d[i]).begin(); it != (d[i]).end(); it++)
      printf("%d %d\n", *it, kind[i]);
  return 0;
}
