#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i = a; i <= n; i++)
#define per(i,a,n) for(int i = a; i >= n; i--)
#define vi vector<int>
#define pb push_back
#define itr(i,v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
#define kill(x) {cout << x << "\n"; return;}
const int N = 1005,S = 2*10010, offset = 10000, mod = 1e9 + 7;
int a[N],ways_left[S],ways_right[S],ans=0,pfxa[N],b[N], pfxb[N];
int dp[S][2];
int get_sum(int l,int r){return max(pfxa[r] - pfxa[l-1], pfxb[r] - pfxb[l-1]);}
void rec(int left,int right){
if(left == right) return;
int mid = (left + right)/2 ;
int mnS = max(get_sum(left,mid), get_sum(mid+1,right));
int offsetS = mnS;
for(int i = -mnS; i <= mnS; i++)
dp[i + offsetS][0] = dp[i + offsetS][1]
= ways_left[i + offsetS] = ways_right[i + offsetS] = 0;
dp[0 + offsetS][0] = 1;
int ptr = 0;
rep(i,mid+1,right){
for(int curS = -mnS; curS <= mnS; curS++)
dp[curS + offsetS][ptr ^ 1] = 0;
for(int curS = -mnS; curS <= mnS; curS++){
if(a[i] + curS >= -mnS and a[i] + curS <= mnS){
dp[a[i] + curS + offsetS][ptr^1] += dp[curS + offsetS][ptr];
if(dp[a[i] + curS + offsetS][ptr^1] >= mod)
dp[a[i] + curS + offsetS][ptr^1] -= mod;
}
if(-b[i] + curS >= -mnS and -b[i] + curS <= mnS){
dp[-b[i] + curS + offsetS][ptr ^ 1] += dp[curS + offsetS][ptr];
if(dp[-b[i] + curS + offsetS][ptr^1] >= mod)
dp[-b[i] + curS + offsetS][ptr^1] -= mod;
}
}
ptr ^= 1;
for(int curS = -mnS; curS <= mnS; curS++){
ways_left[curS + offsetS] += dp[curS + offsetS][ptr];
if(ways_left[curS + offsetS] >= mod)
ways_left[curS + offsetS] -= mod;
}
}
for(int i = -mnS; i <= mnS; i++)
dp[i + offsetS][0] = dp[i + offsetS][1] = 0;
ptr = 0;
dp[0 + offsetS][0] = 1;
per(i,mid,left){
for(int curS = -mnS; curS <= mnS; curS++)
dp[curS + offsetS][ptr ^ 1] = 0;
for(int curS = -mnS; curS <= mnS; curS++){
if(a[i] + curS >= -mnS and a[i] + curS <= mnS){
dp[a[i] + curS + offsetS][ptr^1] += dp[curS + offsetS][ptr];
if(dp[a[i] + curS + offsetS][ptr^1] >= mod)
dp[a[i] + curS + offsetS][ptr^1] -= mod;
}
if(-b[i] + curS >= -mnS and b[i] + curS <= mnS){
dp[-b[i] + curS + offsetS][ptr ^ 1] += dp[curS + offsetS][ptr];
if(dp[-b[i] + curS + offsetS][ptr^1] >= mod)
dp[-b[i] + curS + offsetS][ptr^1] -= mod;
}
}
ptr ^= 1;
for(int curS = -mnS; curS <= mnS; curS++){
ways_right[curS + offsetS] += dp[curS + offsetS][ptr];
if(ways_right[curS + offsetS] >= mod)
ways_right[curS + offsetS] -= mod;
}
}
for(int curS = -mnS; curS <= mnS; curS++){
ans += ways_left[curS + offsetS] * ways_right[-curS + offsetS];
ans %= mod;
}
rec(left, mid);
rec(mid+1, right);
}
void solve(){
int n; cin >> n;
rep(i,1,n) cin >> a[i], pfxa[i] = pfxa[i-1] + a[i];
rep(i,1,n) cin >> b[i], pfxb[i] = pfxb[i-1] + b[i];
rec(1,n);
cout << ans << "\n";
}
int32_t main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// int tst; cin >> tst; while(tst--)
{
solve();
}
}