#include <bits/stdc++.h>
using namespace std;
int p[100000];
bool vis[100000];
vector<vector<int> > vv;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < (int)(N); i++) cin >> p[i], p[i]--;
  for (int i = 0; i < (int)(N); i++) {
    if (i == p[i]) {
      puts("YES");
      for (int j = 0; j < (int)(N); j++) {
        if (i != j) cout << i + 1 << " " << j + 1 << endl;
      }
      return 0;
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    if (!vis[i]) {
      vector<int> vc;
      int x = i;
      do {
        vc.push_back(x);
        vis[x] = 1;
        x = p[x];
      } while (x != i);
      vv.push_back(vc);
    }
  }
  vector<int> two;
  for (vector<int> vc : vv) {
    if (vc.size() % 2 == 1) {
      puts("NO");
      return 0;
    }
    if (vc.size() == 2) two = vc;
  }
  if (two.empty()) {
    puts("NO");
    return 0;
  }
  puts("YES");
  cout << two[0] + 1 << " " << two[1] + 1 << endl;
  for (vector<int> vc : vv) {
    if (vc == two) continue;
    for (int i = 0; i < (int)(vc.size()); i++) {
      cout << two[i % 2] + 1 << " " << vc[i] + 1 << endl;
    }
  }
}
