#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n, m; cin >> n >> m;
    if(n == 1 &&  m == 0){
        out("1 2"); return 0;
    }
    if(m > n-2 || m < 0){
        out(-1); return 0;
    }

    vector<int> l(n), r(n);
    rep(i, n-1){
        l[i] = 2+3*i; r[i] = 4+3*i;
    }
    if(m==0){
        l[n-1] = 2+3*(n-1); r[n-1] = 4+3*(n-1);
    }
    else{
        l[n-1] = 1; r[n-1] = 3+3*m;
    }

    rep(i, n){
        outs(l[i]); out(r[i]);
    }
}
/* Author: rrrr_wys
 **/

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
typedef double db;
typedef long long ll;
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int N = 200110;
const int P = 998244353;

int fa[N];
int fd(int u) {
  if (u == fa[u])
    return u;
  return fa[u] = fd(fa[u]);
}
void mer(int x, int y) {
  int tx = fd(x), ty = fd(y);
  if (tx != ty) {
    fa[tx] = ty;
  }
}
signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, 0, n - 1) cin >> a[i];
  rep(i, 0, N - 1) fa[i] = i;
  int ans = 0;
  rep(i, 0, n - 1) {
    if (fd(a[i]) != fd(a[n - i - 1])) {
      mer(a[i], a[n - i - 1]);
      ++ans;
    }
  }
  cout << ans << "\n";
}