#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
const ll mod2=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
ll mul(ll a, ll b) {
return a*b%mod;
}
const int N=201000;
int a[N],b[N];
db ps[N];
ll pp[N];
struct node {
db mx,lzy;
ll f,lzyp;
}nd[4*N];
void upd(int p) {
if (nd[p+p].mx>nd[p+p+1].mx) {
nd[p]=nd[p+p];
} else {
nd[p]=nd[p+p+1];
}
}
void push(int p) {
nd[p].mx+=nd[p].lzy;
nd[p].f=mul(nd[p].f,nd[p].lzyp);
nd[p+p].lzy+=nd[p].lzy;
nd[p+p+1].lzy+=nd[p].lzy;
nd[p+p].lzyp=mul(nd[p+p].lzyp,nd[p].lzyp);
nd[p+p+1].lzyp=mul(nd[p+p+1].lzyp,nd[p].lzyp);
nd[p].lzy=0;
nd[p].lzyp=1;
}
void build(int p,int l,int r) {
nd[p].lzyp=1;
if (l==r) {
nd[p].mx=ps[l]+log10(b[l]);
nd[p].f=mul(pp[l],b[l]);
return;
}
int md=l+r>>1;
build(p+p,l,md);
build(p+p+1,md+1,r);
upd(p);
}
void modify(int p,int l,int r,int ql,int qr,db x,ll y) {
push(p);
if (l>qr||r<ql) return;
if (ql<=l&&r<=qr) {
nd[p].lzy+=x;
nd[p].lzyp=mul(nd[p].lzyp,y);
push(p);
return;
}
int md=l+r>>1;
modify(p+p,l,md,ql,qr,x,y);
modify(p+p+1,md+1,r,ql,qr,x,y);
upd(p);
}
ll init(int n,int* x,int* y) {
ps[0]=0; pp[0]=1;
rep(i,1,n+1) ps[i]=ps[i-1]+log10(x[i]);
rep(i,1,n+1) pp[i]=mul(pp[i-1],x[i]);
rep(i,1,n+1) a[i]=x[i],b[i]=y[i];
build(1,1,n);
return nd[1].f;
}
void updateX(int pos,int val) {
}
void updateY(int pos,int val) {
}