#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()

template<class T,class U> inline bool chmin(T &a, U b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T,class U> inline bool chmax(T &a, U b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr ll inf = 3e18;
#line 2 "main.cpp"

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll S,p;cin>>S>>p;
    for(ll i=1;i*i<=p;i++){
        if(p%i)continue;
        ll j=p/i;
        if(i+j==S){
            cout<<"Yes\n";return 0;
        }
    }
    cout<<"No\n";
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e3+5;
const int mod=1e9+7;
int a[N];
ll sum;

ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1){
            ans=ans*a%mod;
        }
        a=a*a%mod;
        b>>=1;
    }
    return ans%mod;
}

ll C(ll n,ll m){
    ll ans=1;
    n=min(n,m-n);
    for(int i=1;i<=n;i++){
        ll res=power(i,mod-2);
        ans=ans*res%mod;
    }
    for(ll i=m-n+1;i<=m;i++){
        ans=ans*i%mod;
    }
    return ans;
}

int main(){
    ll n,m;cin>>n>>m;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>m){
        cout<<"0"<<endl;
    }
    else cout<<C(sum+n,n+m)%mod<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);~i;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;

//Data
const int N=2e5;
int n,m; ll c[N+5];

//Main
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>m;
    R(i,n){
        int s,t,v;
        cin>>s>>t>>v;
        c[s]+=v,c[t]-=v;
    }
    R(i,N+3){
        if(c[i]>m) cout<<"No\n",exit(0);
        c[i+1]+=c[i];
    }
    cout<<"Yes\n";
    return 0;
}

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<iterator>
#include<string>
#include<sstream>
#include <unordered_map>
#include<cmath>
using namespace std;
#define ll long long
int __gcd(int a,int b){return b==0 ? a : __gcd(b,a%b);}
ll __gcd(ll a,ll b){return b==0 ? a : __gcd(b,a%b);}

const int maxn=5100;
int a[maxn],t[maxn],c[maxn],g[maxn];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int _=1;
    while(_--){
        int n; cin>>n;
        string s; cin>>s;

        if(s[0]=='A') a[0]++;
        else if(s[0]=='T') t[0]++;
        else if(s[0]=='C') c[0]++;
        else if(s[0]=='G') g[0]++;

        for(int i=1;i<n;++i){
            a[i]=a[i-1]; t[i]=t[i-1]; c[i]=c[i-1]; g[i]=g[i-1];
            if(s[i]=='A') a[i]++;
            else if(s[i]=='T') t[i]++;
            else if(s[i]=='C') c[i]++;
            else if(s[i]=='G') g[i]++;
        }
        int ans=0;
        //cout<<t]<<endl;

        for(int i=0;i<n;++i){
            for(int j=i+1;j<n;++j){
                int A=0,T=0,C=0,G=0;
                if(i>0){
                    A=a[j]-a[i-1]; T=t[j]-t[i-1]; C=c[j]-c[i-1]; G=g[j]-g[i-1];
                } else{
                    A=a[j]; T=t[j]; C=c[j]; G=g[j];
                }
               // if(i==1&&j==3) cout<<A<<" "<<T<<" "<<C<<" "<<G<<endl;
                if(A==T&&C==G) ++ans;
            }
        }
        cout<<ans<<"\n";
    }
}


// 2021-02-20 21:59:14
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;

// clang-format on
const ll inf = 1e18;
int n;
ll x, ans;
vector<ll> a;
ll solve(ll k) {
  vector<vector<ll> > dp(n + 1, vector<ll>(k, -1));
  dp[0][0] = 0;
  rep(i, n) {
    vector<vector<ll> > p = dp;
    repc(j, i) {
      rep(ki, k) {
        if (p[j][ki] >= 0) {
          int nk = (ki + a[i] % k) % k;
          chmax(dp[j + 1][nk], p[j][ki] + a[i]);
        }
      }
    }
  }
  ll res = inf;
  if (dp[k][x % k] > 0) {
    res = ((x - dp[k][x % k]) / k);
  }
  return res;
}
void answer() {
  cin >> n >> x;
  a.resize(n);
  {
    ll mx = 0;
    rep(i, n) {
      cin >> a[i];
      chmax(mx, a[i]);
    }
    ans = x - mx;
  }
  REPC(k, 2, n) chmin(ans, solve(k));
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long int
#define endl "\n"
#define MOD 1000000007
#define mod 1000000007
#define M 1000000007
#define pb push_back
#define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mx 1000005
#define fiint(a,b) memset(a,b,sizeof(a))
#define bitcount __builtin_popcount
#define fori(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<x<<endl;
#define cases(t) int t; cin>>t; while(t--)
#define inf1 INT_MAX
#define all(a) a.begin(),a.end()
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair

#define sz(x) (int)x.size()
#define PI    3.14159265359

int factorial[10000001]={0};

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

int powerFunction(int x,int y){
    int res = 1;
     int p = mod;
    x = x;
    while (y > 0){
        if (y & 1)
            res = (res*x)%p ;
        y = y>>1;
        x = (x*x)%p ;
    }
    return res;
}

void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}

int nCr(int n, int r)
{
    if(r < 0 || r > n){
        return 0;
    }
    int temp = factorial[n];
    temp *= (powerFunction(factorial[r], MOD-2)%MOD);
    temp %= MOD;
    temp *= (powerFunction(factorial[n-r], MOD-2)%MOD);
    temp %= MOD;
    return temp;
}

vec v(200);
int n,x;
int le ;
int dp[105][105][105];
int find(int i , int j , int k  )
{

    if(i == 0)
    {
        if(v[i] % le == k && j == 0 )
            return v[i];
        else if(k == 0 && j == -1  ) return (int)0;
        else return INT_MIN;
    }
    if(j == -1 )
    {
        if(k == 0 ) return 0;
        else return INT_MIN;
    }
   if(dp[i][j][k] != INT_MAX)
        return dp[i][j][k];
    int a = find(i - 1 , j , k);
    int re = v[i] % le;
    if(re <= k )
        re = k - re;
    else { re = le - re +  k  ;  }
    int b = INT_MIN;
    if(j >= 0)
    b = v[i] + find(i - 1 , j - 1 , re  );
    dp[i][j][k] = max(a , b);
  //  cout<<i<<" " << j <<" "<<k <<" "<< le + 1 <<" " << a <<" " << b <<endl;
    return max( a , b );
}

signed main()
{
    cin>>n>>x;
    for(int i  = 0 ; i < n ;i++) cin>>v[i];
    int ans  = x;

    for(int i = 0 ; i < n ;i++)
    {
        le = (i+1);
        for(int i = 0 ; i  < 105 ;i++)
        for(int  j = 0 ; j < 105 ;j++)
        for(int  k =  0 ; k  < 105 ;k++ )
        dp[i][j][k] =INT_MAX;

        int a =  find(n-1 , i ,  x % (i+1)  );
        if(a <= 0 ) continue;
     //   cout<<a<<endl;
       ans = min(ans , (x - a) / (i+1) );
    }
    cout<<ans<<endl;
}


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

#define forn(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define MAX(a,b,c) max(max(a,b),c)
#define SumInRange(a,b) ((b*(b+1))/2)-(((a-1)*(a))/2)
#define Different_Random srand(time(NULL))
#define Random(a,b) (rand()%((b+1)-a))+a
#define __delete(v,n) v.erase(remove(v.begin(),v.end(),n),v.end())

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define newline cout << "\n";

#define read(x)    freopen(#x, "r", stdin)
#define write(x)   freopen(#x, "w", stdout)

#define all(x)     x.begin(), x.end()
#define dbg(args...)    {string sss(#args);sss+=',';cerr<<"-->";debugger::call(all(sss), args);cerr<<"\n";}
#define dbgA(A, n)      {cerr<<"-->"<<#A<<"=(";forn(i, n)cerr<<A[i]<<" ";cerr<<")\n";}
#define dbgA2(A, n, m)  {cerr<<"-->"<<#A<<"=\n";forn(i, n){forn(j, m){cerr<<setw(4)<<A[i][j]<<" ";}cerr<<"\n";}cerr<<"\n";}

struct debugger
{
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest)
    {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cerr << b << " = " << a << " ";
        call(++it, ed, rest...);
    }
};

template<typename T>
T Max(T a)
{
    return a;
}

template<typename T, typename... Args>
T Max(T a, Args... args)
{
    return a > Max(args...)? a : Max(args...);
}

template<typename T>
T Min(T a)
{
    return a;
}

template<typename T, typename... Args>
T Min(T a, Args... args)
{
    return a < Min(args...)? a : Min(args...);
}

//int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
//int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//int knight_x[] = {2, 2, -2, -2, 1, 1, -1, -1};
//int knight_y[] = {1, -1, 1, -1, 2, -2, 2, -2};

/*
cout.precision(x);
cout << fixed;
*/

typedef long long int ll;
typedef unsigned long long int ull;
const double GOLD = (1.0 + sqrt(5.0))/2.0;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = 3.141592653589793;
const double E = 2.718281828459045;

ll expo(ll a, ll n)
{
    ll result = 1;
    while(n)
    {
        if(n%2) result*=a;
        a*=a;
        n/=2;
    }
    return result;
}

ll mod_expo(ll x,ll y,ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
const int MOD = 1e9+7;

int main()
{
    #ifdef TarekHasan
        read(input.txt);
    #endif // TarekHasan
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    string str; cin >> str;
    reverse(str.begin(),str.end());
    for(char &c : str)
    {
        if(c=='6')
            c='9';
        else if(c=='9')
            c='6';
    }
    cout << str << "\n";
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<functional>
#include<utility>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<pair<double, double> > a(n);
    for(auto& [x, y] : a){
        cin >> x >> y;
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            double katamuki = (a[j].second - a[i].second) / (a[j].first - a[i].first);

            if(-1 <= katamuki && katamuki <= 1){
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}


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

#define N 200100
#define MOD 1000000007 //998244353
#define ll long long
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define eb emplace_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>

int main() {
	ll ans;
	ll n, m, x, k, s, y;
	cin >> n >> m;
	s = 0;
	rep(i, n) {
		cin >> x;
		s = (s + x) % MOD;
	}
	ans = 1;
	x = m + n;
	rep(i, s + n) {
		ans = (ans*x) % MOD;
		x--;
	}
	x = 1;
	rep(i, s + n)x = (x*(i + 1)) % MOD;
	y = MOD - 2;
	k = 1;
	while (y > 0) {
		if (y % 2 == 1) {
			k = (k*x) % MOD;
		}
		x = (x*x) % MOD;
		y /= 2;
	}
	ans = (ans*k) % MOD;
	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   long long N;
   cin>>N;
   vector<int> v;
   int cnt[3]={0};
   int x=0;
   while(N){
    cnt[(N%10)%3]++;
    x++;
    N=N/10;
   }
   if(cnt[0] || (cnt[1] && cnt[2])){
       int ans=0;
     for(int i=0;i<=cnt[1];i++){
         for(int j=0;j<=cnt[2];j++){
             if((2*j+i)%3==0){
                 ans=max(j+i,ans);
             }
         }
     }
     cout<<cnt[1]+cnt[2]-ans<<"\n";
   }else{
       cout<<-1<<"\n";
   }

}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int mod = 1e9 + 7;

void addSelf(int &a, int b) {
	a = (a+b)%mod;
}

void mulSelf(int &a , int b) {
	a = (long long )a*b%mod;
}

int binpow(int a, int b) {
	int res  =1;
	while(b>0) {
		if(b&1) {
			mulSelf(res,a);
		}
		mulSelf(a,a);
		b>>=1;
	}
	return res;
}

const ll mxn = 100;
ll cache[mxn][2];
ll vis[mxn][2];
vector<ll> base(mxn,0);
vector<ll> lim(mxn,0);
ll n;

ll dp(ll i ,ll carry) {
	if(vis[i][carry])
		return cache[i][carry];

	vis[i][carry] = 1;

	if(i == n-1) {
		cache[i][carry] = 1;
		return cache[i][carry];
	}

	cache[i][carry] = 0;
	ll val = lim[i] + carry;

	if(val == 2) { // you will shift the carry further
		cache[i][carry] = dp(i+1,carry);
	} else {
		// i can shift the carry futher only if it is none zero
		cache[i][carry] = dp(i+1,0);

		if(base[i] + carry !=0) {
			cache[i][carry] += dp(i+1,1);
		}
	}

	return cache[i][carry];
}

void solve() {
	ll x;
	cin >> n >> x;
	ll a[n];
	for(ll i =0;i<n;i++)
		cin >> a[i];
	ll cpy = x;
	for(ll i = n-1;~i;--i) {
		if(cpy>=a[i]) {
			base[i] = cpy/a[i];
			cpy%=a[i];
			if(i!=n-1) {
				if(base[i]==(a[i+1]/a[i]) - 1)
					lim[i] = 1;
			}
		}
	}

	cout << dp(0,0) << endl;

}

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

	// ll t;cin >> t;while(t--)
		solve();
}

#include<bits/stdc++.h>
long long n,x;
long long ans[2],k[2],a,b,c,now;
int main()
{
	scanf("%lld%lld",&n,&x);
	scanf("%lld",&b);
	ans[0]=1;ans[1]=0;
	for(int i=1;i<n;++i)
	{
		scanf("%lld",&a);
		c=a/b;b=a;
		now=x%c;
		x/=c;
		k[0]=ans[0],k[1]=ans[1];
		if(now)k[1]+=ans[0];
		if(++now!=c)k[0]+=ans[1];
		ans[0]=k[0];ans[1]=k[1];
	}
	printf("%lld",ans[0]+ans[1]);
	return 0;
}


#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n ; cin>>n ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  ll ans= gcd(A[0],A[1]) ;
  rep(i,n-2){
    ans= gcd(ans,A[i+2]) ;
  }
  cout<<ans<<endl ;
    return 0 ;
}

#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int x=0;
    int y=0;
    int z=0;

    int n=0;
    int m=0;
    int i,j,k;
    int te=0;
    int A[100] ={0};
    int B[100] = {0};

    int AA[101][101];
    int BB[3][10];
    int CC[3][10];
    int DD[3][10];

    char op;
    char OP[100];
    long sum=0;
    double f1=0;
    double f2=0;

    cin >> x >>y >>z;
    //cin >> a;
    //cin >> a >> b;
    //cin >> a >> b >> c;
    //cin >> a>> b >> x >> y >> z;

    f1 = (double )y/x;
    b=(int)z*f1;
    f2 = (double)b/z;

    if(f2<f1){
        cout << b << endl;
        return 0;
    }
    if(f2 >= f1){
        for(i=b;i>=0;i--){
            f2 = (double)i/z;
            if(f2 < f1){
                break;
            }
        }
    }

    cout << i << endl;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}

int main(){
	int a = readint(), b = readint();
	int w = readint()*1000;
	int k = (w-1)/b+1; // b*k >= w
	if(a*k > w){
		puts("UNSATISFIABLE");
		return 0;
	}
	printf("%d ",k);
	k = w/a; // a*k <= w
	printf("%d\n",k);
	return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define watch(x) cout << (#x) << " is : " << (x) << newl

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi dirx = {0,0,1,-1};
vi diry = {1,-1,0,0};
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122) return char(x-32);
    if( 65 <= int(x) && int(x) <= 90) return x;
    return -1;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122) return x;
    if( 65 <= int(x) && int(x) <= 90) return char(x+32);
    return -1;
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57) return int(x-'0');
    if(97 <= int(x) && int(x) <= 122) return int(x-96);
    if(65 <= int(x) && int(x) <= 90) return int(x-64);
    return -1;
}
bool isect (int l1, int r1, int l2, int r2){ return max(l1,l2) <= min(r1,r2); }
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1%MOD;
    else if(num2==1)return num1%MOD;
    else{
        ll temp = quickpow (num1,num2>>1LL,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2&1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
int a,b,w;
bool validate(){
    int take = w / a;
    int rem = w % a;
    int p = (rem / take) + !!(rem % take);
    if(a + p > b) return false;
    return true;
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> a >> b >> w; w *= 1000;
    if(!validate()) return cout << "UNSATISFIABLE\n", 0;

    int mx = w / a;
    int mn = w / b + !!(w % b);

    cout << mn << ' ' << mx << newl;

    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cassert>
#include <climits>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define abs(x) ((x) > 0 ? (x) : -(x))
#define FOREACH(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
typedef long long LL;

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, init;
    cin>>n>>init;
    string s;
    cin>>s;
    for(int i=0; i<n; i++){
        if(s[i]=='o') init++;
        else init = max(init-1, 0);
    }
    cout<<init;
}


#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>
#include<stdio.h>
#include<queue>
#include<list>
#include<stack>
#include<random>
#include<chrono>
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
#define COL 31
#define ROW 31
#define ll long long int
#define ull unsigned long long int
#define mp make_pair
#define pb push_back
#define mem memset
#define inf 1e18
#define mod 1000000007
#define ff first
#define ss second
#define ipair pair<int,int>
int main()
{
	ull l,i,j,k;
	cin>>l;
	ull dp[l+1][13];
	for(i=0;i<=l;i++)
		for(j=0;j<=12;j++)
			dp[i][j]=0;
	for(i=0;i<=12;i++)
	{
		dp[0][i]=0;
		dp[1][i]=0;
	}
	dp[1][1]=1;
	dp[0][0]=1;
	for(i=1;i<=l;i++)
		dp[i][0]=0;
	for(i=2;i<=l;i++)
	{
		for(j=1;j<=12;j++)
		{
			ull sum=0;
			for(k=1;k<=i;k++)
				sum+=dp[i-k][j-1];
			dp[i][j]=sum;
		}
	}
	cout<<dp[l][12]<<'\n';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;

#define F first
#define S second
#define allv(v) v.begin(), v.end()
#define alla(a, N) a, a + N
#define np next_permutation

inline void fastIO() {
	cin.tie(nullptr) -> sync_with_stdio(false);
}

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );
inline void flush();

const ll MOD1 = 1000000007;
const ll MOD2 =  998244353;

const int arraysize = 205;
bool vis[arraysize][arraysize];
int dis[arraysize][arraysize];
vector<pii> adj[arraysize];
ll a[arraysize];
ll b[arraysize];
ll c[arraysize];
string s, t;
ll N, M, Q, K, H, W, R, C;
int u, v, d;

inline string YNEOS(bool b) {
	return b ? "YES" : "NO";
}

inline string YNeos(bool b) {
	return b ? "Yes" : "No";
}

// Template by https://usaco.guide/gold/PURS?lang=cpp
template<class T> struct SegTree { // comb(ID,b) = b
	const T ID = 0; int n; vector<T> seg;
	T comb(T a, T b) { return a ^ b; }
	void init(int _n) { n = _n; seg.assign(2*n,ID); }
	void pull(int p) { seg[p] = comb(seg[2*p],seg[2*p+1]); }
	void upd(int p, T val) { // set val at position p
		seg[p += n] = val; for (p >>= 1; p; p >>= 1) pull(p); }
	T query(int l, int r) { // min on interval [l, r]
		T ra = ID, rb = ID; // ----- blank space -----
		for (l += n, r += n+1; l < r; l >>= 1, r >>= 1) {
			if (l&1) ra = comb(ra,seg[l++]);
			if (r&1) rb = comb(seg[--r],rb);
		} return comb(ra,rb);
	}
};

/* n choose k [possibly mod m] */
ll choose(ll n, ll k) {
	ll P = 1;
	for (int i = 0; i < k; ++i) P *= n-i;
	for (int i = 1; i <= k; ++i) P /= i;
	return P;
}

void solve() {
	ll N = readInt(), ans = 1;
	for (ll i = 1; i <= 11; ++i)
		ans *= N - i, ans /= i;
	writeInt(ans, '\n');
}

int main() {

	// int T; cin >> T;
	// while (T--) solve();

	solve();

	flush();
}

/** Fast Input/Output (IO) */

/** Read */

static const int buf_size = 1 << 14;

inline int getChar() {
	static char buf[buf_size];
	static int len = 0, pos = 0;
	if (pos == len)
		pos = 0, len = fread(buf, 1, buf_size, stdin);
	if (pos == len)
		return -1;
	return buf[pos++];
}

inline int readChar() {
	int c = getChar();
	while (c <= 32)
		c = getChar();
	return c;
}

template <class T>
inline T readInt() {
	int s = 1, c = readChar();
	T x = 0;
	if (c == '-')
		s = -1, c = getChar();
	while ('0' <= c && c <= '9')
		x = x * 10 + c - '0', c = getChar();
	return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
	if (write_pos == buf_size)
		flush();
	write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end ) {
	if (x < 0) writeChar('-'), x = -x;

	char s[24];
	int n = 0;
	while (x || !n)
		s[n++] = '0' + x % 10, x /= 10;
	while (n--) writeChar(s[n]);
	if (end) writeChar(end);
}

inline void writeWord( const char *s ) {
	while (*s) writeChar(*s++);
}

inline void flush() {
	fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
}


#include<bits/stdc++.h>
//#include <atcoder/all>

#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
//using namespace atcoder;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;

template<typename T> bool chmin(T& a, const T& b) { if(a > b){ a = b; return 1;} return 0; }
template<typename T> bool chmax(T& a, const T& b) { if(a < b){ a = b; return 1;} return 0; }

const ll ZER = 0;
const ll MOD = 998244353;
const ll INF = 1e18;

//bit全探索
vector<ll>bitSearch(int bit,int n){
    vector<ll>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    // S.push_back(1e9);
    return S;
}

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n)cin >> x[i];
    vector<int> A{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
    int siz = sz(A);
    ll res = 1e18;
    for(int bit = 0; bit < (1 << siz); bit++){
        auto S = bitSearch(bit, siz);
        ll y = 1;
        for(auto s : S)y *= A[s];
        // cout << y << endl;
        bool f = true;
        rep(i, n){
            if(gcd(x[i], y) == 1)f = false;
        }
        if(f)chmin(res, y);
    }
    cout << res << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
double pi = acos(-1);
#define tezi        ios_base::sync_with_stdio(false);\
                    cin.tie(0);\
                    cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;i++)
#define FORR(i,b,a) for(int i=b;i>=a;i--)
#define fill(a,b)   memset(a,b,sizeof(a))
#define _time_      1.0 * clock() / CLOCKS_PER_SEC
#define fi          first
#define se          second
#define mp          make_pair
#define pb          push_back
#define all(a)      a.begin(),a.end()
#define rev(a)      reverse(all(a))
#define reva(a,n)   reverse(a,a+n)
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

ll powerm(ll a,ll b,ll m){
    if(b==0) return 1;
    if(b&1) return a*powerm(a*a%m,b/2,m)%m;
    return powerm(a*a%m,b/2,m);
}
ll power(ll a,ll b){
    if(b==0) return 1;
    if(b&1) return a*power(a*a,b/2);
    return power(a*a,b/2);
}
ll sqroot(ll number){
    ll x = sqrt(number);
    while(x*x<number)x++;
    while(x*x>number)x--;
    return x;
}
ll cbroot(ll number){
    ll x = cbrt(number);
    while(x*x*x<number)x++;
    while(x*x*x>number)x--;
    return x;
}

const int maxn=1e5+5;
//bool prime[maxn];

map<ll,ll> mm;
ll ans=1e18;

void recur(ll x,ll y,ll move){
	if(y<=x){
		ans = min(ans,abs(x-y)+move);
		return;
	}
	if(mm[y] && mm[y]<move)return;
	mm[y] = move;
	ans = min(ans,abs(x-y)+move);
	if(y&1){
		recur(x,y+1,move+1);
		recur(x,y-1,move+1);
	}else{
		recur(x,y/2,move+1);
	}
}

int main(){
    tezi
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //sieve
    //memset(prime,true,sizeof(prime));
    //for(ll p=2;p*p<maxn;p++)if(prime[p]==true)for(ll i=p*p;i<maxn;i+=p)prime[i]=false;

    ll x,y;
    cin >> x >> y;
    if(x>=y){
    	cout << x-y;
    	return 0;
    }
    recur(x,y,0);
    cout << ans;
    return 0;
}

/*
######                  ####### #     #   ###   #     #    #    ####### ####### ######
#     #  ######  #    # #     # ##   ##    #    ##    #   # #      #    #     # #     #
#     #  #       ##   # #     # # # # #    #    # #   #  #   #     #    #     # #     #
#     #  #####   # #  # #     # #  #  #    #    #  #  # #     #    #    #     # ######
#     #  #       #  # # #     # #     #    #    #   # # #######    #    #     # #   #
#     #  #       #   ## #     # #     #    #    #    ## #     #    #    #     # #    #
######   ######  #    # ####### #     #   ###   #     # #     #    #    ####### #     #
*/


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
	char c;
	int w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	int ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
int n;
int a[20];
int b[20];
int tot1;
int tot2;
int main(){
	n=read();
	tot1=1;
	tot2=1;
	a[1]=1;
	b[1]=1;
	int res=0;
	for(int i=1;i<=n;i++)
	{
		int vis=1;
		for(int j=1;j<=tot1;j++)if(a[j]==7) vis=0;
		for(int j=1;j<=tot2;j++)if(b[j]==7) vis=0;
		res+=vis;
		a[1]++;
		int now=1;
		while(a[now]==10)
		{
			a[now]=0;
			a[now+1]++;
			now++;
		}
		b[1]++;
		tot1=max(tot1,now);
		now=1;
		while(b[now]==8)
		{
			b[now]=0;
			b[now+1]++;
			now++;
		}
		tot2=max(tot2,now);
	}
	cout<<res<<'\n';
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

bool f(int x) {
    while(x) {
        int mod = x % 10;
        if(mod == 7) {
            return 1;
        }
        x /= 10;
    }
    return 0;
}

bool g(int x) {
    while(x) {
        int mod = x % 8;
        if(mod == 7) {
            return 1;
        }
        x /= 8;
    }
    return 0;
}

void solve() {
    //TODO:
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(f(i) || g(i)) {
            cnt++;
        }
    }
    cout << n - cnt;
}

int main() {

    solve();
    return 0;
}


#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

void Solve() {
	cin >> N;
	string s, t, u;
	cin >> s >> t >> u;
	cout << string(N, '0') + string(N, '1') + string(1, '0') << "\n";
}

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

	cin >> T;
	while (T--) {
		Solve();
	}
}

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;
using namespace std;

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;

int n, a[N];

void code() {
    cin >> n;
    set<pair<int, int>> se;
    for (int i = 0; i < n; i++) cin >> a[i], se.insert({a[i], i});

    sort(a, a + n);

    int mn = a[0];
    for (int i = n - 1; i >= 0; i--) {
        mn = __gcd(mn, a[i]);
    }

    cout << mn << "\n";
}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define IT iterator
#define V vector
#define TP template <class o>
#define TPP template <typename t1, typename t2>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b; i >= a; i--)
#define FOR(i, n) rep(i, 1, n)
#define debug(x) cerr << #x << ' ' << '=' << ' ' << x << endl
using namespace std;
typedef double db;
typedef unsigned ui;
typedef long long ll;
typedef long double ld;

// char buf[1 << 20],*p1=buf,*p2=buf;
TP void qr(o& x) {
    char c = gc;
    x = 0;
    int f = 1;
    while (!isdigit(c)) {
        if (c == '-')
            f = -1;
        c = gc;
    }
    while (isdigit(c))
        x = x * 10 + c - '0', c = gc;
    x *= f;
}
template <class o, class... O> void qr(o& x, O&... y) { qr(x), qr(y...); }
TP void qw(o x) {
    if (x < 0)
        putchar('-'), x = -x;
    if (x / 10)
        qw(x / 10);
    putchar(x % 10 + '0');
}
TP void pr1(o x) { qw(x), putchar(' '); }
template <class o, class... O> void pr1(o x, O... y) { pr1(x), pr1(y...); }
TP void pr2(o x) { qw(x), putchar(10); }
template <class o, class... O> void pr2(o x, O... y) { pr2(x), pr2(y...); }
TP bool cmax(o& x, o y) { return (x < y ? x = y, 1 : 0); }
TP bool cmin(o& x, o y) { return (x > y ? x = y, 1 : 0); }

const int mod = (int)1e9 + 7;
TPP void ad(t1& x, t2 y) { (x += y) >= mod && (x -= mod); }
TPP void dl(t1& x, t2 y) { (x -= y) < 0 && (x += mod); }

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll power(ll a, ll b = mod - 2, ll p = mod) {
    ll c = 1;
    while (b) {
        if (b & 1)
            c = c * a % p;
        b /= 2;
        a = a * a % p;
    }
    return c;
}
ll exgcd(ll a, ll b, ll& x, ll& y) {
    if (!a) {
        x = 0;
        y = 1;
        return b;
    }
    ll d = exgcd(b % a, a, y, x);
    x -= b / a * y;
    return d;
}
ll INV(ll n, ll p = mod) {
    ll x, y;
    exgcd(n, p, x, y);
    return (x % p + p) % p;
}

const int N = 110;
const ll INF = 1e15;
int n, m, k, val[N];

struct rec {
    int a[N][N];
    rec() { memset(a, 0, sizeof a); }
    rec operator*(rec b) const {
        rec c;
        FOR(i, n) FOR(j, n) FOR(k, n) ad(c.a[i][k], 1ll * a[i][j] * b.a[j][k] % mod);
        return c;
    }
} a, c;

void solve() {
    qr(n, m, k);
    FOR(i, n) a.a[i][i] = c.a[i][i] = 1, qr(val[i]);
    ll inv = power(2 * m);
    while (m--) {
        int x, y;
        qr(x, y);
        dl(a.a[x][x], inv);
        ad(a.a[x][y], inv);
        dl(a.a[y][y], inv);
        ad(a.a[y][x], inv);
    }
    while (k) {
        if (k & 1)
            c = c * a;
        k /= 2;
        a = a * a;
    }
    FOR(i, n) {
        ll ans = 0;
        FOR(j, n) ad(ans, 1ll * c.a[j][i] * val[j] % mod);
        pr2(ans);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int T = 1;
    // qr(T);
    while (T--)
        solve();
#ifndef ONLINE_JUDGE
    cerr << 1.0 * (clock() - start_time) / CLOCKS_PER_SEC << ' ' << 's' << endl;
#endif
    return 0;
}

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <unordered_set>
#include <fstream>
#include <random>

using namespace std;

const long long int MOD = 1e9 + 7;

vector <vector<long long int>> mul(vector <vector<long long int>> a, vector<vector<long long int>> b)
{
	int n = a.size();
	int m = a[0].size();
	int k = b[0].size();
	vector <vector<long long int>>c(n, vector<long long int>(k, 0));

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < k; j++)
		{
			for (int k = 0; k < m; k++)
			{
				c[i][j] += ((a[i][k] % MOD) * (b[k][j] % MOD) % MOD);
				c[i][j] %= MOD;
			}
		}
	}

	return c;
}

long long int mypow(long long int x, long long int n)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
		{
			res = ((res % MOD) * (x % MOD) % MOD);
			res %= MOD;
		}
		x = ((x % MOD) * (x % MOD) % MOD);
		x %= MOD;
		n /= 2;
	}
	return res;
}

int A[101];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K;
	cin >> N >> M >> K;
	vector <vector<long long int>> a(N, vector<long long int>(N, 0));
	vector <vector<long long int>> b(N, vector<long long int>(N, 0));
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	long long int val = mypow(2, MOD - 2);
	long long int val2 = mypow(M, MOD - 2);
	for (int i = 0; i < M; i++)
	{
		int X, Y;
		cin >> X >> Y;
		X -= 1;
		Y -= 1;
		vector <vector<long long int>> c(N, vector<long long int>(N, 0));
		for (int j = 0; j < N; j++)
		{
			c[j][j] = val2;
		}
		long long int temp = val;
		temp = ((temp % MOD) * (val2 % MOD) % MOD);
		temp %= MOD;
		c[X][X] = temp;
		c[X][Y] = temp;
		c[Y][X] = temp;
		c[Y][Y] = temp;
		for (int j = 0; j < N; j++)
		{
			for (int k = 0; k < N; k++)
			{
				a[j][k] = ((a[j][k] % MOD) + (c[j][k] % MOD) % MOD);
				a[j][k] %= MOD;
			}
		}
	}
	for (int i = 0; i < N; i++)
	{
		b[i][i] = 1;
	}
	while (K > 0)
	{
		if (K % 2 == 1)
		{
			b = mul(a, b);
		}
		a = mul(a, a);
		K /= 2;
	}

	for (int i = 0; i < N; i++)
	{
		long long int val = 0;
		for (int j = 0; j < N; j++)
		{
			long long int temp = ((b[i][j] % MOD) * (A[j] % MOD) % MOD);
			temp %= MOD;
			val = ((val % MOD) + (temp % MOD) % MOD);
			val %= MOD;
		}
		cout << val << '\n';
	}

	return 0;
}


#include<iostream>
#include<bits/stdc++.h>

using namespace std;
using ll=long long;

void test_case(){
    int n,k;
    cin>>n>>k;
    k=abs(k);
    int a=2+k,b=2;
    ll ans=0;
    while(a<=2*n){
        int A=min(n,a-1), B=a-A;
        int C=min(n,b-1), D=b-C;
        int cnt_a=1+(min(A-1, n-B));
        int cnt_b=1+min(C-1, n-D);
        ans+=((ll)cnt_a*cnt_b);
        a++;b++;
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    t=1;
    // cin>>t;
    while(t--){
        test_case();
    }

    return 0;
}

#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int64 solve(int X, int n) {
  int ll = 1, rr = min(n, X - 1);
  ll = max(ll, X - min(X - ll, n));
  return max(0, rr - ll + 1);
}

int main() {
  int n, m;
  cin >> n >> m;
  int64 ret = 0;
  for (int X = 2; X <= 2 * n; ++X) {
    int Y = m + X;
    ret += solve(X, n) * solve(Y, n);
  }
  cout << ret << endl;
  return 0;
}


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

#define asll unsigned long long
#define ULL unsigned long long
#define ll long long
#define LL long long
#define ld long double
#define imt long long
#define pii pair<long long,long long>
#define x first
#define fi first
#define y second
#define se second
#define psbk(x) push_back(x);
#define pb push_back
#define For(x,a,b) if(a!=b){icdc=(b-a)/abs(b-a))}else{icdc=1};for(long long x=(a);x!=(b+icdc);x+=icdc)
#define forp(x,a,b) if(b-a!=0){icdc=(b-a)/abs(b-a))}else{icdc=1};for(long long x=(a);x!=(b);x+=icdc)
#define FOR(x,n) for(long long x=0;x<(n);x++)
#define m_p make_pair
long long icdc;

#define kj <<" "<<
#define kjb <<" ";
#define dg <<","<<
#define ml <<'\n';
#define co cout<<
#define ter cout<<endl;
#define sibi cout<<"TES"<<endl;
#define tes(x) cout<<"TES"<<x<<endl;
#define kpr(a) cout<<"("<<a.x dg a.y <<")" ml
#define vvi vector< vector<long long> >

ULL M=1e9+7;
LL b,m,k,tc;
LL p,q,r,t;
LL a[100005];
string s;

vvi aku={{1,0,0},{0,1,0},{0,0,1}};
vvi op1=
{{0,1,0},
{-1,0,0},
{0,0,1}};
vvi op2={
{0,-1,0},
{1,0,0},
{0,0,1}};
vvi op3={
{-1,0,0},
{0,1,0},
{0,0,1}};
vvi op4={
{1,0,0},
{0,-1,0},
{0,0,1}};

vvi pm[200005];//prefix matrix
vvi hsl;

void show(vvi x,string s){
	co "Show" kj s ml
	FOR(i,x.size()){
		FOR(j,x[i].size()){
			co x[i][j] kjb
		}
		ter
	}
}

vvi kali(vvi a,vvi b){
	//sibi
	long long r1,c1,r2,c2;
	vvi ret;
	vector<long long> ret2;
	LL ret3;
	//show(a,"A dalem fungsi");
	//show(b,"B dalem fungsi");
	r1=a.size();
	c1=a[0].size();
	r2=b.size();
	c2=b[0].size();
	//co "rc" kj r1 kj c1 kj r2 kj c2 ml
	//tes(0);
	if(r2!=c1){
		cout<<"ERROR"<<endl;
		return ret;
	}
	//tes(1)
	for(long long i=0;i<r1;i++){
		//co "i=" kj i ml
		//tes(2)
		ret2.clear();
		for(long long j=0;j<c2;j++){//ngebug ternyata tadi i++
			//co "j=" kj j ml
			//tes(3)
			ret3=0;
			for(long long k=0;k<r2;k++){
				///co "k=" kj k ml
				//tes(4);
				ret3+=a[i][k]*b[k][j];
			}
			ret2.pb(ret3);
		}
		ret.pb(ret2);
	}
	/*
	FOR(i,ret.size()){
		FOR(j,ret[i].size()){
			co ret[i][j] kjb
		}ter
	}
	*/
	return ret;
}

pii titik[200005];

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	//srand(time(0));

	cin>>b;
	FOR(i,b){
		cin>>titik[i].x>>titik[i].y;
	}
	//sibi
	cin>>m;
	//sibi
	FOR(i,m){
		//sibi
		//co i ml
		cin>>p;
		//sibi
		//co "p=" kj p ml
		///sibi
		if(p<=2){
			//co "masukif" ml
			//sibi
			if(p==1){
				//sibi
				aku=kali(op1,aku);
			}
			else{
				aku=kali(op2,aku);
			}
		}
		else{
			//co "masukelse" ml
			cin>>q;
			//co "q=" kj q ml
			if(p==3){
				op3[0][2]=2*q;
				aku=kali(op3,aku);
				op3[0][2]=0;
			}
			else{
				op4[1][2]=2*q;
				aku=kali(op4,aku);
			}
		}
		//sibi
		pm[i]=aku;
		//co "pm[i]" ml
		//show(pm[i],"pm[i]");
	}
	cin>>k;
	//co "ka=" kj k ml
	FOR(i,k){
		cin>>p>>q;
		p--;
		q--;
		if(p<0){
			//co "HASIL" kjb
			co titik[q].x kj titik[q].y ml
			continue;
		}
		hsl={{titik[q].x},{titik[q].y},{1}};
		//co "tepat setelah operasi ke" kj p kj "pada titik ke " kj q kj "yaitu" kjb; kpr(titik[q]);
		hsl=kali(pm[p],hsl);
		//co "HASIL" kjb
		cout<<hsl[0][0] kj hsl[1][0] ml
	}

	/*
	operasi nomer 1 :
	0 1
	-1 0
	operasi nomer 2 :
	0 -1
	1 0
	operasi nomer 3 : cermin sumbu x=p
	x' = 2p-x
	y' = y
	operasi nomer 4 :

	*/

}
/*

*/

#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <list>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
void ex_gcd(ll a,ll b, ll& d,ll& x,ll& y){
  if(!b) {d=a;x=1;y=0;}
  else   {	ex_gcd(b,a%b,d,y,x);	y-=a/b*x;}
}
ll inv(ll a,ll n)  {
  ll d,x,y;	ex_gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}
ll gcd(ll x, ll y){
  if(y==0)return x;
  return gcd(y, x%y);
}
const int maxn = 200005;
const int mod = 998244353;

ll x[maxn], y[maxn];
ll a1[maxn], b1[maxn], a2[maxn], b2[maxn];
bool c1[maxn], c2[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>x[i]>>y[i];
  }
  int m;
  cin>>m;
  a1[0] = 1, b1[0] = 0, a2[0] = 1, b2[0] = 0;
  c1[0] = 0, c2[0] = 1;
  for(int i=1;i<=m;i++){
    string s;
    cin>>s;
    a1[i] = a1[i-1],b1[i] = b1[i-1], a2[i] = a2[i-1], b2[i] = b2[i-1];
    c1[i] = c1[i-1],c2[i] = c2[i-1];
    if(s[0]=='3'){
      ll tt;
      cin>>tt;
      a1[i] = -a1[i-1];
      b1[i] = 2*tt - b1[i-1];
    } else if(s[0]=='4'){
      ll tt;
      cin>>tt;
      a2[i] = -a2[i-1];
      b2[i] = 2*tt - b2[i-1];
    } else if(s[0]=='1'){
      swap(c1[i], c2[i]);
      swap(a1[i], a2[i]);
      swap(b1[i], b2[i]);
      a2[i] = -a2[i];
      b2[i] = -b2[i];
    } else {
      swap(c1[i], c2[i]);
      swap(a1[i], a2[i]);
      swap(b1[i], b2[i]);
      a1[i] = -a1[i];
      b1[i] = -b1[i];
    }
  }
  int Q;
  cin>>Q;
  while(Q--){
    int a,b;
    cin>>a>>b;
    ll tx=x[b], ty = y[b];
    if(c1[a]){
      swap(tx,ty);
    }
    ll rx = tx * a1[a] + b1[a];
    ll ry = ty * a2[a] + b2[a];
    cout<<rx<<" "<<ry<<endl;
  }
  return 0;
}


/*
    written by Pankaj Kumar.
    country:-INDIA
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll ;
typedef vector<ll> vl;
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
#define Endl "\n"
// loops
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
// Some print
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
// sort
#define all(V) (V).begin(),(V).end()
#define srt(V) sort(all(V))
#define srtGreat(V) sort(all(V),greater<ll>())
// some extra
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
#define sz(V) ll(V.size())
// template
template <typename T>
T mymax(T x,T y)
{
    return (x>y)?x:y;
}
// function
ll power(ll x,ll y,ll mod)
{
    ll res=1;
    // x=x%mod;
    while(y>0)
    {
        if(y%2==1)
        {
            res*=x;
            // res=res%mod;
        }
        y/=2; x*=x; // x=x%mod;
    }
    return res;
}
ll str_to_num(string s)
{
    return stoi(s);
}

string num_to_str(ll num)
{
    return to_string(num);
}
// datatype definination
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
class Point
{
    public:
        ll x;
        ll y;
        ll z;
        ll getsum()
        {
            return x+y+z;
        }
};
/* ascii value
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/
// to run ctrl+b

ll solve()
{
    ll n;
    cin>>n;
    vl v(n),v2(n);
    forin(v,n);
    forin(v2,n);
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        sum+=(v[i]*v2[i]);
    }
    if(sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

int main()
{
    speed;
    /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif */
    ll TestCase=1;
    // cin>>TestCase;
    while(TestCase--)
    {
        solve();
    }
}

/* stuff you should look before submission
* int overflow
* special test case (n=0||n=1||n=2)
* don't get stuck on one approach if you get wrong answer
*/

#include <bits/stdc++.h>

using namespace std;

#define double long double
#define int long long
const int mod = 1e9 + 7;
const int N = 1e5 + 50;

int a[N];
int n;

double getSum(double x) {
    double ret = 0;
    for (int i = 0; i < n; i++) {
        ret += x + (double) a[i] - min((double) a[i], (double) 2.0 * x);
    }

    return ret;
}

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

    cin >> n;

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

    double l = 0;
    double r = 1e9+1;

    int iter = 100;
    while (iter--) {
        double m1 = l + (r - l) / 3.0;
        double m2 = r - (r - l) / 3.0;
        double f1 = getSum(m1);
        double f2 = getSum(m2);
        if (f1 > f2) {
            l = m1;
        } else {
            r = m2;
        }
    }

    cout << fixed << setprecision(6) << getSum(l) / n << '\n';
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
template<class T> inline bool chmax(T& a, T& b) { if (a < b) { int tmp=a; a=b; b=tmp; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T& b) { if (a > b) { int tmp=a; a=b; b=tmp; return 1; } return 0; }
const ll mod=1000000000+7;

int main() {
    ll R, X, Y;
    cin >> R >> X >> Y;
    double d = sqrt(X * X + Y * Y);
    ll l = floor(d);
    if (floor(d) == ceil(d) && l % R == 0) {
        cout << l / R << "\n";
    } else if (d < R) {
        cout << 2 << "\n";
    } else {
        cout << l / R + 1 << "\n";
    }
    return 0;
}

// Problem: A - Tax Included Price
// Contest: AtCoder - AtCoder Regular Contest 118
// URL: https://atcoder.jp/contests/arc118/tasks/arc118_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
   int 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();
   return s*w;
}
const int p=998244353;
int qp(int x,int y)
{
	int res=1;
	for(int t=x; y; y>>=1,t=t*t%p) if(y&1) res=res*t%p;
	return res;
}
signed main()
{
    int n=read(),m=read();
	int ans=(m*100-1)/n+1;
	printf("%lld\n",(100+n)*ans/100-1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FastIO ios_base::sync_with_stdio(false),cin.tie(0)
#define f(n) for(int i=0;i<n;i++)
#define endl "\n"
const double PI = 3.141592653589793238460;
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

int arr[]={1,1,4,4,2,1,1,4,4,2};

ll pow(ll a,ll b,ll m)
{
    ll res=1;

    for(;b>0;b>>=1)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
    }

    return res;
}

void solve()
{
    int n=3;
    //cin>>n;

    ll A[n];

    f(n)cin>>A[i];

    for(int i=n-2;i>0;i--)
    {
        ll x=A[i]%10,y=A[i+1];

        A[i]=pow(A[i],A[i+1],arr[A[0]%10])+arr[A[0]%10];
    }

    A[0]=pow(A[0],A[1],10)%10;
    cout<<(A[0]%10);
}

int main()
{
    FastIO;

    int t=1;
	//cin>>t;

	for(int i=1;i<=t;i++)
    {
        solve();
        if(i!=t)cout<<endl;
    }
	return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <cassert>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll power(ll x, ll y, ll m)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % m;
        x = (x * x) % m;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    ll a, b, c;
    cin >> a >> b >> c;

    vector<ll> m;
    ll tmp = a % 10;
    m.push_back(tmp);

    for (int i = 0; i < 100; i++)
    {
        tmp *= a;
        tmp %= 10;

        if (tmp == a % 10)
        {
            break;
        }

        m.push_back(tmp);
    }

    cout << m[(power(b, c, m.size()) - 1 + m.size()) % m.size()] << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

vl p(200005);
vector <unordered_map<ll, ll>> pp(200005);
vl siz(200005, 1);

ll get(ll u) {
	return p[u] = (p[u] == u) ? u : get(p[u]);
}

void unions(ll a, ll b) {
	a = get(a);
	b = get(b);
	//cout << a << " " << b << "\n";
	if (a == b)
		return;
	if (siz[a] > siz[b])
		swap(a, b);
	for (auto i : pp[a]) {
		//cout << i.ff << " " << i.ss << "\n";
		pp[b][i.ff] += i.ss;
	}
	p[a] = b;
	siz[b] += siz[a];
}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	t = 1;
	//cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		ll q;
		cin >> q;
		for (ll i = 1; i <= n; i++)
			p[i] = i;

		for (ll i = 1; i <= n; i++) {
			ll d;
			cin >> d;
			pp[i][d] = 1;
		}

		while (q--) {
			ll x, y, z;
			cin >> z;
			cin >> x >> y;
			if (z == 1) {
				unions(x, y);
			}
			else {
				x = get(x);
				cout << pp[x][y] << "\n";
			}
		}
	}
}

#include<bits/stdc++.h>
using namespace std;
namespace Sakurajima_Mai{
    #define ms(a) memset(a,0,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=1e9;//infi较大，注意涉及inf相加时爆int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Sakurajima_Mai;
namespace Fast_Read{
    inline int qi(){
        int f=0,fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline ll ql(){
        ll f=0;int fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline db qd(){
        char c=getchar();int flag=1;double ans=0;
        while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
        if(c=='-') flag=-1,c=getchar();
        while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
        if(c=='.'){c=getchar();for(int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
        return ans*flag;
    }
}
namespace Read{
    #define si(a) scanf("%d",&a)
    #define sl(a) scanf("%lld",&a)
    #define sd(a) scanf("%lf",&a)
    #define ss(a) scanf("%s",a)
    #define rai(x,a,b) repi(i,a,b) x[i]=qi()
    #define ral(x,a,b) repi(i,a,b) x[i]=ql()
}
namespace Out{
    #define pi(x) printf("%d",x)
    #define pl(x) printf("%lld",x)
    #define ps(x) printf("%s",x)
    #define pc(x) printf("%c",x)
    #define pe() puts("")
}
namespace DeBug{
    #define MARK false
    #define DB if(MARK)
    #define pr(x) cout<<#x<<": "<<x<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Fast_Read;
using namespace Read;
using namespace Out;
using namespace DeBug;
const int MAX_N=1e2+5;
char g[MAX_N][MAX_N];
int main()
{
    int h=qi(),w=qi(),x=qi(),y=qi();
    repi(i,1,h) ss(g[i]+1);
    int cnt=0;
    if(g[x][y]!='#') cnt++;
    repi(i,x+1,h){
        if(g[i][y]=='#') break;
        cnt++;
    }
    repd(i,x-1,1){
        if(g[i][y]=='#') break;
        cnt++;
    }
    repi(i,y+1,w){
        if(g[x][i]=='#') break;
        cnt++;
    }
    repd(i,y-1,1){
        if(g[x][i]=='#') break;
        cnt++;
    }
    pi(cnt),pe();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '{' << p.first << ", " << p.second << '}'; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const map<A, B> &mp) { os << '['; string sep; for (const auto &x : mp) os << sep << x, sep = ", "; return os << ']'; }
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "] =", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int long long
#define mod 1000000007
#define inf 1e18
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)(x).size()
#define sb(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()

int sumPairs(vector<int> &arr, int n)
{
    int sum = 0;
    for (int i = n - 1; i >= 0; i--)
        sum += i * arr[i] - (n - 1 - i) * arr[i];
    return sum;
}

void solve()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //cout << fixed << setprecision(10);
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(all(v));
    cout << sumPairs(v, n) << endl;
}

int32_t main()
{
    solve();
    return 0;
}

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")
//#pragma GCC optimize("branch-target-load-optimize")
//#pragma GCC optimize("branch-target-load-optimize2")
//#pragma GCC optimize("btr-bb-exclusive")

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;

void solve();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

#define int long long

const int N = 2e5 + 100, K = 201, INF = 1e18, MOD = 1e9 + 7;

int n, a[N], pref[N], suf[N];

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        pref[i + 1] = pref[i] + a[i];
    }
    for (int i = n - 1; i > 0; i--) {
        suf[i - 1] = suf[i] + a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (i * a[i]) - pref[i] + suf[i] - ((n - i - 1) * a[i]);
    }
    cout << ans / 2;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrep1(i, n) for (int i = n; i >= 1; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define eb emplace_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef long long int ll;
typedef pair<int, int> P;
// typedef modint1000000007 mint;

void speedUpIO() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
}

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/*--------------------------------------------------*/
const int INF = 1e9;
const ll LINF = 1e18;

void solve() {
    int n;
    cin >> n;
    rep(i, 3) {
        string s;
        cin >> s;
    }
    string ans = string(n, '0');
    ans += string(n, '1');
    ans += "0";
    cout << ans << "\n";
}

int main() {
    speedUpIO();
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
        // cout << solve() << "\n";
        // cout << (solve() ? "Yes" : "No") << "\n";
        // cout << fixed << setprecision(15) << solve() << "\n";
    }
    return 0;
}

#include <bits/stdc++.h>
#include"map"
#include"string"
#include"cmath"
#include"cstdio"
#include"iostream"
#include"cstring"
#include"algorithm"
#include"vector"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#ifdef local
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)

const int inf = 2e9 + 7;
double eps = 1e-6;
const int mod = 998244353;
const int N = 2e5 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
/*int len, C[N], clen;
int id(int v) { return lower_bound(C + 1, C + len, v) - C; }
void initC() { sort(C + 1, C + clen+1); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

struct Edge {
    int v, w1, w2;
};
vector<Edge> g[N];
int cnt[N];
bool ok2 = 1;
bool get(int s, int x) {
    return (s >> x) & 1;
}
void dfs(int u, int f) {
    for (Edge e : g[u])if (e.v != f) {
        dfs(e.v, u);
        vector<bool> need(2);
        f(i, 0, 29) {
           // if(get(e.w1,i)^get(e.w2,i))
        }
    }
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
#endif
    int _; cin >> _;
    while (_--) {
        int n; cin >> n;
        vector<string> s(3);
        for (auto& i : s)cin >> i;
        f(i, 1, n)cout << 0; f(i, 1, n)cout << 1;
        cout << 0 << "\n";
    }
    return 0;
    int n; cin >> n;
    bool ok = 1;
    f(i, 1, n - 1) {
        int u, v, w1, w2; cin >> u >> v >> w1 >> w2;
        g[u].push_back({ v,w1,w2 });
        g[v].push_back({ u,w1,w2 });
        if (w1 != w2)ok = 0;
    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ti3 tuple<int,int,int>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int main(){
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll rd = abs(r2 - r1), cd = abs(c2 - c1);
    if(rd == 0 && cd == 0){
        cout << 0 << endl;
    }else if(abs(rd) + abs(cd) <= 3 || abs(rd) == abs(cd)){
        cout << 1 << endl;
    }else if(abs(rd) % 2 == abs(cd) % 2 || abs(rd - cd) <= 3 || rd + cd <= 6){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
long long int n,goal,t[9][9],ans;
bool used[9];
void dfs(int sum,int it,int step){
	if(step==n-1){
		if(sum+t[it][0]==goal){
			++ans;
		}
		return;
	}
	for(int i=1;i<n;++i){
		if(!used[i]&&t[it][i]+sum<=goal){
			used[i]=1;
			dfs(t[it][i]+sum,i,step+1);
			used[i]=0;
		}
	}
}
int main(){
	while(cin >> n >> goal){
		for(int i=0;i<n;++i){
			used[i]=0;
			for(int j=0;j<n;++j)
				cin >> t[i][j];
		}
		ans=0;
		used[0]=1;
		dfs(0,0,0);
		cout << ans << "\n";
	}
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<vector<int>> list(N, vector<int>(N));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cin >> list[i][j];
    vector<int> route(N - 1);
    for (int i = 0; i < N - 1; i++)
        route[i] = i + 1;

    int ans = 0;
    do
    {
        int tmp = 0;
        tmp += list[0][route[0]] + list[0][route[N - 2]];
        for (int i = 0; i < N - 2; i++)
            tmp += list[route[i]][route[i + 1]];
        if (tmp == K)
            ans++;
    } while (next_permutation(route.begin(), route.end()));
    cout << ans;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
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;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
// using namespace atcoder;

struct edge{
	int to,cost;
	edge(int a,int b):to(a),cost(b){}
};

vector<int> dijkstra(vector<vector<edge>> &g,int s){
	constexpr int inf=5e5;
	vector<int>dis(g.size(),inf);
	dis[s]=0;
	using P=pair<int,int>;
	priority_queue<P,vector<P>,greater<P>>pq;
	pq.emplace(0,s);
	while(!pq.empty()){
		auto p=pq.top();
		pq.pop();
		int d=p.first;
		int v=p.second;
		if(d>dis[v])continue;
		for(auto x:g[v]){
			if(chmin(dis[x.to],dis[v]+x.cost)){
				pq.emplace(dis[x.to],x.to);
			}
		}
	}

	return dis;
}

void solve()
{
	int n,m;
	cin>>n>>m;
	vector<vector<edge>>g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].eb(b,1);
		g[b].eb(a,1);
	}
	int k;
	cin>>k;
	vector<int>c(k);
	rep(i,k)cin>>c[i],c[i]--;
	vector<vector<int>>dis(k);
	rep(i,k){
		dis[i]=dijkstra(g,c[i]);
	}

	constexpr int inf=5e5;
	vector<vector<int>>dp((1<<k)+5,vector<int>(k,inf));
	rep(i,k)dp[1<<i][i]=1;

	rep(bit,1<<k){
		rep(i,k){
			if(dp[bit][i]==inf)continue;
			rep(j,k){
				if(bit&(1<<j))continue;

				chmin(dp[bit|1<<j][j],dp[bit][i]+dis[i][c[j]]);
			}
		}
	}

	int ans=inf;
	rep(i,k){
		chmin(ans,dp[(1<<k)-1][i]);
	}
	if(ans==inf)cout<<-1;
	else cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<stack>
using namespace std;
vector<int> g[100000];
int flag[100000];
int dis[17][100000];
int D[17][17];
int cost[17][131072];
int bin[18];
int DP(int v, int s);
int n, m, k;
int main() {
	/*
	int bin[17];
	bin[0] = 1;
	int i, j;
	for (i = 1; i <= 16; i++)bin[i] = bin[i - 1] * 2;

	int n, m, k;
	cin >> n >> m;
	int a[101], b[101], c[16], d[16];
	for (i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}
	cin >> k;
	for (i = 0; i < k; i++) {
		cin >> c[i] >> d[i];
	}
	int sara[101], MAX = 0, counter;
	for (i = 0; i < bin[k]; i++) {
		//cout << i << endl;
		for (j = 0; j <= 100; j++)sara[j] = 0;
		counter = 0;
		for (j = 0; j < k; j++) {
			if (i + bin[j] != (i ^ bin[j])) {
				sara[c[j]] = 1;
			}
			else {
				sara[d[j]] = 1;
			}
		}
		for (j = 0; j < m; j++) {
			if (sara[a[j]] == 1 && sara[b[j]] == 1) {
				counter++;
			}
		}
		MAX = max(counter, MAX);
	}
	cout << MAX << endl;
	return 0;
	*/

	/*long long int n, i, x, y;
	cin >> n;
	long long int counter = 0;
	for (i = 1; i * i <= 2 * n; i++) {
		if ((2 * n) % i == 0) {
			x = i;
			y = 2 * n / i;
			if (x % 2 != y % 2) {
				counter++;

			}
		}

	}
	cout << counter * 2		<< endl;
	return 0;
	*/

	memset(cost, -1, sizeof(cost));
	cin >> n >> m;

	int a, b, i, j;
	bin[0] = 1;
	for (i = 1; i <= 17; i++)bin[i] = bin[i - 1] * 2;
	for (i = 0; i < m ; i++) {

		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cin >> k;
	int c[20];
	for (i = 0; i < k; i++) {
		cin >> c[i];
		c[i]--;
	}
	int p;
	queue<int> que;
	que.push(c[0]);
	flag[c[0]] = 1;
	while (que.size()) {
		p = que.front(); que.pop();
		for (i = 0;i < g[p].size(); i++) {
			if (flag[g[p][i]] == 0) {
				flag[g[p][i]] = 1;
				que.push(g[p][i]);
			}

		}
	}
	for (i = 0; i < k; i++) {
		if (flag[c[i]] == 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (i = 0; i < k; i++) {
		dis[i][c[i]] = 0;
		que.push(c[i]);
		while (que.size()) {
			p = que.front(); que.pop();
			for (j = 0; j < g[p].size(); j++) {
				if (dis[i][g[p][j]] == 0 && g[p][j] != c[i]) {
					dis[i][g[p][j]] = dis[i][p] + 1;
					que.push(g[p][j]);
					//cout << dis[i][g[p][j]] << endl;
				}
			}
		}
	}
	for (i = 0; i < k; i++) {
		for (j = 0; j < k; j++) {
			D[i][j] = dis[i][c[j]];
		}
	}

	int MIN = 99999999;
	for (i = 0; i < k; i++) {
		//cout << i << endl;
		MIN = min(MIN, DP(i, bin[k] - 1 - bin[i]));

	}
	cout << MIN + 1 << endl;
	return 0;

}

int DP(int v, int s) {
	//cout << s << endl;
	if (cost[v][s] != -1) {
		return cost[v][s];
	}
	if (s == 0) {
		cost[v][s] = 0;
		return 0;
	}
	int ii, MIN = 99999999;
	for (ii = 0; ii < k; ii++) {
		if ((s ^ bin[ii]) != (s + bin[ii])) {
			//cout << s - bin[v] << endl;
			MIN = min(MIN, DP(ii, s - bin[ii]) + D[v][ii]);

		}
	}

	cost[v][s] = MIN;
	return MIN;

}


#include<bits/stdc++.h>
using namespace std ;
#define MOD 1e9 + 7
#define inf 1e18 + 1
#define int long long
#define LMAX LLONG_MAX
#define IMAX INT_MAX
#define LMIN LLONG_MIN
#define IMIN INT_MIN
#define sort_1(a) sort(a.begin(),a.end())
#define sort_2(a) sort(a.begin(),a.end(),greater<int>())
#define DEBUG_1(v,a) for(int i=0;i<a;i++) cout<<v[i]<<' ';
#define DEBUG_2(v,a) for(int i=a;i>=0;i--) cout<<v[i]<<' ';

void pranav()
{
	string n;
	int k;
	cin >> n >> k;
	int flg=0;
    int tmp = stoi(n) ;
	while(k--)
	{
		if(flg==1 || tmp%200==0)
		{
			tmp = tmp/200;
			n = to_string(tmp);
			if(tmp%200==0)
			 flg=1;
			else
			 flg=0;
		}
		else
		{
            tmp = tmp*1000 + 200;
			n.push_back('2');
			n.push_back('0');
			n.push_back('0');
			flg=1;
		}
	}
	cout << n << endl;
}

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

	int t=1;
	//cin >> t;

	while(t--)
	{
	   pranav();
	}
	return 0;
}

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define ull unsigned long long
ull n,m,k;
int a[75];
int main()
{
	scanf("%lld%lld",&n,&k);
	while(k)
	{
		if(n%200==0)n/=200,k--;
		else
		{
			if(k>=2)
			{
				n=n*5+1;
				k-=2;
			}
			else
			{
				n=n*1000+200;
				printf("%lld",n);
				return 0;
			}
		}
	}
	printf("%lld",n);
	return 0;
}


#include <cstdio>
using namespace std;

int main()
{
	int n;
	double ans = 0;

	scanf("%d", &n);
	for (int i = 1; i < n; i++)
		ans += double(n) / (n - i);

	printf("%.9lf\n", ans);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
int tt,f[100100],n,p=1e9+7;

void prepare(){
	f[0]=1;
	f[1]=1;
	f[2]=2;
	for(int i=3;i<=n;i++)f[i]=(f[i-1]+f[i-2])%p;
}
void solve(){
	cin>>n;
	prepare();
	int a[n],ans=0;
	for(int i=0;i<n;i++){cin>>a[i];}
	ans+=(a[0]*f[n])%p;
	for(int i=1;i<n;i++){
		ans=ans+((f[i]*f[n-i]-f[i-1]*f[n-i-1])%p+p)*a[i];
		ans%=p;
	}
	cout<<ans<<'\n';
}

signed main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //prepare();
    //cin>>tt;
    //while(tt--)
    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; ++i)

int debug = 0;

const int N = 5000;
int n, x, d, a[N];
set <int> ds, s;

main() {
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        int d = 1;
        while (d * d <= a[i]) {
            if (a[i] % d == 0) {
                ds.insert(d);
                ds.insert(a[i] / d);
            }
            ++d;
        }
    }
    sort(a, a + n);
    for (int d : ds) {
        int x = 0, f = 0;
        rep(i, 0, n) {
            if (a[i] % d == 0) {
                f = 1;
                x = __gcd(x, a[i]);
                if (x == d) break;
            }
        }
        if (x == d && f == 1 && x <= a[0]) s.insert(d);
    }
    cout << s.size() << '\n';
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
const int MOD=1e9+7;
template <typename T>
vector<T> divisor(T n){
  vector<T> res;
  for (T i(1);i*i<=n;i++){
    if (n%i==0){
      res.push_back(i);
      // if (i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

int main(){
  ll N;
  cin>>N;
  vector<ll> di = divisor(2*N);
  set<pair<ll,ll>> st;
  for(ll x:di){
    ll y = 2*N/x;
    ll b = (y-x+1);
    ll a = (y+x+1);
    if(a%2==0 && b%2==0) st.insert({a,b});
    // st.insert({a,b});
  }
  cout << st.size()*2 << endl;
  return 0;
}


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

#include<cstdio>

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

ll dph[2000], dphw[4000], *naname = dphw + 2000;
const int mod = 1e9 + 7;

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

	int H = 0, W = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') H = H * 10 + c - '0';
	while ((c = getchar_unlocked()) >= '0') W = W * 10 + c - '0';

	getchar_unlocked();
	dph[0] = 1;
	naname[0] = 1;
	ll w = 1;
	ll tmp = 1;
	rep1(i, W - 1) {
		tmp = w;
		if (getchar_unlocked() == '.') {
			dph[i] = w;
			naname[i] = w;
			w = w * 2 % mod;
		}
		else {
			dph[i] = 0;
			naname[i] = 0;
			w = 0;
		}
	}
	getchar_unlocked();

	rep1(i, H - 1) {
		if (getchar_unlocked() == '.') {
			tmp = dph[0];
			w = tmp;
			dph[0] = (tmp + dph[0]) % mod;
			naname[-i] = (tmp + naname[-i]) % mod;
		}
		else {
			w = 0;
			dph[0] = 0;
			naname[-i] = 0;
		}
		if (!(i & 7)) {
			rep1(j, W - 1) {
				if (getchar_unlocked() == '.') {
					tmp = w + dph[j] + naname[j - i];
					w += tmp - ll(double(w + tmp) / mod) * mod;
					dph[j] += tmp - ll(double(dph[j] + tmp) / mod) * mod;
					naname[j - i] += tmp - ll(double(tmp + naname[j - i]) / mod) * mod;
				}
				else {
					w = 0;
					dph[j] = 0;
					naname[j - i] = 0;
				}
			}
		}
		else {
			rep1(j, W - 1) {
				if (!(j & 7)) {
					if (getchar_unlocked() == '.') {
						tmp = w + dph[j] + naname[j - i];
						w += tmp - ll(double(w + tmp) / mod) * mod;
						dph[j] += tmp - ll(double(dph[j] + tmp) / mod) * mod;
						naname[j - i] += tmp - ll(double(tmp + naname[j - i]) / mod) * mod;
					}
					else {
						w = 0;
						dph[j] = 0;
						naname[j - i] = 0;
					}
				}
				else {
					if (getchar_unlocked() == '.') {
						tmp = w + dph[j] + naname[j - i];
						w = w + tmp;
						dph[j] = tmp + dph[j];
						naname[j - i] = tmp + naname[j - i];
					}
					else {
						w = 0;
						dph[j] = 0;
						naname[j - i] = 0;
					}
				}
			}
		}
		getchar_unlocked();
	}

	printf("%lld\n", tmp % mod);

	Would you please return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  vector<vector<mint>> dp(h, vector<mint>(w, 0));
  vector<vector<mint>> a(h + 1, vector<mint>(w + 1, 0)), b(h + 1, vector<mint>(w + 1, 0)), c(h + 1, vector<mint>(w + 1, 0));
  dp[0][0] = 1;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j - 1 >= 0 && s[i][j - 1] == '.') a[i][j] += dp[i][j - 1] + a[i][j - 1];
      if (i - 1 >= 0 && s[i - 1][j] == '.') b[i][j] += dp[i - 1][j] + b[i - 1][j];
      if (i - 1 >= 0 && j - 1 >= 0 && s[i - 1][j - 1] == '.') c[i][j] += dp[i - 1][j - 1] + c[i - 1][j - 1];
      dp[i][j] += a[i][j] + b[i][j] + c[i][j];
    }
  }
  cout << dp[h - 1][w - 1].x << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r)-1; i >= (int)(l); (i) -= 1)
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { a = (a > b ? a : b); }
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { a = (a < b ? a : b); }
template <typename T1, typename T2> ostream &operator<<(ostream &os,const pair<T1,T2> &p) { os<<p.first<<' '<<p.second; return os;}
template <typename T> ostream &operator<<(ostream &os,const vector<T> &v) { range(i,0,v.size()) {os<<(i?" ":"")<<v[i];} return os;}
using ull = unsigned long long;
using ll = long long;
using PL = pair<ll, ll>;
using P = pair<int, int>;
const ll INF64 = INT64_MAX / 2;
const int INF32 = INT32_MAX / 2;
const char newl = '\n';

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

  int t;
  cin>>t;

  while(t--){
    int n;
    cin>>n;
    range(i,0,3){
      string s;
      cin>>s;
    }
    cout<<string(n,'1')+string(n,'0')+"1"<<newl;
  }
}

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

int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int N;
    cin >> N;
    string S, T, U;
    cin >> S >> T >> U;
    for (int i = 0; i < N; i++) cout << '0';
    for (int i = 0; i < N; i++) cout << '1';
    cout << '0' << endl;
  }
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string s;
bool cmp(char a, char b){
	return a > b;
}
int main () {
	int T; cin >> T;
	string cp = "atcoder";
	while (T --){
		cin >> s;
		string temp = s;
		sort(temp.begin(), temp.end(), cmp);
		if(temp < cp){
			cout << -1 <<"\n";
			continue;
		}
		int n = s.length();
		if(s > cp){
			cout << 0 << "\n";
			continue;
		}
		int ans = 0;
		int p = 0;
		for(int i = 0; i < n; ++i){
			if(s[i] > 'a'){
				p = i;
				break;
			}
		}
		if(s[p] > 't') p --;
		cout << p << "\n";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define printg(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get_random() {
    static uniform_int_distribution<int> dist(0, 1e9 + 6);
    return dist(rng);
}
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

typedef unsigned long long ull;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 3e5 + 100;

ll cal(const string & s1, string s2) {
	if(s2.empty()) return 1e9;
	if(s1.empty()) return 0;
	if(s1[0]<s2[0]) return 0;

	ll res=1e9;
	if(s1[0]==s2[0])
		res = cal(s1.substr(1, s1.size()-1), s2.substr(1, s2.size()-1));
	rep(i,0,s2.size()){
		if(s2[i]>s1[0]) {
			res = min(res,ll(i));
			break;
		}
	}
	if(s1[0]==s2[0]) return res;
	// print(s1,s2);
	rep(i,1,s2.size()) {
		if(i>res) break;
		if(s2[i]==s1[0]) {
			auto tmp = s2[i] + s2.substr(0, i) + s2.substr(i+1, int(s2.size()) - (i+1));
			res = min(res, i + cal(s1.substr(1,s1.size()-1), tmp.substr(1,tmp.size()-1)));
			break;
		}
	}
	return res;
}

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";
    string s;
    cin>>s;
    ll res = cal("atcoder", s);
    cout<<(res >= 1e9 ? -1 : res)<<endl;
}

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve_testcase;

    return 0;
}


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

int main(){

	int t = 1;
	// cin >> t;
	while(t--){
		int n;
		cin >> n;
		if(n%2){
			cout << "Black";
		}
		else{
			cout << "White";
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int x=N*1.08;
  if(x<206)
    cout << "Yay!" << endl;
  else if(x>206)
    cout << ":(" << endl;
  else
    cout << "so-so" << endl;

  return 0;
}


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

#define maxn 105
typedef long long ll;
ll n,a[maxn],b[maxn];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++) cin>>b[i];
	ll counter=0;
	for(int i=1;i<=1000;i++){
		bool flag=false;
		for(int j=1;j<=n;j++)
			if(! (a[j]<=i && i<=b[j]))
				flag=true;
		if(!flag) counter++;
	}
	cout<<counter<<endl;
	return 0;
}

/*
 * Lang  : C++ 17
 * Author: Debajyoti Dasgupta
 * Date  : 10-04-2021 23:37 10
 */

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int mod = 1000'000'007;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    int mn = 0, mx = 1e9;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mn = max(mn, x);
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mx = min(mx, x);
    }
    cout << max(0, mx - mn + 1) << endl;
}


//Author: Xzirium
//Time and Date: 20:18:14  15 June 2021

//Optional FAST
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

template <typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template <typename T> using ordered_set1 = tree<T,null_type,greater<T>,rb_tree_tag,tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll b, ll e)
{
    ll r = 1ll;
    for(; e > 0; e /= 2, (b *= b) %= MOD)
        if(e % 2) (r *= b) %= MOD;
    return r;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);

}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(M);
    READV(K);
    if(N<=M+K)
    {
        ll tot=1;
        ll ans=1;
        FORI(i,1,N+M+1)
        {
            ans=(ans*i)%MOD;
        }
        tot=ans;
        FORI(i,1,N-K-1+1)
        {
            ans=(ans*modInverse(i))%MOD;
        }
        FORI(i,1,M+K+1+1)
        {
            ans=(ans*modInverse(i))%MOD;
        }
        FORI(i,1,N+1)
        {
            tot=(tot*modInverse(i))%MOD;
        }
        FORI(i,1,M+1)
        {
            tot=(tot*modInverse(i))%MOD;
        }
        if(N<K+1)
        {
            ans=0;
        }
        cout<<(tot-ans+MOD)%MOD<<endl;
    }
    else
    {
        cout<<0<<endl;
    }

//-----------------------------------------------------------------------------------------------------------//

    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9+7)
#define LINF ll(1e18+7)
#define PI acos(-1)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
  ll n,k;
  cin>>n>>k;
  rep(i,k){
    ll g1=0,g2=0;
    vector<int> num;
    while(n>0){
      num.push_back(n%10);
      n/=10;
    }
    sort(num.begin(),num.end());
    int sz=num.size();
    ll p=1;
    rep(j,sz){
      g1 += p*num[j];
      g2 += p*num[sz-j-1];
      p *= 10;
    }
    n=g1-g2;
  }
  cout<<n<<endl;
}


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

#define Mod(x) (x>=P)&&(x-=P)
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
#define erep(i,a) for(int i=hd[a];i;i=nxt[i])

typedef long long ll;
void Max(int &x,int y){(x<y)&&(x=y);}
void Min(int &x,int y){(x>y)&&(x=y);}

bool vio;
char IO;
int rd(int res=0){
	bool f=0;
	while(IO=getchar(),IO<48||IO>57)
		f=IO=='-';
	do res=(res<<1)+(res<<3)+(IO^48);
	while(IO=getchar(),isdigit(IO));
	return f?-res:res;
}
const int M=1e6+10;
int nxt[M<<1],to[M<<1],hd[M],ecnt;
void Add(int a,int b){
	nxt[++ecnt]=hd[a],to[hd[a]=ecnt]=b;
}
int Mx,tp,bot,L[M],R[M],n;
void dfs(int x,int f,int d){
	static int tot;
	if(d>Mx)tp=x,Mx=d;
	L[x]=++tot;
	erep(i,x){
		int y=to[i];
		if(y==f)continue;
		dfs(y,x,d+1);
	}
	R[x]=tot;
}
bool FA(int a,int b){
	return L[a]<=L[b]&&L[b]<=R[a];
}
int nw=1,ans[M];
void redfs(int x,int f){
	ans[x]=nw;
	erep(i,x){
		int y=to[i];
		if(y==f||FA(y,tp))continue;
		nw++,redfs(y,x);
	}
	erep(i,x){
		int y=to[i];
		if(y!=f&&FA(y,tp))nw++,redfs(y,x);
	}
	nw++;
}
bool let;
int main(){
	cerr<<(&vio-&let)/1024.0/1024<<endl;
	rep(i,2,n=rd()){
		int a=rd(),b=rd();
		Add(a,b),Add(b,a);
	}
	Mx=0,dfs(1,0,0);
	bot=tp,Mx=0,dfs(tp,0,0);
	ans[1]=1;
	redfs(bot,0);
	rep(i,1,n)printf("%d ",ans[i]);
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)						(x).begin(),(x).end()
#define X							first
#define Y							second
#define sep							' '
#define endl						'\n'
#define SZ(x)						ll(x.size())

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; //998244353; //1e9 + 9;

int n , timer , R[MAXN] , H[MAXN] , st[MAXN] , fn[MAXN];
vector<int> adj[MAXN];

int cmp(int i , int j){
	return R[i] < R[j];
}

void DFS(int v , int p = -1){
	st[v] = ++timer;
	R[v] = H[v] = (p == -1 ? 0 : H[p] + 1);
	sort(all(adj[v]) , cmp);
	for(int u : adj[v]){
		if(u == p)	continue;
		DFS(u , v);
		R[v] = max(R[v] , R[u]);
	}
	fn[v] = ++timer;
}

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

	cin >> n;
	for(int i = 1 ; i < n ; i++){
		int v , u;
		cin >> v >> u;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	DFS(1);
	int v = max_element(H , H + MAXN) - H;
	DFS(v);
	timer = 0; DFS(v);
	for(int i = 1 ; i <= n ; i++)	cout << st[i] << sep;

    return 0;
}
/*

*/