#include <bits/stdc++.h>
using namespace std;
const int MAXN = 111111;
int n, cnt;
int a[MAXN];
bool f[MAXN];
vector<int> p[MAXN];
void dfs(int x) {
  p[cnt].push_back(x);
  f[x] = true;
  if (!f[a[x]]) dfs(a[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  if (n == 2) {
    puts("YES\n1 2\n");
    return 0;
  }
  memset(f, false, sizeof(f));
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == i) {
      printf("YES\n");
      for (int j = 1; j <= n; j++)
        if (i != j) printf("%d %d\n", i, j);
      return 0;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!f[i]) {
      cnt++;
      dfs(i);
    }
  if (cnt == 1) {
    puts("NO");
    return 0;
  }
  for (int i = 1; i <= cnt; i++)
    if (p[i].size() & 1) {
      puts("NO");
      return 0;
    }
  bool haveans = false;
  int hhh = 0;
  for (int i = 1; i <= cnt; i++)
    if (p[i].size() == 2) {
      haveans = true;
      hhh = i;
    }
  if (!haveans) {
    puts("NO");
    return 0;
  }
  printf("YES\n");
  for (int i = 1; i <= cnt; i++)
    if (i != hhh)
      for (unsigned j = 0; j < p[i].size(); j++)
        printf("%d %d\n", p[i][j], p[hhh][j & 1]);
  printf("%d %d\n", p[hhh][0], p[hhh][1]);
  return 0;
}
