#include <bits/stdc++.h>
using namespace std;
int n, p[100010];
int ansx[100010], ansy[100010];
map<int, int> mp[100010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    if (p[i] == i) {
      printf("YES\n");
      for (int j = 1; j <= n; j++) {
        if (j != i) {
          printf("%d %d\n", i, j);
        }
      }
      return 0;
    }
  }
  if (n & 1) {
    printf("NO\n");
    return 0;
  }
  int x = -1, y = -1;
  int aim = -1;
  for (int i = 1; i <= n; i++) {
    if (i == p[p[i]]) {
      x = i, y = p[i];
      break;
    }
    aim = p[i];
  }
  if (x == -1 || y == -1) {
    printf("NO\n");
    return 0;
  }
  int cnt = 0;
  ansx[++cnt] = x;
  ansy[cnt] = y;
  mp[x][y] = 1;
  mp[y][x] = 1;
  for (int i = 1; i <= n; i++) {
    if (mp[i][x] || mp[i][y]) continue;
    int tx = p[x], ty = p[i];
    while (true) {
      if (mp[tx].count(ty)) break;
      ansx[++cnt] = tx;
      ansy[cnt] = ty;
      mp[tx][ty] = 1;
      mp[ty][tx] = 1;
      tx = p[tx];
      ty = p[ty];
    }
  }
  if (cnt >= n || cnt < n - 1) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (int i = 1; i <= n - 1; i++) {
      printf("%d %d\n", ansx[i], ansy[i]);
    }
  }
  return 0;
}
