#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace std::chrono; 
using namespace __gnu_pbds;
 
using ll = long long;
using ld = long double;
 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define rfo(i,z,n) for(int i = z;i >= n;i--)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vc vector<char>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define vpi vector<pair<int,int> >
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvpi vector<vector<pair<int,int> > >
#define vvc vector<vector<char> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define pi 3.14159265358979323846
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
 
void __print(int x) {cerr << x;}
// void __print(long x) {cerr << x;}
// void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
// void __print(float x) {cerr << x;}
// void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
ll power(ll a,ll p,ll m=mod)
{ll res=1;while(p>0){if(p&1)res=(res*a)%m;a=(a*a)%m;p>>=1;}
return res;}
 
 
int ceil(int a,int b){
    if(a%b == 0)return a/b;
    else return a/b+1;
}
 
int madd(int a,int b){
    int res = (((a + mod)%mod + (b+mod)%mod)%mod + mod)%mod;
    return res;
}
 
int pow(int a,int b){
    if(b == 0)return 1;
    int res = pow(a,b/2);
    res = res*res;
    if(b&1)res *= a;
    return res;
}

vi par(200005,-1);
vi siz(200005,1);

int find(int u){
    if(par[u] == u)return u;
    return par[u] = find(par[u]);
}

void solve(){

    int n;
    cin >> n;
    vi v(n);
    fo(i,0,n)cin >> v[i];

    fo(i,0,n)par[v[i]] = v[i];

    fo(i,0,n/2){
        // if(v[i] == v[n-i-1])continue;
        int fp1 = find(v[i]);
        int fp2 = find(v[n-i-1]);
        // debug(fp1,fp2,i);
        if(fp1 != fp2){
            par[fp2] = fp1;
            siz[fp1] += siz[fp2];
        }
    }

    int connectedcom = 0;
    int ans = 0;
    fo(i,0,200005)
        if(par[i] == i){
            // debug(par[i],i,siz[i]);
            connectedcom++;
            if(siz[i] == 1)ans += siz[i];
            else
            ans += siz[i];
        }
    // cout << connectedcom << endl;
    ans -= connectedcom;

    cout << ans << endl;




    
} 
 
int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);

    // memset(vis,-1,sizeof(vis));
    int t = 1;
    // cin >> t;
     while(t--){
        solve();
     }
 
 
 
 
return 0;
    
    }
#include <bits/stdc++.h>
using namespace std;
const int N = 10000;
int n;
bool mem[N][N];
class ad {
   public:
    int a, b, c, d, r, id;
    ad() {}
    void read() {
        scanf("%d%d%d", &a, &b, &r);
        mem[a][b] = true;
        c = a + 1, d = b + 1;
    }
    void print() { printf("%d %d %d %d\n", a, b, c, d); }
    int size;
    void cal_size() { size = (c - a) * (d - b); }
    double grad0, grad1;
    void cal_grad() {
        double p1 = 1.0 * size, p2 = size + d - b, p3 = size + c - a;
        p1 = min(p1 / r, r / p1), p2 = min(p2 / r, r / p2),
        p3 = min(p3 / r, r / p3);
        p1 = p1 * (2 - p1), p2 = p2 * (2 - p2), p3 = p3 * (2 - p3);
        grad0 = p2 - p1, grad1 = p3 - p1;
    }
    void init() {
        cal_size();
        cal_grad();
    }
    bool extend0() {
        if (a) {
            bool f = true;
            for (int j = b; j < d; ++j) {
                if (mem[a - 1][j]) {
                    f = false;
                    break;
                }
            }
            if (f) {
                for (int j = b; j < d; ++j) mem[a - 1][j] = true;
                --a;
                init();
                return true;
            }
        }
        if (c < 9999) {
            bool f = true;
            for (int j = b; j < d; ++j) {
                if (mem[c][j]) {
                    f = false;
                    break;
                }
            }
            if (f) {
                for (int j = b; j < d; ++j) mem[c][j] = true;
                ++c;
                init();
                return true;
            }
        }
        return false;
    }
    bool extend1() {
        if (b) {
            bool f = true;
            for (int i = a; i < c; ++i) {
                if (mem[i][b - 1]) {
                    f = false;
                    break;
                }
            }
            if (f) {
                for (int i = a; i < c; ++i) mem[i][b - 1] = true;
                --b;
                init();
                return true;
            }
        }
        if (d < 9999) {
            bool f = true;
            for (int i = a; i < c; ++i) {
                if (mem[i][d]) {
                    f = false;
                    break;
                }
            }
            if (f) {
                for (int i = a; i < c; ++i) mem[i][d] = true;
                ++d;
                init();
                return true;
            }
        }
        return false;
    }
    bool operator<(const ad &rhs) const {
        return grad0 + grad1 < rhs.grad0 + rhs.grad1;
    }
};
priority_queue<ad> q;
ad ans[200];
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        ad t;
        t.read();
        t.id = i;
        t.init();
        q.push(t);
    }
    while (!q.empty()) {
        ad now = q.top();
        q.pop();
        bool f = false;
        if (now.grad0 >= now.grad1 && now.grad0 > 0) {
            f = true;
            if (!now.extend0()) now.grad0 = 0;
        }
        if (now.grad1 > now.grad0 && now.grad1 > 0) {
            f = true;
            if (!now.extend1()) now.grad1 = 0;
        }
        if (f)
            q.push(now);
        else
            ans[now.id] = now;
    }
    for (int i = 0; i < n; ++i) ans[i].print();
    return 0;
}