#include <bits/stdc++.h>
#include <cmath>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<long long,long long>;
//ll INF = 1e18;
//int INF = 1e9;
//printf("%.10f\n",ans);




int main() {
  
  int n;
  cin >> n;
  int a = 0;
  rep(i,n){
    int x;
    cin >> x;
    a = max(a,x);
  }
  int b = 1000;
  rep(i,n){
    int y;
    cin >> y;
    b = min(y,b);
  }
  if(b < a) cout << 0 << endl;
  else cout << b-a+1 << endl;
  
  return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main (){
  int n;
  cin >> n;
  
  set<int> a;
  set<int> b;
  
  for(int i=0;i<n;i++){
    int x;
    cin >>x;
    a.insert(x);
  }
  for(int i=0;i<n;i++){
    int x;
    cin >>x;
    b.insert(x);
  }
  
  int ans=*begin(b)-*rbegin(a)+1;
  
  if(ans<=0){
    cout << 0 <<endl;
    return 0;
  }
  
  cout << ans << endl;
  
}
