	/*
ID: ghallya2
TASK: ride
PROG: ride
LANG: C++                 
*/

#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cstdlib>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<chrono>
#include<random>
#include<bitset>
#define forb(i,a,b) for(ll i=a;i<b;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define F first
#define S second
#define mp make_pair
#define sortba(a,i,n) sort(a+i,a+n+i)
#define sortra(a,i,n) sort(a+i,a+n+i,greater<int>())
#define sortb(a) sort(a.begin(),a.end())
#define sortr(a) sort(a.begin(),a.end(),greater<ll> ())
#define inf LLONG_MAX
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll M=1e9+7;

ll kombinasi(ll a,ll b){
	ll ans=1,j=1;;
	ll y=max(b,a-b);
	for(ll i=a;i>y;i--){
		ans*=i;
		ans%=M;
		ans/=j;
		j++;
	}
	return ans;
}
void solve(){
}

int main()
{
	//freopen("swap.in", "r", stdin); 
	//freopen("swap.out", "w", stdout); 
	ll n;
	cin>>n;
	ll a[n];
	forb(i,0,n){
		cin>>a[i];
	}
	ll ans=0;
	forb(i,0,n){
		ll mins=a[i];
		forb(j,i,n){
			mins=min(mins,a[j]);
			ans=max(mins*(j-i+1),ans);
		}
	}
	cout<<ans<<endl;
}
/*
"An anomaly, I'm Muhammad Ali
  Cause I know one day I'm gonna be the"
                - Greatest, Eminem
*/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin >> n; 
    vector<ll> a(n), b(n);
    get(a);
    get(b);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += (a[i] * b[i]);
    }
    cout <<( sum ? "No" : "Yes") << endl;
    return 0;
}