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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  int N, amax, bmin, ans;
  amax = 0;
  bmin = 1001;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  
  rep(i, N) {
    cin >> A[i];
  }
  rep(i, N) {
    cin >> B[i];
  }
  
  rep(i, N) {
    amax = max(amax, A[i]);
  }
  
  rep(i, N) {
    bmin = min(bmin, B[i]);
  }
  
  
  ans = bmin - amax + 1;
  
  if (ans < 0) ans = 0;
  
  cout << ans << endl;
  
  
}
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops") 
#define INF 2147483647
#define ll long long
#define ft first
#define sec second
#define pb push_back
#define pi pair<ll,int>
using namespace std;
ll t,n,a[100001],b[100001];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> b[i];
	ll sum=0;
	for(int i=0; i<n; i++) sum+=a[i]*b[i];
	cout << (sum?"No":"Yes");
	return 0;
}