#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 1001001001;
int n, a[111111], used[111111], ans, k;
vector<int> v[111111];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == i) {
      printf("YES\n");
      for (int j = 1; j <= n; j++) {
        if (j != i) printf("%d %d\n", i, j);
      }
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (used[i] == 0) {
      int poz = i;
      int f = 0;
      while (poz != i || f == 0) {
        f = 1;
        used[poz] = 1;
        v[k].push_back(a[poz]);
        poz = a[poz];
      }
      k++;
    }
  }
  int q = -1;
  for (int i = 0; i < k; i++) {
    if (v[i].size() % 2 == 1) {
      cout << "NO";
      return 0;
    }
    if (v[i].size() == 2) {
      q = i;
    }
  }
  if (q > -1) {
    printf("YES\n%d %d\n", v[q][0], v[q][1]);
    for (int i = 0; i < k; i++) {
      if (i != q) {
        for (int j = 0; j < v[i].size(); j++) {
          if (j % 2 == 0)
            printf("%d %d\n", v[q][0], v[i][j]);
          else
            printf("%d %d\n", v[q][1], v[i][j]);
        }
      }
    }
    return 0;
  }
  cout << "NO";
  return 0;
}
