#include <bits/stdc++.h>
using namespace std;
void gt(int &a, int b) {
  if (a < b) a = b;
}
string n2s(int a) {
  stringstream ss;
  ss << a;
  return ss.str();
}
string getKey(int v, int h) { return n2s(v) + "-" + n2s(h); }
int p[500005];
int mark[500005]{0};
vector<vector<int>> groups;
int main() {
  int n;
  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" << endl;
      for (int j = 1; j <= n; j++)
        if (j != i) cout << i << " " << j << endl;
      return 0;
    }
  for (int u = 1; u <= n; u++)
    if (p[p[u]] == u) {
      int v = p[u];
      for (int i = 1; i <= n; i++) {
        if (i == u || i == v || mark[i]) continue;
        vector<int> g;
        g.push_back(i);
        mark[i] = 1;
        int j = p[i];
        while (j != i) {
          g.push_back(j);
          mark[j] = 1;
          j = p[j];
        }
        if (g.size() % 2 != 0) {
          cout << "NO";
          return 0;
        }
        groups.push_back(g);
      }
      cout << "YES" << endl;
      cout << u << " " << v << endl;
      for (auto g : groups) {
        for (int i = 0; i <= g.size() / 2 - 1; i++) {
          cout << u << " " << g[i * 2] << endl;
          cout << v << " " << g[i * 2 + 1] << endl;
        }
      }
      return 0;
    }
  cout << "NO";
  return 0;
}
