#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <climits>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;



int main() {
    vector<int> a(4);
    rep(i, 4) cin >> a[i];
    int ans = 1e9;
    rep(i, 4) chmin(ans, a[i]);
    cout << ans << endl;
}
// CPP code for Longest Palindromic substring
// using Palindromic Tree data structure
#include <bits/stdc++.h>
using namespace std;

#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 ((long long)(1e9+7))

int par[200006];
int find_parent(int ind)
{
   if(par[ind]==ind)
      return ind;
   return par[ind]=find_parent(par[ind]);
}

void un(int p1, int p2)
{
   p1=find_parent(p1);
   p2=find_parent(p2);
   if(p1!=p2)
   {
      par[p1]=p2;
   }
}

int solve()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<200006;i++)
      par[i]=i;
   std::map<int, int> mp;
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
   }
   int ans=0;
   for(int i=0;i<=(n-1)/2;i++)
   {
      int t1=find_parent(a[i]), t2=find_parent(a[n-i-1]);
      if(t1==t2)
         continue;
      un(t1, t2);
      ans++;
   }
   cout<<ans<<endl;

   return 0;
}
int main()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r", stdin);
   freopen("output.txt","w",stdout);
   #endif
   ios_base::sync_with_stdio(false);
   cin.tie(0);


   int t=1;
   // cin>>t;

   while(t--)
   {
   solve();
   }

   return 0;
}