#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 112345;
int p[N], d[N];
;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
    if (p[i] == i) {
      cout << "YES" << endl;
      for (int j = 0; j < n; j++) {
        if (j != i) {
          cout << i + 1 << " " << j + 1 << endl;
        }
      }
      return 0;
    }
  }
  int j = -1;
  int x, y;
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    if (p[p[i]] == i) {
      j = i;
      x = i;
      y = p[i];
      break;
    }
  }
  ans.push_back(make_pair(x, y));
  if (j == -1) {
    cout << "NO" << endl;
    return 0;
  }
  vector<int> cycle;
  d[x] = 1;
  d[y] = 1;
  for (int i = 0; i < n; i++) {
    if (d[i]) {
      continue;
    }
    cycle.clear();
    int q = i;
    do {
      cycle.push_back(q);
      q = p[q];
      d[q] = 1;
    } while (q != i);
    if (cycle.size() % 2) {
      cout << "NO" << endl;
      return 0;
    }
    for (int i = 0; i < cycle.size(); i += 2) {
      ans.push_back(make_pair(x, cycle[i]));
      ans.push_back(make_pair(y, cycle[i + 1]));
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  }
  return 0;
}
