#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long N = 100500;
const long long mod = 1e9 + 7;
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int xd[N];
int vis[N];
int wea(int i) {
  int j = xd[i];
  vis[i] = true;
  int ans = 1;
  while (j != i) {
    vis[j] = true;
    j = xd[j];
    ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> xd[i + 1];
  }
  for (int i = 1; i <= n; i++) {
    if (xd[i] == i) {
      cout << "YES" << endl;
      for (int j = 1; j <= n; j++)
        if (j != i) cout << i << " " << j << endl;
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      int w = wea(i);
      if (w % 2 == 1) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) vis[i] = false;
  for (int i = 1; i <= n; i++) {
    if (xd[xd[i]] == i) {
      int k = xd[i];
      cout << "YES" << endl;
      for (int j = 1; j <= n; j++) {
        if (vis[j] or j == i or j == k) continue;
        int w = xd[j];
        vis[j] = true;
        cout << j << " " << i << endl;
        int ch = 0;
        while (w != j) {
          vis[w] = true;
          if (ch == 0)
            cout << w << " " << k << endl;
          else
            cout << w << " " << i << endl;
          w = xd[w];
          ch = 1 - ch;
        }
      }
      cout << i << " " << k << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
