#include <bits/stdc++.h>
using namespace std;
int vec[100100], n;
bool mark[100100];
vector<int> qx;
int dfs(int u) {
  qx.push_back(u);
  mark[u] = 1;
  int r = 1;
  if (!mark[vec[u]]) r += dfs(vec[u]);
  return r;
}
set<pair<int, int> > ed;
vector<pair<int, int> > ans;
vector<vector<int> > cyc;
int main() {
  cin >> n;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    vec[x] = i + 1;
  }
  bool ok = 1;
  int root = -1;
  for (int i = 1; ok && i <= n; i++)
    if (!mark[i]) {
      qx.clear();
      int rx = dfs(i);
      if (rx == 1) {
        root = i;
      }
      cyc.push_back(qx);
    }
  if (root != -1) {
    cout << "YES\n";
    for (int i = 1; i <= n; i++)
      if (i != root) {
        cout << i << " " << root << '\n';
      }
    return 0;
  }
  ok = 0;
  for (int i = 0; i < cyc.size(); i++) {
    if (cyc[i].size() == 2) {
      ok = 1;
      for (int j = 0; j < cyc.size(); j++)
        if (i != j) {
          if (cyc[j].size() % 2 != 0) ok = false;
          for (int h = 0; h < cyc[j].size(); h++)
            ans.push_back(pair<int, int>(cyc[i][h % 2], cyc[j][h]));
        }
      ans.push_back(pair<int, int>(cyc[i][0], cyc[i][1]));
      break;
    }
  }
  if (!ok)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < ans.size(); i++)
      cout << ans[i].first << ' ' << ans[i].second << '\n';
  }
  return 0;
}
