#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, v[maxn];
bool visit[maxn];
int dfs(int k) {
  int cnt = 0;
  while (!visit[k]) {
    visit[k] = 1;
    k = v[k];
    ++cnt;
  }
  return cnt;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%d", &v[i]);
    int one = -1, two = -1;
    for (int i = 1; i <= n; ++i) {
      if (v[i] == i) {
        one = i;
        break;
      } else if (v[v[i]] == i) {
        two = i;
      }
    }
    if (one != -1) {
      printf("YES\n");
      for (int k = 1; k <= n; ++k) {
        if (k != one) {
          printf("%d %d\n", one, k);
        }
      }
    } else if (two != -1) {
      if (n & 1) {
        printf("NO\n");
      } else {
        memset(visit, 0, sizeof(visit));
        for (int i = 1; i <= n; ++i) {
          if (visit[i]) continue;
          int w = dfs(i);
          if (w & 1) {
            two = -1;
            break;
          }
        }
        if (two != -1) {
          int a = two, b = v[two];
          printf("YES\n%d %d\n", a, b);
          v[two] = v[v[two]] = -1;
          for (int i = 1; i <= n; ++i) {
            int e = i, s = 0;
            while (v[e] != -1) {
              printf("%d %d\n", s ? b : a, v[e]);
              int t = v[e];
              v[e] = -1;
              s ^= 1;
              e = t;
            }
          }
        } else {
          printf("NO\n");
        }
      }
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
