/*ver 6*/
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <set>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
#define EACH(x,v) for(auto& x : v)
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define REFOR(i,a,b) for(ll i=(ll)b-1;i>=(ll)a;i--)
#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define REREP(i,n) for(ll i=(ll)n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {REP(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {REP(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {REP(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {REP(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {REP(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {REP(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {REP(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {REP(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {REP(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {REP(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {REP(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();EACH(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
	init();
	inl(a,b);
	out((a+b)/2,(a-b)/2);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

/*
Fix k.
For this k, we will:
Compute the maximum possible sum of k items that is equal to X modulo k.
We will do this by using a DP approach. We go through the items one by one and decide IN ORDER whether we use them.
Our DP state is (# items used, current sum % k, items gone through) -> value.
For each k, we have 10^6 DP states.
The processing for each state is constant time.
So we have at most 10^8 "things" to do.
*/

void maxeq(long long& a, long long b){
	a = max(a, b);
}

long long DP[102][101][101];
int main(){
	long long n, x;
	cin>>n>>x;
	vector<long long> A(n);
	for (int i = 0; i < n; i++) cin>>A[i];
	long long ans = 2e18;
	// (# items used, current sum % k, items gone through) -> value.
	for (int k = 1; k <= n; k++){
		//long long DP[k+1][k][n+1];
		for (int a = 0; a <= k+1; a++){
			for (int b = 0; b < k; b++){
				for (int c = 0; c <= n; c++){
					DP[a][b][c] = LLONG_MIN / 3;
				}
			}
		}
		DP[0][0][0] = 0;
		for (int c = 0; c < n; c++){ // we decide whether to take item c
			for (int a = 0; a < k+1; a++){
				for (int b = 0; b < k; b++){
					// take
					maxeq(DP[a + 1][(b + A[c]) % k][c + 1], DP[a][b][c] + A[c]);
					// don't take
					maxeq(DP[a][b][c + 1], DP[a][b][c]);
				}
			}
		}
		if (DP[k][x % k][n] > 0) ans = min(ans, (x - DP[k][x % k][n]) / k);
	}
	cout << ans << endl;
}


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

int main(){
  long long int l,C;
  cin >> l;

  C = 1;
  for(int j=1; j<12; j++){
    C = C*(l-j)/j;
  }

  cout << C << endl;

  return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

void solve(){
}
int main()
{
    fast_cin();
    int l;
    cin>>l;
    ll ans=1;
    for(int i=1; i<=11; i++) {
        ans*=l-i;
        ans/=i;
    }
    cout<<ans<<endl;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(c%2==0){
		a=abs(a);
		b=abs(b);
	}
	if(a<b) printf("<\n");
	else if(a>b) printf(">\n");
	else printf("=\n");
	return 0;
}

#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << 21 - a - b - c << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

inline int read()
{
	int a=0,f=1;
	char ch=getchar();
	for(;!isdigit(ch);ch=getchar())
		if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())
		a=(a<<3)+(a<<1)+ch-'0';
	return a*f;
}

void write(int x)
{
	if(x<0)x=-x,putchar('-');
	if(x>9)write(x/10);
	putchar((x%10)^48);
}

inline void writen(int x)
{write(x);puts("");}

const int MOD=1e9+7;
const int N=1e6+5;
const int INF=0x3f3f3f3f;
const double PI=acos(-1);

signed main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<21-a-b-c<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, c, n) for (ll i = c; i < (n); ++i)
//以下debug用
#define d(x) cout << #x << "; " << x << endl;
#define p(x) cout << x << endl;
#define f(x) for (long unsigned int i = 0; i < x.size(); i++) cout << #x << "[" << i << "]; " << x[i] << endl;

bool ok = false;
vector<int> datas;
const int inf = 1001001001;
const ll INF = 1LL << 60; //無限大

int ans=0,num=0,counter=0;
string s;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  ans = 7*3 - (a+b+c);
  p(ans)

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)

int n,m;
vector<int> G[20];
vector<bool> used(20,false);
vector<int> col(20,-1);

vector<int> vs;
void dfs(int v)
{
    if(used[v])return;
    used[v]=true;
    vs.push_back(v);
    for(int u:G[v])dfs(u);
}

ll now;
void dfs2(int i)
{
    if(i == (int)vs.size()){
        now++;
        return;
    }
    rep(c,3){
        col[vs[i]]=c;
        bool ok = true;
        for(int u:G[vs[i]]){
            if(col[u]==c)ok = false;
        }
        if(!ok)continue;
        dfs2(i+1);
    }
    col[vs[i]]=-1;
}
int main()
{
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll ans = 1;
    col = vector<int>(n,-1);
    rep(i,n){
        if(used[i])continue;
        ans*=3;
        vs = vector<int>();
        dfs(i);
        //col = vector<int>(20,-1);
        col[vs[0]]=0;
        now = 0;
        dfs2(1);
        ans*=now;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
const int MAXN = 2e1 + 5;

int fa[MAXN];
int find(int x) {
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}
void merge(int x, int y) {
    fa[find(y)] = find(x);
}

vector<int> vec;
int res, col[MAXN];
int n, m, g[MAXN][MAXN];
void dfs(int k) {
	if (k == vec.size()) {
		++res;
		return ;
	}
	for (int i = 1; i <= 3; ++i) {
		int u = vec[k];
		col[u] = i;
		auto check = [](int x) -> bool {
			for (int i = 1; i <= n; ++i)
				if (g[x][i] && col[i] == col[x])
					return false;
			return true;
		};
		if (check(vec[k])) dfs(k + 1);
		col[u] = 0;
	}
}
bool vis[MAXN];
signed main(int argc, char *argv[]) {
	//ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	for (int i = 0; i < MAXN; ++i) fa[i] = i;
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		merge(u, v);
		g[u][v] = g[v][u] = 1;
	}
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		if (vis[i]) continue;
		vec.clear(), res=  0;
		for (int j = 1; j <= n; ++j)
			if (find(j) == i) vec.push_back(j), vis[j] = true;;
		dfs(0);
		ans *= res;
	}
	cout << ans << '\n';
	system("pause");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 100005
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*f;
}
int n,a[N];
inline double js(double p)
{
	double sum=0;
	for(int i=1;i<=n;i++)
	    if(a[i]<=int(2.0*p)) sum+=p;
	    else sum+=double(a[i])-p;
	return sum;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int l=1,r=n,lm,rm;
	while(l+1<r)
	{
		lm=(l+r)>>1;rm=(lm+r)>>1;
//		printf("%d %d %d %d\n",l,lm,rm,r);
		if(js(double(a[lm])/2.0)>js(double(a[rm])/2.0)) l=lm;
		else r=rm;
	}
	double ans=double(a[r])/2.0,P=0;
	for(int i=1;i<=n;i++)
	    if(a[i]<=int(2.0*ans)) P+=ans;
	    else P+=double(a[i])-ans;
	printf("%.6lf\n",P/double(n));
	return 0;
}

#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <iostream>
#include <map>

#define go(i, l, r) for(int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define god(i, r, l) for(int i = (r), i##end = (int)(l); i >= i##end; --i)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug_in  freopen("in.txt","r",stdin)
#define debug_out freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
const ll maxn = 2e3+10;
const ll maxM = 1e6+10;
const ll inf_int = 1e8;
const ll inf_ll = 1e17;

template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}

void pt(){ cout<<'\n';}
template<class H, class ... T> void pt(H h,T... t){ cout<<" "<<h; pt(t...);}

//--------------------------------------------
int a,b,c;
double dp[105][105][105];
double dfs(int a,int b,int c){
    if(a>=100 || b >= 100 || c >= 100) return 0;
    if(dp[a][b][c] >= -0.5) return dp[a][b][c];
    double ans = 0;
    ans += (double)a/(a+b+c) * dfs(a+1,b,c);
    ans += (double)b/(a+b+c) * dfs(a,b+1,c);
    ans += (double)c/(a+b+c) * dfs(a,b,c+1);
    return dp[a][b][c] = ans + 1;
}
int main() {
//    debug_in;
//    debug_out;

    read(a,b,c);
    go(i,0,101) go(j,0,101) go(k,0,101) dp[i][j][k] = -1;
    double ans = dfs(a,b,c);
    printf("%.8f\n",ans);
    return 0;
}


#include <cstdio>
#define ll long long
#define mem(x, a) memset(x, a, sizeof x)
#define mpy(x, y) memcpy(x, y, sizeof y)
#define fo(x, a, b) for (int x = (a); x <= (b); x++)
#define fd(x, a, b) for (int x = (a); x >= (b); x--)
#define go(x) for (int p = tail[x], v; p; p = e[p].fr)
using namespace std;
ll n, m;

int main()
{
	scanf("%lld%lld", &n, &m);
	for (ll i = 1; i * i <= m; i++)
		if (m % i == 0) {
			ll j = m / i;
			if (i + j == n)
				return 0 & printf("Yes\n");
		}
	printf("No\n");
	return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist(1,10000000); // distribution in range [1, 6]

const double PI =  3.141592653589793238;
int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

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

const int N = 100010;
const int mod = 1e9 + 7;

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int tt = 1;
    // cin >> tt;

    while (tt--) {
        int s, p;
        cin >> s >> p;

        int f = 0;
        for (int i = 1; i <= 1e6; ++i) {
            if (i * (s - i) == p) {
                f = 1;
            }
        }

        if (f) cout << "Yes\n";
        else cout << "No\n";

    }
    return 0;
}


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(array) array.begin(), array.end()
#define print(x) cout << x << endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef string str;
ll INF = 10e9;

//Aのiからj番目まで表示
int print_array(vector<int> A,int i,int j){
    FOR(k,i,j){
        cout << A[k] << " ";
    }
    print(A[j]);
    return 0;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a % 200;
    }

    str ans = "No";
    if (N>=8){
        N = 8;
        vector<vector<int>> B(pow(2, N) - 1, vector<int>(0));
        for (int bit = 1; bit < (1 << N); ++bit)
        {
            vector<int> c;
            int sum = 0;
            for (int i = 0; i < N; ++i)
            {
                if (bit & (1 << i))
                {
                    c.pb(i + 1);
                    sum += A[i];
                }
            }

            B[bit - 1].pb(sum % 200);
            FOR(i, 0, c.size())
            {
                B[bit - 1].pb(c[i]);
            }
        }

        sort(ALL(B));
        FOR(i, 1, B.size())
        {
            if (B[i][0] == B[i - 1][0])
            {
                ans = "Yes";
                print(ans);
                //x
                cout << B[i].size() - 1 << " ";
                print_array(B[i], 1, B[i].size() - 1);
                //y
                cout << B[i - 1].size() - 1 << " ";
                print_array(B[i - 1], 1, B[i - 1].size() - 1);
                break;
            }
        }
    }
    else { // N<8のときbit全探索
        vector<vector<int>> B(pow(2,N)-1, vector<int>(0));
        for (int bit = 1; bit < (1 << N); ++bit)
        {
            vector<int> c;
            int sum = 0;
            for (int i = 0; i < N; ++i)
            {
                if (bit & (1 << i)){
                    c.pb(i+1);
                    sum += A[i];
                }
            }

            B[bit-1].pb(sum%200);
            FOR(i,0,c.size()){
                B[bit - 1].pb(c[i]);
            }
        }

        sort(ALL(B));
        FOR(i,1,B.size()){
            if (B[i][0]==B[i-1][0]){
                ans = "Yes";
                print(ans);
                //x
                cout << B[i].size() - 1 << " ";
                print_array(B[i], 1, B[i].size() - 1);
                //y
                cout << B[i-1].size() - 1 << " ";
                print_array(B[i-1], 1, B[i-1].size() - 1);
                break;
            }
        }

        if (ans == "No"){
            print(ans);
        }
    }
    return 0;
}

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

const int mod = 998244353;

int a[200001], visited[200001] = {0};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int cnt = 0, ans = 0;
    for (int i = 1; i <= n; ++i)
        if (!visited[i]) {
            ++cnt;
            visited[i] = cnt;
            for (int j = a[i]; ; j = a[j])
                if (visited[j]) {
                    if (visited[j] == cnt) ++ans;
                    break;
                } else visited[j] = cnt;
        }
    cnt = 1;
    while (ans--) cnt = cnt * 2 % mod;
    cnt = (cnt + mod - 1) % mod;
    cout << cnt;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

int dp[13][202];

int32_t main(){
   ios;
   int L;
   cin>>L;

   dp[0][0]=1;
   F(i,1,12){
   	F(j,0,L){
   		F(l,1,L-11)
			if(j>=l) dp[i][j]+=dp[i-1][j-l];
   	}
   }
   cout<<dp[12][L]<<endl;
}

//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand
#include <random>
#include <functional>
#include <list>
#include <stack>

using namespace std;
#define ll long long
#define ll128 long long
#define lp(i,n) for(ll i=0;i<n;i++)

#define modd 1000000007
#define mod2 998244353
const double EPS = 1e-20;
const double PI = acos(-1);

#define INF 8223372036854775807ll
#define ALL(a)  (a).begin(),(a).end()

typedef pair<long long, long long> pl;
typedef pair<double, double> pd;
typedef pair<ll, string> pls;

typedef string::const_iterator State;
class ParseError {};

vector<ll> qv[200001];
ll N;
ll P[200001];
ll Q;
ll U[200001];
ll D[200001];
ll ans[200001];
ll count_d[200001];
vector<ll> child[200001];

void Search(ll node, ll cd[200001], ll depth) {

  	lp(i, qv[node].size()) {
		ll qnum = qv[node][i];
		ans[qnum] -= cd[D[qnum]];
	}
  cd[depth]++;

  lp(i, child[node].size()) {
    Search(child[node][i], cd, depth + 1);
  }

	lp(i, qv[node].size()) {
		ll qnum = qv[node][i];
		ans[qnum] += cd[D[qnum]];
	}

}

int main() {
	cin >> N;
	for (ll i = 2; i <= N; i++) {
		cin >> P[i];
		child[P[i]].push_back(i);
	}
	cin >> Q;
	lp(i, Q)cin >> U[i] >> D[i];
	lp(i, Q) {
		qv[U[i]].push_back(i);
	}
	Search(1, count_d, 0);
	lp(i, Q) {
		cout << ans[i] << endl;
	}

	//cout << fixed << setprecision(12) << bb << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int h,w,sum=0,mx=998244353;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int in;
      cin>>in;
      sum+=in;
      mx=min(mx,in);
    }
  }
  cout<<sum-mx*h*w<<endl;
}

/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  map<int, int> cnt;
  int cur = 0;
  fore(i, 0, n) fore(j, 0, m) {
    int num;
    cin >> num;
    cnt[num]++;
    cur += num;
  }
  auto it = cnt.begin();
  cout << cur - n * m * (*it).first << '\n';

  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,ans;
char a[105][105];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)cin>>a[i][j];
	for(int i=1;i<=n;i++)
	for(int j=2;j<=m;j++)if(a[i][j]=='.'&&a[i][j-1]=='.')ans++;
	for(int j=1;j<=m;j++)
	for(int i=2;i<=n;i++)if(a[i][j]=='.'&&a[i-1][j]=='.')ans++;
	printf("%d",ans);
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int res = 0;
    rep(i, h){
        rep(j, w){
            if(s[i][j] != '.') continue;
            if(j != w-1)if(s[i][j+1] == '.') res++;
            if(i != h-1)if(s[i+1][j] == '.') res++;
        }
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


#include <iostream>
#include <string>

using namespace std;
using ll = long long;

int main(void){
  string X;

  cin >> X;

  if (X == "0") {
    cout << 0 << endl;
    return 0;
  }

  string ans;
  for (auto x : X) {
    if (x != '.') {
      ans += x;
    } else {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define ordered_set tree<int, null_type, less<int >,rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ll long long
#define ld long double
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define vii vector<int>
#define pii pair<ll,ll>
#define vll vector<ll>
#define clr(v, d) memset(v,d,sizeof(v))
using namespace std;
const int N = 2e6 + 500, mod = 1e9 + 7;
int a[N];
vector<int> dx[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin>>n;
    ld ans=0;
    for (int i = 1; i <n ; ++i) {
        ans+=(ld)n/i;
    }
    cout<<fixed<<setprecision(6)<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
using vp=vector<P>;
using vvp=vector<vp>;
const int inf=1e9+7;
const ll INF=9e18/2;
const long double PI = acosl(-1.0);
const long double EPS=1e-10;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
bool pair_comp(const pair<long,long> &A,const pair<long,long> &B){if(A.first==B.first)return A.second>B.second;return A.first<B.first;}//F昇→S降
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){//cout<<fixed<<setprecision(20);
  ll n;
  cin>>n;
  ll ans=INF;
  ll t=1;
  rep(b,0,70){
    if(t>n)break;
    ll a,c;
    a=n/t;
    c=n%t;
    chmin(ans,a+b+c);
    t*=2;
  }
  cout<<ans<<endl;
}

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <vector>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; i < n; i++)
#define sr(i, n) for (i = 0; i < n.length(); i++)

// template<typename... T>
// void read(T&... args) {
// 	((cin >> args), ...);
// }

// // template<typename... T>
// // void write(T&&... args) { //rvalue reference is new to C++
// // 	((cout << args << " "), ...);
// // }

void rank0001()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     //freopen("input.txt", "r", stdin);
    //     //freopen("output.txt", "w", stdout);
    // #endif
}

int main()
{
    rank0001();
    ll n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (i + 2 != s.length())
        {
            if (s[i] == 'f' && s[i + 1] == 'o' && s[i + 2] == 'x')
            {
                s.erase(i, 3);
                if (i == 0 || i == 1 || i == 2)
                    i = -1;
                else
                    i -= 3;
            }
        }
        //cout << s.length();
    }
    cout << s.length() << endl;
}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define DBG(a) cout<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 998244353;
long double pi = acosl(-1);
const ll infl = 1e17+100;
const int inf = 1e9+100;
const int nmax = 1e6+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>a(n+1);
    for(int &x : a) cin>>x;

    int kom = inf;
    for(int i=0; i<n; i++){
        kom = min(kom, abs(a[i]-a[i+1]));
    }

    vector< vector<int> >ans(kom, vector<int>(n+1) );
    for(int i=0; i<=n; i++){
        int z = a[i]/kom;
        int extra = a[i]%kom;
        for(int j=0; j<kom; j++){
            ans[j][i] = z;
            if(j<extra) ans[j][i]++;
        }
    }

    cout<<kom<<"\n";
    for(auto z : ans){
        for(auto x : z){
            cout<<x<<" ";
        }
        cout<<"\n";
    }
}
/*
*/

#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

typedef long long LL;
const int N = 810, inf = 1e9;

int n, m;
int a[N][N];
int s[N][N];
int vis;

bool check(int x){
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] > x);

    int res = inf;
    for(int i = m; i <= n; i ++)
        for(int j = m; j <= n; j ++)
            res = min(res, s[i][j] - s[i - m][j] - s[i][j - m] + s[i - m][j - m]);
    return res <= m * m - vis;
}

int main(){
    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            scanf("%d", &a[i][j]);

    vis = m * m / 2;
    if(m & 1) vis ++;
    int l = 0, r = 1e9;
    while(l < r){
        int mid = l + r >> 1;
        if(check(mid)) r = mid;
        else l = mid + 1;
    }
    printf("%d\n", r);
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define sortall(v) sort(all(v))
#define deb(x) cout<<#x<<" = "<<x<<'\n'
#define deb2(x, y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<'\n';
#define si(x) scanf("%d", &x)
#define sii(x,y) scanf("%d%d", &x, &y)
#define sll(x) scanf("%lld", &x)
#define ss(s) scanf("%s",&s)
#define sc(c) scanf("%c", &c)
#define pi(x) printf("%d\n", x)
#define ps(s) printf("%s\n",s)
#define pfll(x) printf("%lld\n", x)
#define pb(x) push_back(x)
#define HI cout<<"Hi\n"
#define mp(x, y) make_pair(x, y)
#define mt(x, y, z) make_tuple(x, y, z)
#define F first
#define S second
#define PI 3.1415926535897932384626
#define fr(i, n) for(auto i=0; i<n; ++i)
#define frn(i, ini, fin) for(int i=ini; i<=fin; ++i)

// ========= typedef ========== //

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> t3;
typedef std::vector<t3> vt3;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<pii> vpii;
typedef std::vector<pll> vpll;
typedef unordered_map<int, int> umii;
typedef unordered_map<char, int> umci;
typedef unordered_set<int> usi;

//===========mod and data structs=============== //
//100 400
//40 500
const int mod = 1e9 + 7;
// const int N = 2*1e5+5, M = 1e6;
const ll X = 1e6;
bool primes[X+1];

unordered_map<int, int> index_energy;
int grid[105][105];

const int INF = 1e9;
int n,k;

//============================//
ll arr[10];
// ============functions =========//
int mpow(int base, int exp);
void mmul(int &num , int num2);
void printVec(vi v);
void SieveOfEratosthenes(ll n);
std::vector<int> arr8;
ll poww(int base, int exp);
// ================================= //

void solve(){
  cin>>n;
  vi a(n), b(n);
  fr(i, n){
    cin>>a[i];
  }
  fr(i, n){
    cin>>b[i];
  }
  int ans = 0;
  fr(i, n){
    ans+=a[i]*b[i];
  }
  if(ans)cout<<"No\n";
  else cout<<"Yes\n";
}

int main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t=1;

  while(t--) solve();
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void mmul(int &num , int num2){
  num = ((num%mod)*(num2%mod))%mod;
}

void SieveOfEratosthenes(ll n){
  memset(primes, true, sizeof(primes));
  primes[0]=primes[1]=false;
  for(ll i=2; i*i<=n; ++i){
    if(primes[i]){
      for(ll j=i*i; j<=n; j+=i){
        primes[j]=false;
      }
    }
  }
}
ll poww(int base, int exp) {
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) ;
    base = (base * base);
    exp >>= 1;
  }
  return result;
}
// void printVec(std::vector<string> v){
//   fr(i,v.size()){
//     cout<<v[i]<<" ";
//   }
//   cout<<endl;
// }

//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

/*
ビット全探索
for(int bit=0;bit<(1<<n);bit++){
        for(int i=0;i<n;i++){
            if(bit & (1<<i)){
            }
        }
*/

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main(){
    //小数の桁数の出力指定
    //cout<<fixed<<setprecision(10);
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    char a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c)cout<<"Won"<<endl;
    else cout<<"Lost"<<endl;
    return 0;
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;

using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;

#define pb push_back
#define mp make_pair
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) reps(i, 1, n + 1)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)

#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" <<endl;
#define kd(x) cerr << "\033[33m" << #x << ": " << x << ", \033[m";
#define kdl(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << ", \033[m";
#define kde(x) cerr << "\033[33m" << #x << ": " << x << ", \033[m" << endl;

inline int in_int() {int x; cin >> x; return x;}
inline ll in_ll() {ll x; cin >> x; return x;}
inline string in_str() {string x; cin >> x; return x;}
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}

ll dfs(int i, int *v, const int n, int a, int w)
{
    //kd(i); kde(a);
    if (a == 0) return 1;
    if (i+1 == n) return 0;
    if (v[i] == 1) return dfs(i+1, v, n, a, w);
    int *u = new int[n];
    rep(j,n) u[j] = v[j];
    ll ret = 0;
    // try 1
    u[i] = 1;
    if (i+1 < n && (i+1) % w && u[i+1] != 1) {
        u[i+1] = 1;
        ret += dfs(i+1, u, n, a-1, w);
        u[i+1] = 0;
    }
    if (i+w < n && u[i+w] != 1) {
        u[i+w] = 1;
        ret += dfs(i+1, u, n, a-1, w);
        u[i+w] = 0;
    }
    // try 0
    u[i] = 0;
    ret += dfs(i+1, u, n, a, w);
    delete [] u;
    return ret;
}

int main()
{
    int h = in_int();
    int w = in_int();
    int a = in_int();
    int b = in_int();
    int *v = new int[h*w];
    rep(j,h*w) v[j] = 0;
    cout << dfs(0, v, h*w, a, w);
    return 0;
}

#include <iostream>
#include <algorithm>
#include <list>
#include <string>

int h, w;

int f (int a, int b, std::list<int> r) {
  int s = 0;
  if (a == 0 || r.empty()) {
    s = 1;
  } else {
    int m = r.front();

    r.pop_front();

    if (b > 0) {
      s += f(a, b-1, r);
    }

    if ((m+1) % w != 0 && m+1 == r.front()) {
      r.pop_front();
      s += f(a-1, b, r);
      r.push_front(m+1);
    }

    auto i = r.begin();
    while(i != r.end() && *i < m+w) i++;
    if (*i == m+w) {
      auto next = std::next(i);
      r.erase(i);
      s += f(a-1, b, r);
      r.insert(next, m+w);
    }
  }

  return s;
}

int main() {
  int a, b;

  std::cin >> h >> w >> a >> b;

  std::list<int> r;

  for(int i = 0 ; i < h*w; i++) r.push_back(i);

  int s = f(a, b, r);
  std::cout << s << std::endl;

  return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    long long a[n];
    long long mx = 0;
    long long sum = 0;
    long long mospos = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i) a[i] += a[i - 1];
        mospos = max(a[i], mospos);
        mx = max(sum + mospos, mx);
        sum += a[i];
    }
    cout << mx << endl;
}

/*
ID: Λινδα
LANG: C++
TASK: abc196c
*/
#include <stdio.h>
long long ppct(long long x)
{
	long long i=0,s=1;
	do
	{
		x=x/10;
		i++;
	}
	while(x!=0);
	while(i--)
	{
		s=s*10;
	}
	return s;
}
int read(){char c=getchar();int t=0,f=1;while(c<'0'||c>'9'){if(c=='-'){f=-1;}c=getchar();}while(c>='0'&&c<='9'){t=(t<<1)+(t<<3)+(c^48);c=getchar();}return t*f;}
void write(int x){char ch[50];int l=0;if(x<0){putchar('-');x=-x;}do{ch[l++]=x%10+'0';x=x/10;}while(x);while(l){putchar(ch[--l]);}}
int main()
{
//	freopen("main.in","r",stdin);
//	freopen("main.out","w",stdout);
//	freopen("main.err","w",stderr);
	long long i=1,n,s=0;
	scanf("%lld",&n);
	while(i*ppct(i)+i<=n)
	{
//		printf("%lld ",i*ppct(i)+i);
		s++;
		i++;
	}
	printf("%lld\n",s);
//	fclose(stdin);
//	fclose(stdout);
//	fclose(stderr);
	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
const int N = 2e5 + 5;
const ll inf = 1e18;
const ll mod = 998244353;

ll n, k, a[100][100], s, visr[100], visc[100], fact[100];
vector<ll> r[100], c[100];

bool check_col(int x, int y){
	for (int i = 1; i <= n; i++)
		if (a[i][x] + a[i][y] > k)
			return 0;
	return 1;
}

bool check_row(int x, int y){
	for (int i = 1; i <= n; i++)
		if (a[x][i] + a[y][i] > k)
			return 0;
	return 1;
}

void dfsc(int u){
	s++;
	visc[u] = 1;
	for (auto p: c[u])
		if(!visc[p])
			dfsc(p);
}

void dfsr(int u){
	s++;
	visr[u] = 1;
	for (auto p: r[u])
		if(!visr[p])
			dfsr(p);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> k;

	fact[0] = 1;
	for (ll i = 1; i<= n; i++)
		fact[i] = fact[i - 1] * i % mod;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> a[i][j];

	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (check_col(i, j))
			{
				c[i].push_back(j);
				c[j].push_back(i);
			}

	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if (check_row(i, j))
			{
				r[i].push_back(j);
				r[j].push_back(i);
			}

	ll ans = 1;

	for (int i = 1; i <= n; i++)
	if (!visc[i]){
		s = 0;
		dfsc(i);
		ans = ans * fact[s] % mod;
	}

	for (int i = 1; i <= n; i++)
	if (!visr[i]){
		s = 0;
		dfsr(i);
		ans = ans * fact[s] % mod;
	}

	cout << ans;
}

/*
* @author : ashnove
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl;
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;}
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b)
{
    if(a.first < b.first )
        return true;
    if( a.first==b.first && a.S != b.second )
       return true;
    return false;
}
//me
ll const mod = 998244353;
ll const inf = 1e18;
ll const maxn = 1e3+1;

ll f[maxn];
void fact(){
      f[0]=1;
      for(ll i = 1; i< maxn; i++)
            f[i] = (f[i-1]*i)%mod;
}

ll par_row[maxn], par_col[maxn];
ll Rank1[maxn], Rank2[maxn];

ll find1(ll x){
      if( par_row[x] < 0)
            return x;
      return par_row[x] = find1(par_row[x]);
}
ll find2(ll x){
      if( par_col[x] < 0)
            return x;
      return par_col[x] = find2(par_col[x]);
}

void merge1(ll a, ll b){
      a = find1(a), b = find1(b);
      if(a==b)return;
      if(Rank1[a] > Rank1[b]){
            par_row[b]= a;
            Rank1[a]+=Rank1[b];
      }
      else{
            par_row[a]=b;
            Rank1[b]+=Rank1[a];
      }
}

void merge2(ll a, ll b){
      a = find2(a), b = find2(b);
      if(a==b)return;
      if(Rank2[a] > Rank2[b]){
            par_col[b]=a;
            Rank2[a]+=Rank2[b];
      }
      else{
            par_col[a]=b;
            Rank2[b]+=Rank2[a];
      }

      //par_col[b]=a;
}

void solve()
{
      fact();

      ll n, K; cin >> n >> K ;
      fill(par_row, par_row+n, -1);
      fill(par_col, par_col+n, -1);
      fill(Rank2, Rank2+n, 1);
      fill(Rank1, Rank1+n, 1);

      ll a[n][n];
      f(i,0,n) f(j,0,n) cin >> a[i][j];

      f(i,0,n){

            f(j,i+1,n){
                  bool ok = 1;
                  f(k,0,n){

                        if( a[j][k]+a[i][k]> K )
                              ok = 0;

                  }
                  if(ok){
                        merge1(i,j);
                  }
            }

      }

      f(i,0,n){

            f(j,i+1,n){
                  bool ok = 1;
                  f(k,0,n){

                        if( a[k][i]+a[k][j]> K )
                              ok = 0;

                  }
                  if(ok){
                        merge2(i,j);
                  }
            }

      }

      ll ans= 1;

      f(i,0,n){
            if(par_row[i]<0)
                  ans = (ans*f[abs(Rank1[i])])%mod;
      }
      f(i,0,n){
            if(par_col[i]<0)
                  ans = (ans*f[abs(Rank2[i])])%mod;
      }

      cout << ans << endl;

}

int main() {
Knucklehead
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/

          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < int(NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)

template <typename T>
void chmin(T& a, T b){ if(a > b) a = b; }
template <typename T>
void chmax(T& a, T b){ if(a < b) a = b; }

ll ss(ll i, ll n)
{
    if(i < n) return 0;
    else if(n <= i && i < 2*n) return i - (n-1);
    else if(2*n <= i && i < 3*n) return 3*n-1-i;
    else return 0;
}

int main()
{
    cin.tie( 0 ); ios::sync_with_stdio( false );
    // ----------------------------------------------------------------

    ll n,k;
    cin >> n>>k;

    ll s = 0;
    bool ok = false;
    REP(i,3*n-2)
    {
        s += ss(i+n, n);
        s -= ss(i, n);

        if(k > s)
        {
            k -= s;
            continue;
        }
        else
        {
            REP(j, n)
            {
                ll s2 = ss(i+n-j, n);
                if(k > s2)
                {
                    k -= s2;
                    continue;
                }
                else
                {
                    ll a = j;
                    ll c = min(i-a, n-1)-(k-1);
                    ll b = i - a - c;
                    cout << a+1 << " " << b+1 << " " << c+1 << endl;
                    ok = true;
                    break;
                }
            }
        }
        if(ok) break;
    }

    // ----------------------------------------------------------------
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin >> h >> w;
    vector<string> s(h);
    dsu uf(h+w);
    uf.merge(0,h);
    uf.merge(h-1,h+w-1);
    uf.merge(h,h+w-1);
    REP(i,h){
        cin >> s[i];
        REP(j,w){
            if(s[i][j]=='#') uf.merge(i,j+h);
        }
    }
    map<int,int> mh,mw;
    REP(i,h) mh[uf.leader(i)]++;
    REP(i,w) mw[uf.leader(i+h)]++;
    cout << min(mh.size(),mw.size())-1 << endl;
}


                              //ABHISHEK AGRAWAL,BIT mesra//
//Author: Abhishekagrawal
//Date: 09/05/2021
//Time: 18:34:50
#include<bits/stdc++.h>
using namespace std;
#define booga cout << "booga" << endl
#define int long long int
#define pb push_back
#define f first
#define s second
#define mod (ll)1000000007
#define pi (double)acos(-1.0)
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define safai(...) Clearing_out(__VA_ARGS__)
void Clearing_out() { return; }

template <typename Head, typename... Tail>
void Clearing_out(Head &H, Tail & ... T) {
	H.clear();
	Clearing_out(T...);
}

const int N=200040;int a[N],b[N],c[N],ans,sum;
int n;

void testcase(){
  int k;
  cin>>k>>n;
  bool vis[100000];
  memset(vis,true,sizeof(vis));
  for(int i=1;i<=1000;i++){
    int cur=(100+k)*i;
    cur/=100;
    vis[cur]=false;
  }
  int x=1,cc=1;
  vector<int>v;
  for(int i=1;i<=1000;i++){
    if(vis[i]) v.push_back(i-(100+k-1)/k*(cc++));
  }
  int n1=(n-1)/k;
  int cu;
  if(n1==0) cu=0;
  else cu=(v[k-1]+1)*n1;
  n1=n%k;
  n1--;
  if(n1==-1) n1=k-1;
  cu+=v[n1];
  cout<<((100+k-1)/k)*n+cu;

  return;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  /*Today's thought: Push yourself,because no one else is going to do it for you.*/
  int test=1;
  // cin>>test;
  while(test--){
    testcase();
  }
  cerr << "Time : " << 1000 *((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  return 0;
}

#include<bits/stdc++.h>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef long long ll;
char s[2003][2003];
ll mod=1e9+7;
ll ma[2003][2003]={0};
ll maxx[2003][2003]={0};
ll may[2003][2003]={0};
ll mas[2003][2003]={0};
ll h,w;
int main(void)
{
	scanf("%lld%lld",&h,&w);
	for(ll i=1;i<=h;i++)
	{
		scanf("%s",s[i]+1);
	}
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			if(i==1&&j==1){ma[i][j]=maxx[i][j]=may[i][j]=mas[i][j]=1;continue;}
			if(s[i][j]=='#') ma[i][j]=maxx[i][j]=may[i][j]=mas[i][j]=0;
			else
			{
				ma[i][j]=maxx[i-1][j]+may[i][j-1]+mas[i-1][j-1];
				maxx[i][j]=ma[i][j]+maxx[i-1][j];
				may[i][j]=ma[i][j]+may[i][j-1];
				mas[i][j]=ma[i][j]+mas[i-1][j-1];
				ma[i][j]%=mod;
				maxx[i][j]%=mod;
				may[i][j]%=mod;
				mas[i][j]%=mod;
			}
		}
	}
	printf("%lld\n",ma[h][w]);
}


#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}
struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int main() {
    ll n, w;
    cin >> n >> w;
    vector<ll> s(n);
    vector<ll> t(n);
    vector<ll> p(n);
    REP(i, n) {
        cin >> s[i];
        cin >> t[i];
        cin >> p[i];
    }
    ll wpm = 0;
    vector<ll> a(300000);
    rep(i, 0, n) {
        a[s[i]] += p[i];
        a[t[i]] -= p[i];
    }
    ll maxwpm = 0;
    REP(i, 300000) {
        wpm += a[i];
        maxwpm = max(wpm, maxwpm);
    }
    if (w >= maxwpm) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

// Problem: F - +1-1x2
// Contest: AtCoder - AtCoder Beginner Contest 188
// URL: https://atcoder.jp/contests/abc188/tasks/abc188_f
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
#include<bits/stdc++.h>
using namespace std;
#define _rep(i, x, y) for(int i = (int)x; i < (int)y; ++i)
#define _dep(i,x,y) for(int i = (int)x; i > (int)y; i--)
#define PII pair<int,int>
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define PQ priority_queue
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<ll> VL;
typedef vector<vector<ll>> VLL;
constexpr int mod = 1e9 + 7;
constexpr ll KINF = 0x3f3f3f3f;
constexpr double eps = 1e-7;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	ll x, y;
	cin >> x >> y;
	unordered_map<ll, ll> memo;
	function<ll(ll)> dfs = [&](ll u){
		if(memo[u]) return memo[u];
		if(u <= x) return memo[u] = x - u;
		ll ans = u - x;
		if(u % 2 == 0) ans = min(ans, dfs(u / 2) + 1);
		else ans = min({dfs((u - 1) / 2) + 2, dfs((u + 1) / 2) + 2, ans});
		return memo[u] = ans;
	};
	cout << dfs(y) << endl;
	return 0;
}


                              //ABHISHEK AGRAWAL,BIT mesra//
                      //Newbie......You have to be odd to be no. ONE :)//
//Author: Abhishekagrawal
//Date: 15/03/2021
//Time: 04:36:03
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fl float
#define vll vector<ll>
#define pii pair<int,int>
#define vpll vector<pair<ll,ll>>
#define pb push_back
#define f first
#define s second
#define mll map<ll,ll>
#define mp make_pair
#define sp(n) fixed<<setprecision(n)
#define mod (ll)1000000007
#define sortv(v) sort(v.begin(),v.end())
#define INF (ll)(1e15)
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define rloop(n,i) for(int i=n-1;i>=0;i--)
#define sorta(a) sort(a,a+n,greater<ll>())
#define countone(n) __builtin_popcount(n)
#define numoftrailzero(n) __builtin_ctz(n)
#define maxpowoftwo(n) __builtin_clz(n)
#define leastindexwithone(n)  __builtin_ffs(n)
#define what_is(x) cerr << #x << " is " << x << endl;
#define pfv(v) cout<<v.size()<<"\n";loop(i,v.size()) cout<<v[i]<<" ";cout<<"\n";
#define pv(v) loop(i,v.size()) cout<<v[i]<<" ";
#define all(v) v.begin(),v.end()
#define mset(dp,val) memset(dp,val,sizeof(dp))
ll test,n;ll sum,ans;
void the_happiest_place_on_earth()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #ifdef ENABLE_FILE_IO
    freopen("out.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
  #endif
}
// bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b){
//   if(a.s+2*a.f==b.s+2*b.f) return a.f>b.f;
//   return (a.s+2*a.f>b.s+2*b.f);
// }
const int N=200040;ll a[N],b[N],c[N],par[N],Size[N],present[N],color[N];
ll sieve_spf[1000110];
ll n1=1000000;
void Sieve_spf(){
 loop(i,n1) sieve_spf[i]=i;
  sieve_spf[0]=-1;
  sieve_spf[1]=1;
  for(int i=2;i<n1;i+=2) sieve_spf[i]=2;
  for(ll i=3;i<n1;i+=2){
    if(sieve_spf[i]==i){
      for(ll j=(i*i);j<n1;j+=i){
        if(sieve_spf[j]==j) sieve_spf[j]=i;
      }
    }
  }
}
vll v;
void dfs(int i, ll j){
	if(i==15){
		for(int k=0; k<n; ++k)
			if(__gcd(a[k],j)<2) return;
		ans=min(ans,j); return;
	}
	dfs(i+1,j);
	dfs(i+1,j*v[i]);
}
void testcase(){
  cin>>n;
  loop(i,n) cin>>a[i];
  ans=LLONG_MAX;
  dfs(0,1);
  cout<<ans<<"\n";
  return;
}

int main(){
  the_happiest_place_on_earth();
  // Today's thought: Push yourself,because no one else is going to do it for you.
  // Things are not always #000000 and #FFFFFF
  // g++ -o a BB.cpp -DENABLE_FILE_IO;./a
  // g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o a file_name.cpp;./a
  test=1;int t=0;
  Sieve_spf();
  loop1(i,50){
    if(sieve_spf[i]==i&&i!=1) v.pb(i);
  }
  // cin>>test;
  while(test--){
    //cout<<"Case #"<<++t<<": ";
    testcase();
  }
  cerr << "Time : " << 1000 *((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
*/

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
// avoid unordered_map and unordered_set!!!
#include <vector>
#include <utility>

using namespace std;

using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using pi64 = pair<i64, i64>;

#define vec vector
#define let const
#define DRi64(x) i64 x; cin >> x;
#define DRS(x) string x; cin >> x;
#define DRVi64(v, n) vec<i64> v(n); { for (i64 i = 0; i < n; ++i) { cin >> v[i]; }}
#define DRpi64(x) pi64 x; cin >> x.first >> x.second;

#ifdef DEBUG
#define P(x) cerr << x << "\n"
#else
#define P(x)
#endif

constexpr i64 MAXN = 3*100*1000LL+5LL;
constexpr i64 MOD = 1000000007LL;
constexpr i64 INF64 = MOD * MOD;

bool
dfs(const i64 u, const i64 p, vec<i64>& colour, const i64 mask, const vec<vec<i64>>& adj)
{
    bool ok = true;
    for (let i64 nbr : adj[u])
    {
        if (nbr == p)
        {
            continue;
        }
        if (mask & (1LL<<nbr))
        {
            continue;
        }

        if (colour[nbr] < 0)
        {
            colour[nbr] = !colour[u];
            ok &= dfs(nbr, u, colour, mask, adj);
        }
        if (colour[nbr] == colour[u])
        {
            return false;
        }
    }
    return ok;
}

int
main()
{
    ios_base::sync_with_stdio(false);
    // fast io: see 1423K
    cin.tie(nullptr);
    cout.tie(nullptr);

    DRi64(N); DRi64(M);
    vec<vec<i64>> adj(N);
    for (i64 i = 0; i < M; ++i)
    {
        DRi64(A); DRi64(B);
        A--, B--;
        adj[A].push_back(B);
        adj[B].push_back(A);
    }

    i64 ways = 0;
    for (i64 mask = 0; mask < (1LL << N); ++mask)
    {
        bool bad = false;
        for (i64 b = 0; !bad && b < N; ++b)
        {
            if ((1LL<<b) &  mask)
            {
                for (let i64 nbr : adj[b])
                {
                    bad |= (mask & (1LL<<nbr));
                }
            }
        }
        if (bad)
        {
            continue;
        }
        P(bitset<4>(mask));
        i64 subways = 1;
        // how many  ways to colour the uncoloured vertices?
        vec<i64> colour(N, -1);
        for (i64 b = 0; b < N; ++b)
        {
            if ((1LL<<b) & mask)
            {
                continue;
            }
            if (colour[b] >= 0)
            {
                continue;
            }
            colour[b] = 0;
            let bool subproblem = dfs(b, -1, colour, mask, adj);
            bad |= subproblem == 0;
            // indepent subproblems -- different components
            subways *= 2;
        }
        ways += !bad * subways;
    }
    cout << ways << "\n";

    return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
#define int long long
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#define EPS 0.000000001
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
int pos[1501][1501],arr[500001],arr2[500001];
void DFS(int X,int Y,int DIR){
if(X>1500||Y>1500||X<0||Y<0)
return;
if((pos[X][Y]==1)||pos[X][Y]==2)
return;
if(pos[X][Y]==DIR)
return;
pos[X][Y]=DIR;
if(DIR==3)
DFS(X+1,Y,3);
else if(DIR==4)
DFS(X-1,Y,4);
else if(DIR==5)
DFS(X,Y+1,5);
else
DFS(X,Y-1,6);
}
int32_t main()
{
//freopen("output.txt","w",stdout);
//freopen("colors.in","r",stdin);
cin.tie(0),iostream::sync_with_stdio(0);
int x,y,n,m,X,Y;
cin>>x>>y>>n>>m;
for(int i=0;i<n;i++){
cin>>X>>Y;
X--,Y--;
pos[X][Y]=1;
arr[i]=X,arr2[i]=Y;
}
for(int i=0;i<m;i++){
cin>>X>>Y;
X--,Y--;
pos[X][Y]=2;
}
for(int i=0;i<n;i++){
DFS(arr[i]+1,arr2[i],3),DFS(arr[i]-1,arr2[i],4),DFS(arr[i],arr2[i]+1,5),DFS(arr[i],arr2[i]-1,6);
}
int counter=0;
for(int i=0;i<x;i++){
for(int l=0;l<y;l++)
counter+=((pos[i][l]>=3)?1:0);
}
cout<<counter+n;
return 0;
}

#include <bits/stdc++.h>

using namespace std;
using i64 = long long;

const i64 N = 1000, G = 30;

struct Node {
    //0:up 1:right 2:down 3:left
    double cost[4] = {4500, 4500, 4500, 4500};
};

i64 dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

Node node[G][G];

int main() {
    for (i64 turn = 1; turn <= N; turn++) {
        i64 s[2], t[2];
        cin >> s[0] >> s[1] >> t[0] >> t[1];
        vector<vector<i64>> cost(G, vector<i64>(G, 1e9));
        vector<vector<pair<i64, i64>>> bef(G, vector<pair<i64, i64>>(G, {-1, -1}));
        cost[s[0]][s[1]] = 0;
        priority_queue<tuple<i64, i64, i64>, vector<tuple<i64, i64, i64>>, greater<tuple<i64, i64, i64>>> que;
        que.push({0, s[0], s[1]});
        while (que.size()) {
            auto[c, x, y] = que.top();
            que.pop();
            if (cost[x][y] < c) {
                continue;
            }
            for (i64 i = 0; i < 4; i++) {
                i64 ddx = x + dx[i], ddy = y + dy[i];
                if (ddx < 0 || G <= ddx || ddy < 0 || G <= ddy) {
                    continue;
                }
                i64 randCost = node[x][y].cost[i] * pow(((double) turn / N), 2);
                if (cost[x][y] + randCost < cost[ddx][ddy]) {
                    cost[ddx][ddy] = cost[x][y] + randCost;
                    bef[ddx][ddy] = {x, y};
                    que.push({cost[ddx][ddy], ddx, ddy});
                }
            }
        }
        string ans;
        int nowX = t[0], nowY = t[1];
        while (nowX != s[0] || nowY != s[1]) {
            if (nowX - 1 == bef[nowX][nowY].first) {
                ans += "D";
                nowX--;
            } else if (nowX + 1 == bef[nowX][nowY].first) {
                ans += "U";
                nowX++;
            } else if (nowY - 1 == bef[nowX][nowY].second) {
                ans += "R";
                nowY--;
            } else if (nowY + 1 == bef[nowX][nowY].second) {
                ans += "L";
                nowY++;
            }
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
        double length;
        cin >> length;
        length /= ans.size();
        for (char i:ans) {
            if (i == 'D') {
                node[nowX][nowY].cost[3] += length;
                node[nowX][nowY].cost[3] /= 2;
                nowX++;
                node[nowX][nowY].cost[1] += length;
                node[nowX][nowY].cost[1] /= 2;
            } else if (i == 'U') {
                node[nowX][nowY].cost[1] += length;
                node[nowX][nowY].cost[1] /= 2;
                nowX--;
                node[nowX][nowY].cost[3] += length;
                node[nowX][nowY].cost[3] /= 2;
            } else if (i == 'R') {
                node[nowX][nowY].cost[0] += length;
                node[nowX][nowY].cost[0] /= 2;
                nowY++;
                node[nowX][nowY].cost[2] += length;
                node[nowX][nowY].cost[2] /= 2;
            } else if (i == 'L') {
                node[nowX][nowY].cost[2] += length;
                node[nowX][nowY].cost[2] /= 2;
                nowY--;
                node[nowX][nowY].cost[0] += length;
                node[nowX][nowY].cost[0] /= 2;
            }
        }
    }
    return 0;
}


#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int P[200001];
int A[100000];
int find(int A) {
	if (P[A] < 0) return A;
	return P[A] = find(P[A]);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	rep(i, 200001) P[i] = -1;
	int N;
	cin >> N;
	rep(i, N >> 1) cin >> A[i];
	int gomi;
	if (N & 1) cin >> gomi;

	int kotae = 0;
	for (int i = (N >> 1) - 1; i >= 0; i--) {
		int a = find(A[i]);
		int b;
		cin >> b;
		b = find(b);
		if (a == b) continue;
		if (P[a] > P[b]) swap(a, b);
		P[a] += P[b];
		P[b] = a;
		kotae++;
	}
	co(kotae);

	Would you please return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define inf 0x3f3f3f3f
#define PI 3.1415926
typedef long long ll;
const int maxn=25;
int n;
void solve()
{
	cin>>n;
	int x0,x1,y0,y1;
	cin>>x0>>y0>>x1>>y1;
	x1-=x0,y1-=y0;
	double ang=(n-2)*PI/n/2;
	double d=sqrt(1.0*x1*x1+1.0*y1*y1);
	double d1=d*cos(ang);
	double x=x1/d,y=y1/d;
	double u=x0+d1*(x*cos(ang)+y*sin(ang)),v=y0+d1*(y*cos(ang)-x*sin(ang));
	printf("%.10lf %.10lf\n",u,v);
}
int main()
{
    solve();
    return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const ll LINF = INT64_MAX;
const int IINF = INT32_MAX;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;

    vector<int> l(n, IINF), r(n, -IINF);
    REP(i, n){
        int x, c;
        cin >> x >> c;
        --c;
        chmin(l[c], x);
        chmax(r[c], x);
    }

    vector<P> d;
    d.emplace_back(0, 0);
    REP(i, n) if(l[i] != IINF){
        d.emplace_back(l[i], r[i]);
    }
    d.emplace_back(0, 0);

    vector<ll> dp(2);
    FOR(i, 1, SIZE(d)-1){
        vector<ll> p(2, LINF);
        swap(p, dp);

        int L = d[i].first, R = d[i].second;
        REP(j, 2){
            int x = j ? d[i-1].second : d[i-1].first;
            chmin(dp[0], p[j] + abs(x-R) + (R-L));
            chmin(dp[1], p[j] + abs(x-L) + (R-L));
        }
    }

    cout << dp[0] << endl;

    return 0;
}

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

const int maxl=3e5+10;
const ll inf=1ll<<60;

int n,m,k,cnt,tot,cas,ans;
struct node
{
	int x,c;
}a[maxl];
int l[maxl],r[maxl];
ll dp[maxl][2];
bool vis[maxl];
char s[maxl];

inline bool cmp(const node &a,const node &b)
{
	return a.x<b.x;
}

inline void prework()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].x,&a[i].c);
		if(l[a[i].c]==0)
			l[a[i].c]=r[a[i].c]=a[i].x;
		else
			l[a[i].c]=min(l[a[i].c],a[i].x),
			r[a[i].c]=max(r[a[i].c],a[i].x);
	}
}

inline void chmi(ll &x,ll y)
{
	x=min(x,y);
}

inline void mainwork()
{
	for(int i=1;i<=n;i++)
	if(l[i]==0)
	{
		l[i]=l[i-1];dp[i][0]=dp[i-1][0];
		r[i]=r[i-1];dp[i][1]=dp[i-1][1];
	}
	else
	{
		dp[i][0]=dp[i][1]=inf;
		chmi(dp[i][0],dp[i-1][0]+abs(r[i]-l[i-1])+r[i]-l[i]);
		chmi(dp[i][0],dp[i-1][1]+abs(r[i]-r[i-1])+r[i]-l[i]);
		chmi(dp[i][1],dp[i-1][0]+abs(l[i]-l[i-1])+r[i]-l[i]);
		chmi(dp[i][1],dp[i-1][1]+abs(l[i]-r[i-1])+r[i]-l[i]);
	}
}

inline void print()
{
	ll ans=min(dp[n][0]+abs(l[n]),dp[n][1]+abs(r[n]));
	printf("%lld",ans);
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	for(cas=1;cas<=t;cas++)
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}


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

int main(){
    long n, a[100000], i; cin >> n;
    long double dn = n, x2 = 2;
    for(i = 0; i < n; i++) cin >> a[i];

    if(n == 1) cout << fixed << setprecision(15)
                    << a[0] / x2 << endl;
    else if(n == 2) cout << fixed << setprecision(15)
                         << max(a[0], a[1]) / x2 << endl;
    else{
        sort(a, a + n);
        long hsum = 0; x2 = a[int(n / 2)] / x2;
        for(i = n / 2; i < n; i++) hsum += a[i];

        if(n % 2 == 0){
            cout << fixed << setprecision(15)
                 << hsum / dn << endl;
        }
        else{
            cout << fixed << setprecision(15)
                 << x2 + (hsum - int((n + 1)/ 2) * a[int(n / 2)]) / dn << endl;
        }
    }
    return 0;
}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

#define mp make_pair

int MOD =  1e9 + 7;

int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=MOD) s-=MOD;
    return s;
}

int sub(int a, int b) {
    int s = (a+MOD-b);
    if (s>=MOD) s-=MOD;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, MOD-2);
}

mt19937 rnd(time(0));

/*
const int LIM = 1000;

vector<int> facs(LIM), invfacs(LIM);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<LIM; i++) facs[i] = mul(facs[i-1], i);
    invfacs[LIM-1] = inv(facs[LIM-1]);
    for (int i = LIM-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

/*struct DSU
{
    vector<int> sz;
    vector<int> parent;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);

        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n; cin>>n;
    vector<int> a(n); for (int i = 0; i<n; i++) cin>>a[i];

    sort(a.begin(), a.end());

    ld ans = 1e18;

    ld cur = 0;
    ld tmp = 0; for (auto it: a) tmp+=it;

    ans = min(ans, tmp);

    for (int i = 0; i<n; i++)
    {
        ld cur1 = (ld)a[i]/(ld)(2);
        tmp+=(cur1-cur)*n;
        tmp-=2*(cur1-cur)*(n-i);
        cur = cur1;
        ans = min(ans, tmp);
    }

    cout<<setprecision(10)<<fixed<<ans/(ld)(n);
}


#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;

struct eq{
    long double a, b; // a*f0 + b
    eq(): a(0), b(0){}
    eq(long double a, long double b): a(a), b(b){}
    eq operator+(const eq &oth){
        return eq(a + oth.a, b + oth.b);
    }
    eq operator-(const eq &oth){
        return eq(a - oth.a, b - oth.b);
    }
    eq operator*(long double f){
        return eq(a*f, b*f);
    }
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, m, k;
    cin>>n>>m>>k;
    vector<int> a(k);
    for(int &x:a) cin>>x;
    vector<eq> dp(n+m+1);
    vector<eq> suf(n+m+1);

    for(int i = n-1; i>=0; i--){
        suf[i] = suf[i+1];
        if(binary_search(a.begin(), a.end(), i)){
            dp[i] = {1, 0};
        } else {
            dp[i] = (suf[i+1] - suf[i+m+1]) * (1.0/m);
            dp[i].b += 1.0;
        }
        suf[i]  = suf[i] + dp[i];
    }
    if(abs(1.0 - dp[0].a) < 1e-6)
        cout<<"-1\n";
    else
        cout<<fixed<<setprecision(4)<<dp[0].b/(1.0 - dp[0].a)<<"\n";

    return 0;
}

#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

struct RangeSum {
  using T = double;
  T operator()(const T &a, const T &b) { return a + b; }
  static constexpr T id() { return T(0); };
};

template <typename M>
struct SegmentTree {
  using Val = typename M::T;
  M calc;
  vector<Val> data;
  int n;
  explicit SegmentTree(int size) {
    n = 1;
    while (n < size) n <<= 1;
    data = vector<Val>(n << 1, calc.id());
  }
  explicit SegmentTree(vector<Val> &v) {
    n = 1;
    while (n < v.size()) n <<= 1;
    data = vector<Val>(n << 1);
    copy(v.begin(), v.end(), data.begin() + n);
    for (int i = n + (int)v.size(); i < 2 * n; i++) data[i] = calc.id();
    for (int i = n - 1; i > 0; --i) {
      data[i] = calc(data[i * 2], data[i * 2 + 1]);
    }
  }
  void update(int i, Val v) {
    int k = i + n;
    data[k] = v;
    for (k >>= 1; k >= 1; k >>= 1) data[k] = calc(data[k * 2], data[k * 2 + 1]);
  }
  Val query(int l, int r) {  //get[a,b)
    Val resl = calc.id(), resr = calc.id();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = calc(resl, data[l++]);
      if (r & 1) resr = calc(data[r - 1], resr);
    }
    return calc(resl, resr);
  }
};

class Solver2 {
 public:
  int n, m;
  vector<int> is_return;
  SegmentTree<RangeSum> a_0, a_x;
  Solver2(LL n, LL m) : n(n), m(m), is_return(n + 1), a_0(n + 1), a_x(n + 1){};

  void solve() {
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
      int tmp;
      cin >> tmp;
      is_return[tmp] = 1;
    }
    for (int i = 0, j = 0; i <= n; ++i) {
      if (is_return[i]) {
        j++;
        if (j == m) {
          cout << -1 << endl;
          return;
        }
      } else {
        j = 0;
      }
    }
    a_0.update(n, 0);
    a_x.update(n, 0);
    for (int i = n - 1; i > 0; --i) {
      if (is_return[i]) {
        a_0.update(i, 0);
        a_x.update(i, 1);
      } else {
        double sum_0 = a_0.query(i + 1, min(i + m, n) + 1);
        double sum_x = a_x.query(i + 1, min(i + m, n) + 1);
        a_0.update(i, sum_0 / m + 1.0);
        a_x.update(i, sum_x / m);
        if (i > 99900) DBG(i, m - (n - i), sum_0 / m + 1.0, sum_x / m)
      }
    }
    double sum_0 = a_0.query(1, min(m, n) + 1);
    double sum_x = a_x.query(1, min(m, n) + 1);
    DBG(sum_0 / m + 1.0, sum_x / m)
    double ans = (sum_0 / m + 1.0) / (1.0 - sum_x / m);
    cout << ans << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vll = vector<long long>;
using vb = vector<bool>;
using vd = vector<double>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvc = vector<vector<char>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using graph = vector<vector<pair<T, int>>>;// pair of weight and vertex
void my_answer(){

   string s;
   cin >> s;

   deque<char> t;

   int turn = 1;
   for(const auto c: s){
       if(c == 'R'){
           turn *= -1;
           continue;
       }

       if(turn == 1){
           if(!t.size()) t.emplace_back(c);
           else if(t.back() != c) t.emplace_back(c);
           else t.pop_back();
       }else{
           if(!t.size()) t.emplace_front(c);
           else if(t.front() != c) t.emplace_front(c);
           else t.pop_front();
       }
   }

   if(turn == 1){
       for(auto itr = t.begin(); itr != t.end(); ++itr){
           cout << *itr;
       }
   }else{
       for(auto itr = t.rbegin(); itr != t.rend(); ++itr){
           cout << *itr;
       }
   }
   cout << endl;

}
void best_answer(){

}
int main(){

    my_answer();
    // best_answer();
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <stack>
#include <cstring>
#include <set>
#include <utility>
#include <iostream>
#include <iomanip>
#include <list>
#include <queue>
#include <algorithm>
#include <cmath>
//#include <boost/multiprecision/cpp_int.hpp>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <numeric>
#include <complex>
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SUM(v) accumulate(ALL(v),0ll)
using ll = long long;
const ll INF=100;
const ll eps=1;
const double pi=3.14159265359;
const ll mod=1000000+7;
using namespace std;
int main()
{
  string s;
  cin>>s;
  int len=s.size();
  string t;
  bool ok=true;
  for(int i=0;i<len;i++)
  {
    if(s[i]=='R')
    {
   //   reverse(t.begin(),t.end());
      if(ok==true)ok=false;
      else ok=true;
    }
    else
    {
      if(ok==true)
        {
          t+=s[i];
          if(t.size()>=2)
          {
            if(t[t.size()-2]==t[t.size()-1])t.erase(t.size()-2,2);
          }

        }
      else
      {
          t=s[i]+t;
          if(t.size()>=1)
          {
            if(t[1]==t[0])t.erase(0,2);
          }
      }
    }
  }
  if(ok==false)reverse(t.begin(),t.end());
  cout<<t<<endl;
  return 0;
}


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

char getch()
{
	static char buf[1 << 14], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 14, stdin), p1 == p2) ? EOF : *p1++;
}

void read(int &x)
{
	x = 0;
	char c = getch();
	while(c < '0' || c > '9') c = getch();
	while(c >= '0' && c <= '9')
	{
		x = x * 10 + (c - '0');
		c = getch();
	}
}

int n, m, cnt;
int head[100001], vis[100001];
struct node
{
	int v, w, next;
}e[500003];

void add(int u, int v, int w)
{
	e[++cnt].v = v;
	e[cnt].w = w;
	e[cnt].next = head[u];
	head[u] = cnt;
}

void dfs(int u)
{
	for(int i = head[u]; i; i = e[i].next)
	{
		int v = e[i].v, w = e[i].w;
		if(vis[v]) continue;
		if(vis[u] == w) vis[v] = w % n + 1;
		else vis[v] = w;
		dfs(v);
	}
}

int main()
{
	read(n); read(m);
	int x, y, z;
	for(int i = 1; i <= m; ++i)
	{
		read(x); read(y); read(z);
		add(x, y, z); add(y, x, z);
	}
	vis[1] = 1;	dfs(1);
	int flag = 0;
	for(int i = 1; i <= n; ++i)
		if(!vis[i])
		{
			flag = 1;
			break;
		}
	if(flag) cout << "No" << endl;
	else
	{
		for(int i = 1; i <= n; ++i)
			printf("%d\n", vis[i]);
	}
	return 0;
}

#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	char s,t; cin >> s >> t;
	if(s == 'Y'){
		if(t == 'a'){
			cout << 'A' << endl;
		}else if(t == 'b'){
			cout << 'B' << endl;
		}else{
			cout << 'C' << endl;
		}
	}else{
		cout << t << endl;
	}
}


/*
    author: blue_matrix
*/
#include <bits/stdc++.h>
using namespace std;

#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); }
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long a,b,c;
    cin>>a>>b>>c;
    if(pow(a,2) + pow(b,2)<pow(c,2)) cout<< "Yes";
    else cout<< "No";

    return 0;
}

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

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;
    cout << ((a * a + b * b < c * c) ? "Yes" : "No")
         << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(vector<bool>::reference b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(ll x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
	friend string to_string(const Mint& b) { return to_string(b.val); }
};
vector<Mint> fac(1, 1), invfac(1, 1);
Mint binom(int n, int k) {
	if (k < 0 || k > n) return 0;
	while (fac.size() <= n) {
		fac.push_back(fac.back() * fac.size());
		invfac.push_back(1 / fac.back());
	}
	return fac[n] * invfac[k] * invfac[n - k];
}
vector<int> pfac; // pfac[i] = largest prime factor of i (pfac[i <= 1] = 0)
void genPrimes(int n) {
	pfac = vector<int>(n + 1);
	for (int i = 2; i <= n; ++i) pfac[i] = i;
	for (int i = 2; i <= n; ++i)
		if (pfac[i] == i)
			for (int j = i + i; j <= n; j += i)
				pfac[j] = i;
}
/* Prime factors (with precomputing). */
vector<pair<int, int>> factorize(int x) {
	vector<pair<int, int>> factors;
	while (x > 1) {
		int p = pfac[x];
		int cnt = 0;
		while (pfac[x] == p) {
			++cnt;
			x /= p;
		}
		factors.emplace_back(p, cnt);
	}
	return factors;
}
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	binom(n + 20, 0);
	genPrimes(m);
	Mint ans = 0;
	for (int i = 1; i <= m; ++i) {
		auto ps = factorize(i);
		Mint prod = 1;
		for (auto& p : ps) {
			prod *= binom(n - 1 + p.second, p.second);
		}
		ans += prod;
	}
	printf("%d\n", ans.val);
}

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <random>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>

//#include <atcoder/all>

#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[8]={-1,0,1,0,1,1,-1,-1},dy[8]={0,1,0,-1,1,-1,1,-1};

//using namespace atcoder;

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=1000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n,m;

int main(){
	Init();
	cin>>n>>m;
	ll res=1;
	for(int i=2;i<=m;i++){
		vi a;
		int x=i;
		for(int j=2;j*j<=x;j++) if(x%j==0){
			a.push_back(j);
			while(x%j==0) x/=j;
		}
		if(x>1) a.push_back(x);
		ll tmp=1;
		for(auto j:a){
			x=i;
			int t=0;
			while(x%j==0) x/=j,t++;
			(tmp*=nCk(n+t-1,n-1))%=mod;
		}
		(res+=tmp)%=mod;
	}
	cout<<res<<endl;
}


/**
*    author:  tomo0608
*    created: 18.02.2021 21:47:19
**/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

#define all(x) x.begin(),x.end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;}
template<class T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
#define pb push_back
#define eb emplace_back
#define elif else if
#define mp make_pair
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template<typename T> T gcd(T x, T y){if(x%y == 0)return y;return gcd(y, x%y);}
template<typename T> T gcd(vector<T> a){T res = a[0];for(auto &x: a)res = gcd(res, x);return res;}
template <typename T>T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;}
#define endl '\n'
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

// Primality test
class Prime {
    public:
    const int N;
    vector<int> min_prime;
    vector<int> primes;
    Prime(int size): N(size), min_prime(N+1){
        rep(i,N+1)min_prime[i] = i;
        min_prime[0] = -1;
        min_prime[1] = -1;
        for(int i = 2;i<=N;i++){
            if(min_prime[i]!=i)continue;
            primes.push_back(i);
            int tmp = 2*i;
            while(tmp <= N){
                if(min_prime[tmp]==tmp)min_prime[tmp] = i;
                tmp += i;
            }
        }
    }
    bool check(int x){ return min_prime[x] == x;}
};

void solve(){
    ll n,x;cin >> n >> x;
    V<ll> a(n);cin >> a;
    map<pll, ll> memo;
    auto dp = [&](auto &&dp, ll now, ll X)->ll{
        if(now == n-1)return 1;
        if(memo.count({now, X}))return memo[{now, X}];
        ll nmax = a[now+1]/a[now];
        memo[{now, X}] = dp(dp, now+1, X/nmax) + (X%nmax != 0)*dp(dp, now+1, X/nmax + 1);
        return memo[{now, X}];
    };
    cout << dp(dp, 0, x) << endl;
    //cout << memo << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << setprecision(20);
    int codeforces = 1;
    //cin >> codeforces;
    while(codeforces--){
        solve();
    }
    return 0;
}

#include <algorithm>
#include <iostream>
#include <limits>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	int numDog = N * 2;

	unordered_map<char, vector<long long>> a;
	a['R'];
	a['B'];
	a['G'];
	for(int i = 0; i < numDog; i++) {
		long long aa;
		char c;
		cin >> aa >> c;
		a[c].push_back(aa);
	}

	// もしどの色も偶数なら0が最小
	bool allEven = true;
	char evenColor;
	for(auto &x : a) {
		if(x.second.size() % 2 == 1) {
			allEven = false;
		} else {
			evenColor = x.first;
		}
	}
	if(allEven) {
		cout << 0 << endl;
		return 0;
	}

	// そうでないなら、必ず偶数、奇数、奇数の組合せ
	// 奇数同士をペアにする場合と、偶数から2匹もらう場合がある

	for(auto &x : a) {
		sort(x.second.begin(), x.second.end());
	}

	vector<vector<long long>*> odd;
	vector<long long> *even = nullptr;
	for(auto &x : a) {
		if(x.second.size() % 2 == 0) {
			even = &a[x.first];
		} else {
			odd.push_back(&a[x.first]);
		}
	}

	// 奇数同士
	int i = 0, j = 0;
	long long result = 1e17;
	while(true) {
		if(i >= odd[0]->size() || j >= odd[1]->size()) {
			break;
		}
		auto x = odd[0]->at(i);
		auto y = odd[1]->at(j);
		result = min(result, abs(x - y));
		if(x < y) {
			i++;
		} else {
			j++;
		}
	}

	// 偶数から借りる
	i = j = 0;
	int used;
	long long t1 = 1e17;
	while(true) {
		if(i >= odd[0]->size() || j >= even->size()) {
			break;
		}
		auto x = odd[0]->at(i);
		auto y = even->at(j);
		if(abs(x - y) < t1) {
			used = j;
		}
		t1 = min(t1, abs(x - y));
		if(x < y) {
			i++;
		} else {
			j++;
		}
	}
	i = j = 0;
	long long t2 = 1e17;
	while(true) {
		if(i >= odd[1]->size() || j >= even->size()) {
			break;
		}
		auto x = odd[1]->at(i);
		auto y = even->at(j);
		if(j != used) {
			t2 = min(t2, abs(x - y));
		}
		if(x < y) {
			i++;
		} else {
			j++;
		}
	}

	result = min(result, t1 + t2);

	cout << result << endl;

	return 0;
}