#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) {
  return (b ? gcd(b, a % b) : a);
}
inline long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
inline int cmp(double x, double y = 0, double tol = 1e-7) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
using namespace std;
const int MAXN = 100005;
vector<int> cicle[MAXN];
int v[MAXN];
int cor[MAXN] = {0};
int cont = 0;
int sz1 = -1, sz2 = -1;
bool impar = false;
void G(int i) {
  cicle[cont].push_back(i);
  cor[i] = 1;
  int x = v[i];
  while (x != i) {
    cicle[cont].push_back(x);
    cor[x] = 1;
    x = v[x];
  }
  if (cicle[cont].size() == 1)
    sz1 = i;
  else if (cicle[cont].size() == 2)
    sz2 = cont;
  if (cicle[cont].size() % 2 == 1) impar = true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (!cor[i]) {
      G(i);
      cont++;
    }
  }
  if (sz1 != -1) {
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      if (i != sz1) cout << sz1 + 1 << " " << i + 1 << endl;
    }
  } else if (sz2 != -1 && impar == false) {
    cout << "YES\n";
    int x = cicle[sz2][0] + 1, y = cicle[sz2][1] + 1;
    cout << x << " " << y << endl;
    for (int i = 0; i < cont; i++) {
      if (i == sz2) continue;
      for (int j = 0; j < cicle[i].size(); j++) {
        if (j % 2 == 0)
          cout << x;
        else
          cout << y;
        cout << " " << cicle[i][j] + 1 << endl;
      }
    }
  } else {
    cout << "NO\n";
  }
}
