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

int main() {
  int n;
  cin >> n;
  int mn = 1e9, mx = -1e9;
  for(int i=0;i<n;++i){
    int x; cin >> x;
    mx = max(mx, x);
  }
  for(int i=0;i<n;++i){
    int x; cin >> x;
    mn = min(mn, x);
  }
  
  cout << (mn < mx ? 0 : mn-mx+1);
  cout << endl;
  
  return 0;
}
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int a[n], b[n];
    loop(i,0,n) cin>>a[i];
    loop(i,0,n) cin>>b[i];

    int mn = a[0], mx = b[0];
    loop(i,1,n)
    {
        mn = max(mn,a[i]);
        mx = min(mx,b[i]);
    }

    int ans = max(0,mx-mn+1);
    cout<<ans<<'\n';

    return 0;
}
