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


typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define lc                                              id << 1
# define rc                                              id << 1 | 1

 
ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
 
const int xn = 1e5 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 1e9 + 7;//998244353;
const int base = 257;
 
int n, a[xn], b[xn];



 
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
cin >> n;
int d = 0;
int ans = inf;
for(int i = 0; i < n; i++){
    cin >> a[i];
}
for(int i = 0; i < n; i++){
    cin >> b[i];
}
sort(a, a + n);
sort(b, b + n);
if(b[0] >= a[n - 1]){
    ans = b[0] - a[n - 1] + 1;
}else{
    ans = 0;
}
cout << ans;
}
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <fstream> 
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip> //setprecision
#include <map> // map
#include <unordered_map> //unordered_map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#include <sstream>
#include <random>
#include <initializer_list>
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const long long MOD = 3;
//const long long MAXIMUM = INFINITY;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M, long long mod) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % mod, M / 2,mod);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % mod;
    return res %= mod;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}
long long get_mod(long long res){
    if(res < 0) res += MOD;
    return res % MOD;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    /*FILE* in = freopen("answer.txt", "w", stdout);
    ifstream ifs("in.txt"); // 巨大ケースは in.txt に書いてifsで標準入力*/

    int N;cin >> N;
    vector<int> A(N),B(N);
    for(int i = 0;i<N;i++) cin >> A.at(i);
    for(int i = 0;i<N;i++) cin >> B.at(i);
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int ans = 0;
    for(int i = A.front();i<=1001;i++){
        for(int j = 0;j<N;j++){
            if(B.at(j) < i){
                goto NG;
            }
        }
        ans++;
        NG:;
    }
    cout << ans << endl;
}