#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int abs(int a) {
  if (a < 0) return -a;
  return a;
}
int main() {
  int n;
  cin >> n;
  bool v[n];
  int p[n], ind = -1;
  for (int i = 0; i < n; i++) cin >> p[i], p[i]--, v[i] = false;
  for (int i = 0; i < n; i++) {
    if (p[i] == i) {
      cout << "YES" << endl;
      for (int j = 0; j < n; j++)
        if (i != j) cout << i + 1 << ' ' << j + 1 << endl;
      return 0;
    }
    if (p[p[i]] == i) ind = i;
  }
  if (ind == -1) {
    cout << "NO" << endl;
    return 0;
  }
  v[ind] = v[p[ind]] = true;
  int lon, pos;
  for (int i = 0; i < n; i++)
    if (!v[i]) {
      lon = 1;
      pos = i;
      while (p[pos] != i) {
        v[pos] = true;
        pos = p[pos];
        lon++;
      }
      if (lon % 2) {
        cout << "NO" << endl;
        return 0;
      }
    }
  cout << "YES" << endl;
  cout << ind + 1 << ' ' << p[ind] + 1 << endl;
  v[ind] = v[p[ind]] = false;
  for (int i = 0; i < n; i++) {
    if (v[i]) {
      pos = i;
      lon = 0;
      while (lon == 0 or pos != i) {
        cout << (lon % 2 ? ind : p[ind]) + 1 << ' ' << pos + 1 << endl;
        lon++;
        pos = p[pos];
        v[pos] = false;
      }
    }
  }
}
