#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define int ll
#define each(i, a) for (auto &&i : (a))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using vp = vector<P>;
using int128 = __int128_t;//cin coutはできない
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a, b) * b;};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template <class T>
void CVEC(const T &v) {
	int c = v.size() - 1;
	for (int i = 0; i < c; i++) cout << v[i] << ' ';
	if (c > -1) cout << v[c];
	cout << '\n';
}

#pragma endregion header

signed main(){
    int n; cin >> n;
	vi a(n), b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	int mi = *max_element(ALL(a));
	int mx = *min_element(ALL(b));
	cout << max(mx - mi + 1, 0LL) << endl;
}
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 300005
#define MOD 1000000007
#define INF 1000000007
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

int main()
{
    int n,i;
    scanf("%d",&n);
    int a=0,b=1000;
    for(i=0;i<n;i++)
    {
        int c;
        scanf("%d",&c);
        a=max(a,c);
    }
    for(i=0;i<n;i++)
    {
        int c;
        scanf("%d",&c);
        b=min(b,c);
    }
    if(b<a)
    {
        printf("0");
    }
    else
    {
        printf("%d",b-a+1);
    }
    return 0;
}
