#include <bits/stdc++.h>
using namespace std;
int g[100001];
bool vis[100001];
int k = 0;
vector<int> cyc[100001];
void dfs(int pre, int x) {
  vis[x] = true;
  if (g[x] == pre) {
    cyc[k].push_back(x);
    return;
  }
  dfs(pre, g[x]);
  cyc[k].push_back(x);
}
int main() {
  int N, X;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> X;
    g[i] = X;
  }
  for (int i = 1; i <= N; i++) {
    if (!vis[i]) {
      dfs(i, i);
      k++;
    }
  }
  int only = -1;
  bool odd = false;
  for (int i = 0; i < k; i++) {
    if (cyc[i].size() == 1 || cyc[i].size() == 2) {
      if (only == -1 || cyc[only].size() == 2) only = i;
    } else {
      if (cyc[i].size() % 2) odd = true;
    }
  }
  if (only == -1 || (cyc[only].size() == 2 && odd)) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (int i = 0; i < k; i++) {
      if (i != only) {
        int cnt = 0;
        for (int j = 0; j < cyc[i].size(); j++) {
          cnt++;
          cnt %= cyc[only].size();
          cout << cyc[i][j] << " " << cyc[only][cnt] << endl;
        }
      }
    }
    if (cyc[only].size() == 2)
      cout << cyc[only][0] << " " << cyc[only][1] << endl;
  }
}
