// kid_kb //

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,n,a) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
#define INF INT_MAX
#define inf INT_MIN

// cout<<fixed<<setprecision(8)<<endl;

ll gcd(ll a,ll b)
{    if (a == 0)    return b;     return gcd(b % a, a); }

ll lcm(ll a,ll b)
{    ll g=gcd(a,b); ll ans=(a*b)/g; return ans;    }

ll fastpower(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=fastpower(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return fastpower(a, m-2, m); }

//----------------------------------------Let's Fight-----------------------------------------------------------------

void solve(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    rep(i,0,n)cin>>v[i];
    
    ll ans=v[0];
    rep(i,1,n){
        ans=gcd(ans,v[i]);
    }
    cout<<ans<<endl;
    
}

int main()
{
    kb
//  clock_t tStart = clock();
    ll t;
    t=1;
//    cin>>t;
    while(t--){
        solve();
    }
 // printf("%.2fs time lga\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[200000],b[200000];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&a[i]);
    for (i = 0; i < N; i++) scanf("%d",&b[i]);

    LLI c = 0;
    int maxa = 0;
    for (i = 0; i < N; i++) {
        maxa = max(maxa,a[i]);
        c = max(c,(LLI) b[i]*maxa);
        printf("%lld\n",c);
    }

    return 0;
}

