//prewritten code: https://github.com/antma/algo
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

class InputReader {
  private:
  ubyte[] p;
  ubyte[] buffer;
  size_t cur;
  public:
  this () {
    buffer = uninitializedArray!(ubyte[])(16<<20);
    p = stdin.rawRead (buffer);
  }
  final ubyte skipByte (ubyte lo) {
    while (true) {
      auto a = p[cur .. $];
      auto r = a.find! (c => c >= lo);
      if (!r.empty) {
        cur += a.length - r.length;
        return p[cur++];
      }
      p = stdin.rawRead (buffer);
      cur = 0;
      if (p.empty) return 0;
    }
  }
  final ubyte nextByte () {
    if (cur < p.length) {
       return p[cur++];
    }
    p = stdin.rawRead (buffer);
    if (p.empty) return 0;
    cur = 1;
    return p[0];
  }

  template next(T) if (isSigned!T) {
    final T next ()  {
      T res;
      ubyte b = skipByte (45);
      if (b == 45) {
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 - (b - 48);
        }
      } else {
        res = b - 48;
        while (true) {
          b = nextByte ();
          if (b < 48 || b >= 58) {
            return res;
          }
          res = res * 10 + (b - 48);
        }
      }
    }
  }
  template next(T) if (isUnsigned!T) {
    final T next () {
      T res = skipByte (48) - 48;
      while (true) {
        ubyte b = nextByte ();
        if (b < 48 || b >= 58) {
          break;
        }
        res = res * 10 + (b - 48);
      }
      return res;
    }
  }
  final T[] nextA(T) (int n) {
    auto a = uninitializedArray!(T[]) (n);
    foreach (i; 0 .. n) {
      a[i] = next!T;
    }
    return a;
  }
}

alias T = Tuple!(int, int);

void main() {
  auto r = new InputReader;
  immutable n = r.next!int;
  auto p = r.nextA!int(n);
  p[] -= 1;
  auto q = new int[n];
  foreach (i; 0 .. n) {
    q[p[i]] = i;
  }
  int m = n / 2;
  T[] res;
  int s (int i, int j) {
    debug stderr.writefln ("swap: %d %d\n", i + 1, j + 1);
    if (i == j) {
      return j;
    }
    debug stderr.writefln ("%d %d", 2 * abs (i - j), n);
    assert (2 * abs (i - j) >= n);
    res ~= tuple (i + 1, j + 1);
    swap (p[i], p[j]);
    q[p[i]] = i;
    q[p[j]] = j;
    return j;
  }
  immutable last = n - 1;
  debug stderr.writeln ("m = ", m);
  foreach_reverse (i; 1 .. m) {
    int pos = m - i;
    int u = q[pos];
    debug stderr.writeln ("p = ", p, ", pos = ", pos, ", u = ", u);
    if (u != pos) {
      if (u < m) {
        u = s (u, last);
      } else {
        u = s (u, 0);
        u = s (0, last);
      }
      assert (u == last);
      s (last, pos);
    }
    pos = m + i - 1;
    u = q[pos];
    debug stderr.writeln ("p = ", p, ", pos = ", pos, ", u = ", u);
    if (u != pos) {
      if (u >= m) {
        u = s (u, 0);
      } else {
        u = s (u, last);
        u = s (last, 0);
      }
      assert (u == 0);
      s (0, pos);
    }
  }
  if (p[0] != 0) {
    s (0, last);
  }
  writeln (res.length);
  foreach (t; res) {
    writeln (t[0], ' ', t[1]);
  }
  debug {
    stderr.writeln (p);
    foreach (i; 0 .. n) {
      assert (p[i] == i);
    }
  }
}

