#include <bits/stdc++.h>
using namespace std;
long long int arr[100001];
vector<pair<long long int, long long int> > edges;
bool vis[100001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  long long int n;
  cin >> n;
  long long int single = 0;
  long long int dual = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == i) single = i;
    if (arr[i] < i && i == arr[arr[i]]) dual = arr[i];
  }
  if (single) {
    cout << "YES" << endl;
    for (int i = 1; i <= n; i++) {
      if (i != single) {
        cout << i << " " << single << endl;
      }
    }
    return 0;
  }
  if (dual == 0) {
    cout << "NO" << endl;
    return 0;
  }
  vis[dual] = true;
  vis[arr[dual]] = true;
  edges.push_back(make_pair(dual, arr[dual]));
  for (int i = 1; i <= n; i++) {
    vector<int> currcycle;
    if (!vis[i]) {
      int start = i;
      while (!vis[start]) {
        vis[start] = true;
        currcycle.push_back(start);
        start = arr[start];
      }
    }
    if (currcycle.size() % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
    for (int j = 0; j < currcycle.size(); j++) {
      if (j % 2 == 0)
        edges.push_back(make_pair(dual, currcycle[j]));
      else
        edges.push_back(make_pair(arr[dual], currcycle[j]));
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < edges.size(); i++) {
    cout << edges[i].first << " " << edges[i].second << endl;
  }
  return 0;
}
