#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 20;
int a[N], e[N], visited[N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    e[i] = a[i];
  }
  int t = 0, o = 0, flag = 1;
  for (int i = 1; i <= n; i++) {
    if (i == e[i]) {
      t = e[i];
    }
    if (e[e[i]] == i) {
      o = i;
    }
    if (visited[i] == 0) {
      visited[i] = 1;
      int d = e[i], t = 1, p = 1;
      while (d != i) {
        visited[d] = 1;
        p++;
        d = e[d];
      }
      if (p % 2 == 1) {
        flag = 0;
      }
    }
  }
  fill(visited, visited + n + 1, 0);
  if (t != 0) {
    cout << "YES\n";
    for (int i = 1; i <= n; i++) {
      if (t != i) {
        cout << t << " " << i << "\n";
      }
    }
  } else if (o != 0 and flag == 1) {
    cout << "YES\n";
    int x = o;
    int y = e[o];
    cout << x << " " << y << "\n";
    for (int i = 1; i <= n; i++) {
      if (i != x and i != y and visited[i] == 0) {
        visited[i] = 1;
        cout << y << " " << i << "\n";
        int d = e[i], t = 1;
        while (d != i) {
          visited[d] = 1;
          if (t == 1) {
            cout << x << " " << d << "\n";
            t *= -1;
          } else {
            cout << y << " " << d << "\n";
            t *= -1;
          }
          d = e[d];
        }
      }
    }
  } else {
    cout << "NO";
  }
}
