///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///

///PRAGMA
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

///PBDS
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

//PBDS_SET
//Index of Value - .order_of_key()
//Value at Index - .find_by_order()
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set; 
//typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset; 

#define mem(a, x) memset(a, x, sizeof(a))
#define MP make_air
#define inf 1e8
#define INF 1e18
#define CP(x) printf("Case %d: ", x);
#define unq(v) v.erase(unique(all(v)),v.end())
#define one(x) __builtin_popcount(x)
#define onel(x) __builtin_popcountll(x)
#define ll long long
#define ld long double
#define LMX LLONG_MAX
#define fixpre(x) cout << fixed << setprecision(x)
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define matrix vector<vector<ll> >
#define F first
#define S second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define INT ini()
#define LONG inl()
#define M 1000000007
#define N 200005

int ini(){int x;scanf("%d",&x);return x;}
ll inl(){ll x;scanf("%lld",&x);return x;}


pair<int, int> pr[N];

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		pr[i] = {INT, INT};
	}
	int l = 1, r = 1e9, mn = -1, mx = -1;
	while(l <= r)
	{
		int md = (l + r) >> 1;
		int ls = 0, gr = 0;
		for(int i = 1; i <= n; i++)
		{
			if(pr[i].F <= md) ls++;
			if(pr[i].S >= md) gr++;
		}
		if(ls >= (n + 1) / 2 && gr >= (n + 1) / 2 - 1) mn = md, r = md - 1;
		else if(ls < (n + 1) / 2) l = md + 1;
		else if(gr < (n + 1) / 2 - 1) r = md - 1;
	}
	l = 1, r = 1e9;
	while(l <= r)
	{
		int md = (l + r) >> 1;
		int ls = 0, gr = 0;
		for(int i = 1; i <= n; i++)
		{
			if(pr[i].F <= md) ls++;
			if(pr[i].S >= md) gr++;
		}
		if(ls >= (n + 1) / 2 - 1 && gr >= (n + 1) / 2) mx = md, l = md + 1;
		else if(ls < (n + 1) / 2 - 1) l = md + 1;
		else if(gr < (n + 1) / 2) r = md - 1;
	}
	ll ans = mx - mn;
	if(n % 2 == 0)
	{
	int mn2 = -1, mx2 = -1;
	l = 1, r = 1e9;
	while(l <= r)
	{
		int md = (l + r) >> 1;
		int ls = 0, gr = 0;
		for(int i = 1; i <= n; i++)
		{
			if(pr[i].F <= md) ls++;
			if(pr[i].S >= md) gr++;
		}
		if(ls >= (n + 1) / 2 + 1 && gr >= (n + 1) / 2 - 1) mn2 = md, r = md - 1;
		else if(ls < (n + 1) / 2 + 1) l = md + 1;
		else if(gr < (n + 1) / 2 - 1) r = md - 1;
	}
	l = 1, r = 1e9;
	while(l <= r)
	{
		int md = (l + r) >> 1;
		int ls = 0, gr = 0;
		for(int i = 1; i <= n; i++)
		{
			if(pr[i].F <= md) ls++;
			if(pr[i].S >= md) gr++;
		}
		if(ls >= (n + 1) / 2 - 1 && gr >= (n + 1) / 2 + 1) mx2 = md, l = md + 1;
		else if(ls < (n + 1) / 2 - 1) l = md + 1;
		else if(gr < (n + 1) / 2 + 1) r = md - 1;
	}	
	ans = mx + mx2 - mn - mn2;
	}
	cout << ans + 1<< endl;
	return 0;
}





Measured memory_bytes: 5224