#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int p[N];
bool was[N];
vector<vector<int> > a;
int n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  for (int i = 1; i <= n; ++i)
    if (p[i] == i) {
      cout << "YES\n";
      for (int j = 1; j <= n; ++j)
        if (i != j) cout << i << ' ' << j << '\n';
      return 0;
    }
  vector<int> now;
  for (int i = 1; i <= n; ++i)
    if (!was[i]) {
      now.clear();
      now.push_back(i);
      was[i] = 1;
      for (int j = p[i]; j != i; j = p[j]) now.push_back(j), was[j] = 1;
      a.push_back(now);
    }
  for (int i = 0; i < a.size(); ++i)
    if (a[i].size() == 2) {
      for (int j = 0; j < a.size(); ++j)
        if (a[j].size() & 1) {
          cout << "NO\n";
          return 0;
        }
      cout << "YES\n";
      cout << a[i][0] << ' ' << a[i][1] << '\n';
      for (int j = 0; j < a.size(); ++j)
        if (i != j) {
          for (int k = 0; k < a[j].size(); ++k)
            cout << a[j][k] << ' ' << a[i][k & 1] << '\n';
        }
      return 0;
    }
  cout << "NO\n";
  return 0;
}
