#include <bits/stdc++.h>
using namespace std;
int n, p[100005], ep = 0;
vector<int> cir[100005];
bool vis[100005];
void dfs(int k) {
  while (!vis[k]) {
    cir[ep].push_back(k);
    vis[k] = true;
    k = p[k];
  }
  ep++;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int fg = 0;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    if (i == p[i]) fg = i;
  }
  if (fg) {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++)
      if (i != fg) cout << fg << ' ' << i << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  bool fg2 = 0;
  int z = 0;
  for (int i = 0; i < ep; i++) {
    if (cir[i].size() == 2) fg2 = true, z = i;
    if (cir[i].size() % 2) {
      fg2 = false;
      break;
    }
  }
  if (!fg2)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    cout << cir[z][0] << ' ' << cir[z][1] << endl;
    for (int i = 0; i < ep; i++) {
      if (i == z) continue;
      for (int j = 0; j < cir[i].size(); j++)
        cout << cir[z][j % 2] << ' ' << cir[i][j] << endl;
    }
  }
  return 0;
}
