#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int n, m, a, b;
vector<int> pn;
int main() {
  cin >> n;
  pn.resize(n);
  for (int i = 0; i < (int)n; i++) cin >> pn[i], pn[i]--;
  for (int i = 0; i < (int)n; i++) {
    if (pn[i] == i) {
      cout << "YES" << endl;
      for (int j = 0; j < (int)n; j++) {
        if (j != i) {
          cout << i + 1 << " " << j + 1 << endl;
        }
      }
      return 0;
    }
  }
  vector<bool> visited(n, 0);
  for (int i = 0; i < (int)n; i++) {
    if (!visited[i]) {
      int sIdx = i;
      int cnt = 0;
      while (1) {
        visited[sIdx] = true;
        cnt++;
        sIdx = pn[sIdx];
        if (visited[sIdx]) break;
      }
      if (cnt % 2) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  vector<bool> visited1(n, 0);
  for (int i = 0; i < (int)n; i++) {
    if (pn[pn[i]] == i) {
      int x = i, y = pn[i];
      cout << "YES" << endl;
      cout << x + 1 << " " << y + 1 << endl;
      for (int j = 0; j < (int)n; j++) {
        if (j != x && j != y && !visited1[j]) {
          int sIdx = j;
          int cnt = 0;
          while (1) {
            visited1[sIdx] = true;
            cnt++;
            if (cnt % 2)
              cout << x + 1 << " " << sIdx + 1 << endl;
            else
              cout << y + 1 << " " << sIdx + 1 << endl;
            sIdx = pn[sIdx];
            if (visited1[sIdx]) break;
          }
        }
      }
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
