#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)0 + (int)1e8;
const int N = 100005;
const double PI = 4 * atan(1);
const double eps = 1e-10;
const long long oo = 1e10;
const int K = 26;
int n;
int p[N];
int rev[N];
bool vis[N];
int cn = 0;
vector<long long> vv;
vector<long long> v;
void dfs(int src) {
  if (vis[src]) return;
  v.push_back(src);
  vis[src] = 1;
  dfs(p[src]);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == i) {
      cout << "YES\n";
      for (int j = 0; j < n; j++) {
        if (j == i) continue;
        cout << i + 1 << " " << j + 1 << endl;
      }
      return 0;
    }
  }
  int a = -1;
  int b = -1;
  for (int i = 0; i < n; i++) {
    if (p[p[i]] == i) {
      a = i;
      b = p[i];
      break;
    }
  }
  if (a == -1) {
    cout << "NO\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (i == a || i == b) continue;
    if (vis[i]) continue;
    v.clear();
    dfs(i);
    if (v.size() % 2) {
      cout << "NO\n";
      return 0;
    }
    for (auto t : v) vv.push_back(t);
  }
  cout << "YES\n";
  cout << a + 1 << " " << b + 1 << endl;
  for (int i = 0; i < vv.size(); i++) {
    if (i % 2) {
      cout << a + 1 << " " << vv[i] + 1 << endl;
    } else {
      cout << b + 1 << " " << vv[i] + 1 << endl;
    }
  }
  return 0;
}
