#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmax(T& a, const T& b) {
  return a < b ? (a = b, true) : false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  return b < a ? (a = b, true) : false;
}
int N;
vector<int> A;
bool vis[100001];
void dfs(int curr, vector<int>& v) {
  if (vis[curr]) return;
  vis[curr] = true;
  v.push_back(curr);
  return dfs(A[curr], v);
}
int main() {
  scanf("%d", &N);
  A.assign(N + 1, 0);
  for (int i = (int)(1); i < (int)(N + 1); i++) {
    scanf("%d", &A[i]);
  }
  for (int i = (int)(1); i < (int)(N + 1); i++) {
    if (A[i] == i) {
      puts("YES");
      for (int j = (int)(1); j < (int)(N + 1); j++)
        if (j != i) {
          printf("%d %d\n", i, j);
        }
      return 0;
    }
  }
  for (int i = (int)(1); i < (int)(N + 1); i++) {
    if (A[A[i]] == i) {
      int x = i, y = A[i];
      vis[x] = vis[y] = true;
      vector<pair<int, int> > ans;
      ans.push_back(make_pair(x, y));
      bool ok = true;
      for (int j = (int)(1); j < (int)(N + 1); j++) {
        vector<int> v;
        dfs(j, v);
        if (v.size() % 2) {
          ok = false;
          break;
        }
        for (int i = (int)(0); i < (int)(v.size()); i++) {
          if (i % 2 == 0) {
            ans.push_back(make_pair(x, v[i]));
          } else {
            ans.push_back(make_pair(y, v[i]));
          }
        }
      }
      if (ok == false) break;
      puts("YES");
      for (int i = (int)(0); i < (int)(ans.size()); i++) {
        printf("%d %d\n", ans[i].first, ans[i].second);
      }
      return 0;
    }
  }
  puts("NO");
  return 0;
}
