#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, p[maxn];
bool used[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", p + i);
    p[i] -= 1;
  }
  vector<vector<int>> cycles;
  for (int i = 0; i < n; ++i)
    if (!used[i]) {
      used[i] = true;
      cycles.push_back({i});
      for (int j = p[i]; j != cycles.back().front(); j = p[j]) {
        used[j] = true;
        cycles.back().push_back(j);
      }
    }
  for (auto& c : cycles)
    if (c.size() == 1) {
      puts("YES");
      for (int i = 0; i < n; ++i)
        if (i != c.front()) printf("%d %d\n", i + 1, c.front() + 1);
      return 0;
    }
  for (auto& c : cycles)
    if (c.size() % 2 == 1) {
      puts("NO");
      return 0;
    }
  for (size_t i = 0; i < cycles.size(); ++i)
    if (cycles[i].size() == 2) {
      puts("YES");
      printf("%d %d\n", cycles[i][0] + 1, cycles[i][1] + 1);
      for (size_t j = 0; j < cycles.size(); ++j)
        if (j != i) {
          for (size_t k = 0; k < cycles[j].size(); ++k)
            printf("%d %d\n", cycles[j][k] + 1, cycles[i][k % 2] + 1);
        }
      return 0;
    }
  puts("NO");
}
