#include <bits/stdc++.h>
#include <ext/pb_ds/hash_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;

LL z = 1;

int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
const int N = 2e5 + 5;
LL sum[N], pre[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		sum[i] = sum[i - 1] + x;
		pre[i] = max(pre[i - 1], sum[i]);
	}
	LL mx = 0, tot = 0;
	for(int i = 1; i <= n; i++){
		mx = max(mx, tot + pre[i]);
		tot += sum[i];
	}
	cout << mx;
	return 0;
}

 /*
    Stay motivated and keep working hard
*/
#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 int long long
#define pb push_back
#define cntbit __builtin_popcount
#define fr first
#define mem(arr, val) memset(arr, val, sizeof(arr))
#define sc second
#define sz(v) ((int)(v).size())
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repd(i,a,p) for(int i=a-1;i>=p;i--)
#define md 998244353
#define vi vector<int>
#define vp vector<pair<int,int> >
#define ml map<int,int>
#define MPI 3.1415926536
#define in insert
#define endl "\n"
#define ub  upper_bound
#define lb  lower_bound
#define gcd __gcd
#define setval(a,b) memset(a,b,sizeof(a))
#define lwr lower_bound
#define pii pair<int,int>
#define upr upper_bound
#define ordered_s  et     tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define blk 555
//CANDIDATE MASTER TOH BNKE RHUNGA
//dsu is pel concept
//KMP is pel concept
int k,n,t,i,j=0,m;
const int N=4e6+5;
int md2;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += md;
  return u;
}
void extgcd(int a,int b, int& x,int& y)
{
    if(b != 0){
        extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1;
        y = 0;
    }
}
//fenwick tree is the best
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    unordered_map <int,int> mp1;
    int mn=*min_element(all(a));
    for(int i=0;i<n;i++)
    {
    	for(int j=1;j*j<=a[i] and j<mn;j++)
    	{
    		if(a[i]%j==0)
    		{
    		mp1[j]=__gcd(mp1[j],a[i]);
    		if(a[i]/j<mn)
    		mp1[a[i]/j]=__gcd(mp1[a[i]/j],a[i]);
    	    }
		}
	}
	int ans=1;
	for(auto it:mp1)
	{
		if(it.fr==it.sc)
		ans++;
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define int long long
#define menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pi pair<int, int>
#define BE(i) i.begin(),i.end()
#define fi first
#define se second
#define INF 2147483647
#define mkp make_pair
#define ist insert
#define mod 1000000007
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC optimize("O2")
using namespace std;
int min(int a, int b){return a < b ? a : b;}
int max(int a, int b){return a > b ? a : b;}
bool isprime(int k){bool is=1 ; for ( int i = 2 ; i*i <= k ; i++ ) if ( k % i == 0 ) is = 0 ; return k>1?is:0;}
const double PI=acos(-1);
int n,k;
pi a[200005];
void sol(){
    cin >>n>>k;
    for (int i=0;i<n;i++) cin >>a[i].fi>>a[i].se;
    sort(a,a+n);
    for (int i=0;i<n;i++){
        if (k>=a[i].fi) k+=a[i].se;
    }
    cout <<k<<"\n";
}
signed main(){
    menhera_chan_is_mine
    int _=1;
    //cin >>_;
    while (_--) sol();
    return 0;
}

#include<iostream>
#include<climits>
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define mod 998244353
LL r(vector<LL> &kabza,vector<LL> &nonKabza,LL i,LL j,vector<vector<LL> > &dp){
    if( i>=kabza.size() ){
        return 0;
    }
    if (j>=nonKabza.size()){
        return INT_MAX;
    }
    LL &ans= dp[i][j];
    if(ans != -1){
        return ans;
    }
    return ans = min( r(kabza,nonKabza,i,j+1,dp) , r(kabza,nonKabza,i+1,j+1,dp) + abs(kabza[i]-nonKabza[j]));
}

int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    LL N,K;
    cin >> N >> K;
    map <LL,LL> hash;
    for(LL i=0;i<N;i++){
        LL x,y;
        cin >> x >> y;
        hash[x]+=y;
    }
    LL have= K;
    LL pos = 0;
    for(auto it:hash){
        LL reach= have+pos;
        if(reach<it.first){
            break;
        }
        have= have-(it.first - pos);
        have+= it.second;
        pos= it.first;
    }
    cout<<have+pos;
}


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

using namespace std;

const int N = 1500005;

int n, m, a[N], cnt[N], ans[N];

int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		scanf("%d", &a[i]);
		++cnt[a[i]];
	}
	int l = -1;
	while(cnt[++l]);
	ans[l] = true;
	for(int i = m + 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		++cnt[a[i]];
		if(--cnt[a[i-m]] == 0) ans[a[i-m]] = true;
	}
	l = -1;
	while(!ans[++l]);
	cout << l << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    const int N = 26;
    const vector<int> dx = {0,1,0,-1};
    const vector<int> dy = {-1,0,1,0};
    auto isalpha = [](char c) {
        if (c >= 'a' && c <= 'z') return c - 'a';
        else return -1;
    };
    int h, w;
    cin >> h >> w;
    vector<string> ss(h);
    REP(i,h) cin >> ss[i];
    vector<vector<pii>> warp(N);
    pii s,g;
    REP(y,h) REP(x,w) {
        pii p{y,x};
        if (ss[y][x] == 'S') s = p;
        if (ss[y][x] == 'G') g = p;
        int a = isalpha(ss[y][x]);
        if (a >= 0) warp[a].emplace_back(p);
    }

    vector<pii> bfs;
    vector<vector<int>> step(h,vector<int>(w,-1));
    vector<bool> use(N);
    step[s.first][s.second] = 0;
    bfs.emplace_back(s.first,s.second);
    int ans = -1;
    int now = 1;

    while(!bfs.empty() && ans == -1) {
        vector<pii> tmp;
        swap(bfs,tmp);
        for (auto p:tmp) {
            // cerr << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;
            REP(i,dx.size()) {
                int y2 = p.first + dy[i];
                int x2 = p.second + dx[i];
                if (y2 < 0 || y2 >= h) continue;
                if (x2 < 0 || x2 >= w) continue;
                if (ss[y2][x2] == '#') continue;
                if (step[y2][x2] >= 0) continue;
                if (y2 == g.first && x2 == g.second) {
                    ans = now;
                }
                step[y2][x2] = now;
                bfs.emplace_back(y2,x2);
            }
            int a = isalpha(ss[p.first][p.second]);
            if (a >= 0 && use[a] == false) {
                for (auto p2:warp[a]) {
                    if (step[p2.first][p2.second] >= 0) continue;
                    step[p2.first][p2.second] = now;
                    bfs.emplace_back(p2.first,p2.second);
                }
                use[a] = true;
            }

        }
        now++;
    }

    if (ans > 0) OUT(ans)
    else OUT(-1)

    return 0;
}


/*
{
######################
#       Author       #
#        Gary        #
#        2021        #
######################
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
//    int x=0;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){
//        ch=getchar();
//    }
//    while(ch>='0'&&ch<='9'){
//        x=(x<<1)+(x<<3)+(ch^48);
//        ch=getchar();
//    }
//    return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int h,w;
char a[2002][2002];
int dp[2002][2002];
int main(){
	cin>>h>>w;
	rb(i,1,h)
		rb(j,1,w)
			cin>>a[i][j];
	memset(dp,-63,sizeof(dp));
	dp[h][w]=0;
	rl(i,h,1)
		rl(j,w,1)
			if(i!=h||j!=w){
				if(i!=h){
					check_max(dp[i][j],-dp[i+1][j]+(a[i+1][j]=='+'? 1:-1));
				}
				if(j!=w){
					check_max(dp[i][j],-dp[i][j+1]+(a[i][j+1]=='+'? 1:-1));
				}
			}
	if(dp[1][1]>0){
		cout<<"Takahashi";
	}
	if(dp[1][1]<0){
		cout<<"Aoki";
	}
	if(dp[1][1]==0){
		cout<<"Draw";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxn = 2e5+5;
#define mod 1000000009

void solve(){

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

  if( m==0){
  	cout << 1 << endl;
  	return;
  }

  sort(a.begin(),a.end());
  vector<int> widths;
  for(int i=0;i<m-1;i++){
  	if(a[i+1]-a[i]-1 > 0)
  	widths.push_back(a[i+1]-a[i]-1);
  }

  if(a[0] > 1)
   widths.push_back(a[0]-1);
  if( n-a[m-1] > 0)
  widths.push_back(n-a[m-1]);

  // for(auto i: widths) cout << i <<" ";
  // 	cout << endl;
  if( widths.empty() || m == 0) {
  	cout << 0 <<endl;
  	return;
  }
  int mn = *min_element(widths.begin(),widths.end());
  int ans =0;

  for(auto i : widths){
  	ans += (i+mn-1)/mn;
  }

  if(widths.empty()) cout << 0 << endl;
  else cout << ans << endl;
}

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int tc = 1;
  // cin >> tc;
   while(tc--) solve();

 return 0;
}


//红太阳zhouakngyang txdy!
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
	int sum=0,nega=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')nega=-1;ch=getchar();}
	while(ch<='9'&&ch>='0')sum=sum*10+ch-'0',ch=getchar();
	return sum*nega;
}
const int N=5009,mod=998244353;
int n,m,dp[N],res,ny[N],zky,qwq;
inline int Pow(int x,int y)
{
	int res=1,base=x;
	while(y)
	{
		if(y%2==1)res=res*base%mod;
		base=base*base%mod;
		y=y/2;
	}
	return res;
}
signed main()
{
	n=read(),m=read();swap(n,m);
	dp[1]=n;
	for(int i=1;i<=n;i++)ny[i]=Pow(i,mod-2);
	for(int i=2;i<=m;i++)
	{
		res=0;
		dp[i]=dp[i-1]*n%mod;zky=Pow(n,i);
		//res=(res+Pow(n,i-2))%mod;
		//cout<<res<<"----"<<endl;
		for(int j=1;j<=n;j++)
		{
			int k=n-j,p=i-1;
			qwq=Pow(n,p)-Pow(k,p)+mod;
			qwq=qwq%mod*ny[n-k]%mod;
			res=res+qwq;res=res+mod;res=res%mod;
		}
		dp[i]=dp[i]+(zky-res+mod);dp[i]=dp[i]%mod;
		//cout<<dp[i]<<endl;
	}
	cout<<dp[m]<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int Inf = 2000000030;
constexpr long long INF= 2000000000000000000;

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

template<typename T>
T modpow(T N, T P, T M){
    if(P < 0) return 0;
    if(P == 0) return 1;
    if(P % 2 == 0){
        T t = modpow(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) return N * modpow(N,P - 1,M);
    return N * modpow(N, P-1, M) % M;
}

template<typename T>
struct CumulativeSum {
    vector<vector<T>> Sum;
    CumulativeSum(int H,int W,vector<vector<T>> vec) {
        Sum.resize(H + 1,vector<T>(W + 1,0));
        for(int i = 0;i < H;i++) {
            for(int j = 0;j < W;j++) {
                Sum.at(i + 1).at(j + 1) = Sum.at(i).at(j + 1) + Sum.at(i + 1).at(j) - Sum.at(i).at(j) + vec.at(i).at(j);
            }
        }
    }
    //クエリ[x1,x2)*[y1,y2)(0-indexed)の長方形区域の和
    T sum(int x1,int x2,int y1,int y2) {
        return Sum.at(x2).at(y2) - Sum.at(x1).at(y2) - Sum.at(x2).at(y1) + Sum.at(x1).at(y1);
    }
};

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> cnt(N * N);
    vector<vector<int>> vec(N,vector<int>(N));
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < N;j++) {
            cin >> vec[i][j];
            cnt[i * N + j] = vec[i][j];
        }
    }
    sort(cnt.begin(),cnt.end());
    int ng = -1;
    int ok = N * N;
    while(ok - ng > 1) {
        int mid = (ng + ok) / 2;
        int target = cnt[mid];
        vector<vector<int>> Sum(N,vector<int>(N));
        for(int i = 0;i < N;i++) {
            for(int j = 0;j < N;j++) {
                if(vec[i][j] <= target) Sum[i][j]++;
            }
        }
        CumulativeSum<int> Sum2(N,N,Sum);
        bool res = false;
        for(int i = 0;i <= N - K;i++) {
            for(int j = 0;j <= N - K;j++) {
                if(Sum2.sum(i,i + K,j,j + K) >= K * K - K * K / 2) {
                    res = true;
                }
            }
        }
        if(res) ok = mid;
        else ng = mid;
    }
    cout << cnt[ok] << endl;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    double x0, y0, x2, y2;
    cin >> n >> x0 >> y0 >> x2 >> y2;

    const double pi = acos(-1);

    double x1 = ((x0 + x2) + (x0 - x2) * cos(2.0*pi/n) - (y0 - y2)*sin(2.0*pi/n)) / 2.0;
    double y1 = ((y0 + y2) + (x0 - x2) * sin(2.0*pi/n) + (y0 - y2)*cos(2.0*pi/n)) / 2.0;

    printf("%.10f %.10f\n",x1, y1);
    re0;
}

#include <bits/stdc++.h>
//#include <atcoder/string>
//using namespace atcoder;
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
using tp = tuple<ll, ll, ll>;
const ll INF = (1LL<<61);

template<class T> bool chmin(T &a, const T b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N;
    vec a(N), m(N), s(N);
    rep(i, N){
        cin>>a[i];
        m[i] = s[i] = a[i];
        if(i) {
            s[i] += s[i - 1];
            chmax(m[i], m[i - 1]);
        }
    }
    ll minus = 0;
    rep(k, N){
        minus += a[k] * k;
        cout<<m[k] * (k + 1) + s[k] * (k + 1) - minus<<endl;
    }

}


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

#define ll long long
const int maxn = 4e5 + 5;

int n;
int a[maxn];

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

	priority_queue<int> heap;
	ll sum = 0, aoki = 0;
	for(int i=1;i<=n;i++) {
		heap.push(-a[n-i+1]);
		heap.push(-a[n+i]);
		sum += a[n-i+1] + a[n+i];
		aoki += -heap.top(); heap.pop();
	}
	printf("%lld",sum - aoki);
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    int k;
    cin>>s>>k;
    for(int aaa=0;aaa<k;aaa++){
        string a = s;
        string b = s;
        sort(all(a));
        sort(all(b));
        reverse(all(b));
        int x = 0;
        int n = a.size();
        for(int i=0;i<n;i++){
            x *= 10;
            x += b[i]-a[i];
        }
        s = to_string(x);
    }
    cout << s << endl;
}


#include <bits/stdc++.h>
using namespace std;
//-(smallstar))---- :]
#define int long long
#define ll long long
#define mp make_pair
#define vi vector<ll>
#define pb push_back
#define all(o) (o).begin(), (o).end()
#define rall(o) (o).rbegin(), (o).rend()
#define nl cout << "\n"
//debug start
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define debugvi(a)                           \
    for (int idx = 0; idx < a.size(); idx++) \
    {                                        \
        cerr << #a << "[" << idx << "]: ";   \
        for (auto i : a[idx])                \
            cerr << i << " ";                \
        cerr << ' ';                         \
        cerr << '\n';                        \
    }
#define debugpp(a)                                         \
    cerr << #a << ": ";                                    \
    for (auto i : a)                                       \
        cerr << "(" << i.first << "," << i.second << ") "; \
    cerr << '\n';

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}
//debug end
template <class T>
istream &operator>>(istream &is, vector<T> &V)
{
    for (auto &e : V)
        is >> e;
    return is;
}

const ll MOD = 1000000007;
const ll inf = LONG_LONG_MAX;
const ll ninf = LONG_LONG_MIN;

long long binpow(long long a, long long b)
{

    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

void europa_enceladus_titan()
{
    int k;
    string n;
    cin >> n >> k;
    while (k--)
    {
        int m = stoll(n);
        if (m % 200 == 0)
        {
            m /= 200;
            n = to_string(m);
        }
        else
        {
            n += "200";
        }
    }
    cout << n << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t = 1;
    //cin >> t;
    for (int i = 0; i < t; i++)
    {
        europa_enceladus_titan();
    }
}

//created by pyoxiao on 2021/05/08
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
LL n;
int k;
void solve() {
    cin >> n >> k;
    for(int i = 1; i <= k; i ++) {
        if(n % 200 == 0) n /= 200;
        else {
            n = n * 1000LL + 200;
        }
    }
    cout << n << '\n';
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --)
        solve();
    return 0;
}


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

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  a2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll a[N],b[N];
int main()
{
    ll n,w;
    cin>>n>>w;
    cout<<n/w<<endl;
}

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<long long>a(n);
	rep(i, n)cin >> a[i];
	long long amax = -LINF;
	long long sub0 = 0;
	long long sub1 = 0;
	rep(i, n) {
		long long ans = 0;
		sub1 += a[i];
		sub0 += sub1;
		chmax(amax, a[i]);
		ans += amax * (i + 1);
		ans += sub0;
		cout << ans << endl;
	}
	return 0;
}


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

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

using ll = long long;
using P = pair<int, int>;
using vvi = vector<vector<int>>;
using vi = vector<int>;

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;

void solve() {
    int n;
    cin >> n;

    if (n % 100 == 0) {
        cout << n/100 << endl;
    } else {
        cout << n/100 + 1 << endl;
    }
}

int main() {

    solve();

    return 0;
}

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

int main(){
  int x;
  cin >> x;
  if(x<0) cout << 0 << endl;
  else cout << x << endl;
  return 0;
}


 #include <bits/stdc++.h>
#define ll         long long int
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(ll i=0;i<n;i++)
#define f1(i,x,y)  for(ll i=x;i<=y;i++)
#define f2(i,x,y)  for(ll i=x;i>=y;i--)
#define yes        cout<<"YES"<<"\n"
#define no         cout<<"NO"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
#define moddif(a,b)  ((a%mod)-(b%mod)+mod)%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes
//__builtin_ctz(x)      to count the number of trailing zeroes
//__gcd(a,b)
using namespace std;
ll visited[51];
ll Fact(ll x)
{
    ll y=1;
    for(ll i=1;i<=x;i++){y=modpro(y,i);}
    return y;
}
ll dfs(ll parent,vector <ll> v[])
{
    ll y=1;
    visited[parent]=1;
    for(ll i=0;i<v[parent].size();i++)
    {
        if(visited[v[parent][i]]==0)
        {
            y+=dfs(v[parent][i],v);
        }
    }
    return y;
}
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=((result%M) * (x%M))%M;
        x=((x%M)*(x%M))%M;
        n=n/2;
    }
    return result;
}
ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
ll pow1(ll x,ll y)
{
    ll z=1;
    while(y--){z=z*x;}
    return z;
}
bool isprime(ll n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
ll check(ll x)
{
    ll y=1,z=0;
    while(x>y){y*=2;z++;}
    if(x!=y){z--;}
    return z;
}
// Returns n^(-1) mod p
unsigned long long modInverse(unsigned long long n, int p)
{
    return modularExponentiation(n, p - 2, p);
}

// Returns nCr % p using Fermat's little
// theorem.
unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
    // Base case
    if (r == 0)
        return 1;

    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}
ll modInverse(ll A,ll M)
{
    return modularExponentiation(A,M-2,M);
}
bool cmp(pair<ll,ll> a, pair<ll,ll> b)
{
    if(a.F==b.F)
        return a.S<b.S;
    else
        return a.F<b.F;
}
int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   long long int   n;cin>>n;
   long long int ans=2329089562801;
   cout<<ans;
}

#include<bits/stdc++.h>
#include<vector>
#include<map>
#include<set>
#include<list>
using namespace std;

#define ll signed long long
#define D double
#define LD long double
#define ff first
#define ss second
#define PII pair<int, int>
#define PLL pair<ll,ll>
#define SPLL pair<sll, sll>
#define pb(x) push_back(x)
#define pp() pop_back()
#define in(x) insert(x)
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vpii vector<PII>
#define vpll vector<PLL>
#define vvi vector<vi>
#define pn(n) cout<<n<<endl
#define pn2(x,y) cout<<x<<" "<<y<<endl
#define pn3(x, y, z) cout<<x<<' '<<y<<' '<<z<<endl;
#define pr(ar) {for (auto i : ar) cout<<i<<" "; cout<<endl;}
#define get(x) cin>>x;
#define get2(x, y) cin>>x>>y;
#define get3(x, y, z) cin>>x>>y>>z;
#define cn(v) for(auto &i : v) cin>>i;
#define sq(a) (a*a)
#define mpii make_pair
#define eps 1e-9
#define MM0(x) memset(x, 0, sizeof x)
#define MM1(x) memset(x, 1, sizeof x)
int dr[] {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
ll const mod = 1e9 + 7;
bool many____testttt = 0;
int const mx = 505;

bool is_prime(int n){
	for(int i = 2; i < n; i++) if(n%i == 0) return 0;
	return 1;
}
void solve()
{
	ll n; cin>>n;
	ll sum = 1;

	vector<vector<int>> div(35);
	for(int i = 2; i <= n; i++){
		int m = i;
		for(int j = 2; j <= i; j++)if(m%j == 0) {
			while(m > 1){
				div[i].pb(j);
				m /= j;
			}
		}
	}
	vi cnt(36, 0);
	//for(auto i : div) pr(i);
	for(auto i : div){
		vi c(35, 0);
		for(auto j : i){
			c[j]++;
		}
		for(int k = 0; k <= 35; k++) cnt[k] = max(cnt[k], c[k]);
	}

	for(int i = 2; i <= 35; i++){
		for(int j = 0; j < cnt[i]; j++) sum *= i*1LL;
	}
	cout<<sum+1<<endl;
}
void solve_2() {int t; cin>>t; while(t--) solve();}

int main()
{
  if(!many____testttt) solve();
  else solve_2();
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i, b) for (int i = 0; i < b; i++)
#define fr(i, a, b) for (int i = a; i >= b; i--)
#define vt vector
#define all(v) v.begin(), v.end()
const ll M = 998244353;
using namespace std;
ll num(string t)
{
    ll r = 0;
    for (ll i = 0; i < t.length(); i++)
    {
        r = r * 10 + (t[i] - '0');
    }
    return r;
}
ll modularExponentiation(ll x, ll n, ll M)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0)
        return modularExponentiation((x * x) % M, n / 2, M);
    return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
ll binaryExponentiation(ll x, ll n)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0)
        return binaryExponentiation(x * x, n / 2);
    else
        return x * binaryExponentiation(x * x, (n - 1) / 2);
}
ll GCD(ll A, ll B)
{
    if (B == 0)
        return A;
    else
        return GCD(B, A % B);
}
ll extended_GCD(ll a, ll b, ll &x, ll &y)
{
    if (a == 0)
    {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = extended_GCD(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return gcd;
}
ll modinv(ll a, ll mod)
{
    ll x, y;
    extended_GCD(a, mod, x, y);
    if (x < 0)
        x += mod;
    return x;
}
ll modPrimeInverse(ll A, ll M)
{
    return modularExponentiation(A, M - 2, M);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    vt<string> v;
    ll val = 6;
    vt<ll> v2;
    ll flag=0;
    while (val--)
    {
        // cout<<v[v.size()-1]<<"\n";
        // if (v.size()!=0&&v[v.size() - 1] >= "999999")
        //     break;
        vt<string> v1;
        if (v.size() == 0)
        {
            for (int i = 0; i <= 9; i++)
            {
                string ans = "";
                ans += to_string(i);
                v.push_back(ans);
                ans += to_string(i);
                if(ans!="00")
                    v2.push_back(num(ans));

                // cout << ans << "\n";
            }
        }
        else
        {
            for (int i = 0; i < v.size(); i++)
            {

                for (int j = 0; j <= 9; j++)
                {
                    string ans = "";
                    ans += to_string(j);
                    ans += v[i];
                    v1.push_back(ans);
                    // cout<<ans<<"     ";
                    ans += ans;
                    ll x=num(ans);
                    if(ans[0]!='0')
                        v2.push_back(x);
                    // cout << ans << "\n";
                    if(ans=="999999999999")
                    {
                        flag=1;
                        break;
                    }
                }
                if(flag)break;
            }
            if(flag)break;
            v=v1;
        }

    }
    sort(all(v2));
    // if(s.find(n); != s.end()){
    //     cout<<*(s.find(n));
    // }
    if (binary_search(v2.begin(), v2.end(), n))
    {
        // cout << n << "\n";
        cout << lower_bound(v2.begin(), v2.end(), n) - v2.begin() + 1 << "\n";
    }
    else
    {
        if (n < 11)
        {
            cout << "0";
        }
        else
        {
            cout << lower_bound(v2.begin(), v2.end(), n) - v2.begin() << "\n";
        }
    }

    // f(i, v2.size()) cout << v2[i] << "\n";
#ifndef ONLINE_JUDGE
    cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
#endif
    return 0;
}


// Problem: C - Tricolor Pyramid
// Contest: AtCoder - AtCoder Regular Contest 117
// URL: https://atcoder.jp/contests/arc117/tasks/arc117_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
//#define int long long
inline int read()
{
	int num=0,f=1;char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>47&&c<58)num=num*10+(c^48),c=getchar();
	return num*f;
}
#include <stdio.h>
typedef long long ll;
const int p=3;
ll f[100005];
void init()
{
	f[0] = 1;
	for (int i = 1; i <= p; ++i) f[i] = f[i - 1] * i % p;
}
ll pow_mod(ll a, ll x)
{
	ll ret = 1;
	while (x)
	{
		if (x & 1)  ret = ret * a % p;
		a = a * a % p;
		x >>= 1;
	}
	return ret;
}
inline int pow_mod(int x,int y,int z)
{
	return x;
}
ll C(ll n, ll m){
	return (m>n ? 0 : ((f[n] * pow_mod(f[m], p - 2, p)) % p*pow_mod(f[n - m], p - 2, p) % p));
}
ll Lucas(ll n, ll k)
{
	return (k ? ((C(n%p, k%p) % p)*Lucas(n / p, k / p) % p) % p : 1);
}
/*int main()
{
	scanf("%*d");
	int p, n, m;
	while (~scanf("%d%d%d", &n, &m, &p))
		printf("%lld\n", (init(p), Lucas(n + m, n, p)));
	return 0;
}*/
inline int re1d()
{
	char c=getchar();
//	while(c<48||c>49)c=getchar();
	while(c<'A'||c>'Z')c=getchar();
	return c=='B'?0:c=='W'?1:2;
}
inline int min(int a,int b){return a>b?b:a;}
inline int max(int a,int b){return a<b?b:a;}
signed main()
{
	init();
	int n=read(),ans=0;
	for(int i=0;i<n;i++)
	{
		int x=re1d();
		ans=ans+x*Lucas(n-1,i);
		ans%=3;
	}
	if(n&1);else ans=(6-ans)%3;
	printf("%c\n","BWR"[ans]);
}

#pragma GCC optimize ("Ofast")
#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;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
#define b_s(a,b) binary_search(a.begin(),a.end(),b)
#define l_b(a,b) lower_bound(a.begin(),a.end(),b)
#define u_b(a,b) upper_bound(a.begin(),a.end(),b)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int k; cin >> k;
    int ans = 0;
    for (int i = 1; i * 2 <= k; i++)
    {
        for (int j = 1; j * i <= k; j++)
        {
            ans += k / (i * j);
        }
        //trace(i, ans);
    }
    cout << ans + (k - (k / 2) );
}


#include<iostream>
#include<cstdio>
#include<algorithm>
namespace do_while_true {
	#define ld double
	#define ll long long
	#define re register
	#define pb push_back
	#define fir first
	#define sec second
	#define pp std::pair
	#define mp std::make_pair
	const ll mod = 998244353;
	template <typename T>
	inline T Max(T x, T y) { return x > y ? x : y; }
	template <typename T>
	inline T Min(T x, T y) { return x < y ? x : y; }
	template <typename T>
	inline T Abs(T x) {	return x < 0 ? -x : x; }
	template <typename T>
	inline T& read(T& r) {
		r = 0; bool w = 0; char ch = getchar();
		while(ch < '0' || ch > '9') w = ch == '-' ? 1 : 0, ch = getchar();
		while(ch >= '0' && ch <= '9') r = r * 10 + (ch ^ 48), ch = getchar();
		return r = w ? -r : r;
	}
	template <typename T>
	inline T qpow(T x, T y) {
		re T sumq = 1; x %= mod;
		while(y) {
			if(y&1) sumq = sumq * x % mod;
			x = x * x % mod;
			y >>= 1;
		}
		return sumq;
	}
	char outch[110];
	int outct;
	template <typename T>
	inline void print(T x) {
		do {
			outch[++outct] = x % 10 + '0';
			x /= 10;
		} while(x);
		while(outct >= 1) putchar(outch[outct--]);
	}
}
using namespace do_while_true;

ll B, C;

void solve() {
	read(B); read(C);
	if(C == 1) {
		printf("%d\n", B == 0 ? 1 : 2);
		return ;
	}
	ll down1 = B - (C / 2), up1 = B + ((C - 2) / 2);
	B = -B; C--;
	ll down2, up2;
	if(C == 1) {
		printf("%lld\n", up1 - down1 + 1 + (!(down1 <= B && B <= up1)));
		return ;
	}
	down2 = B - (C / 2), up2 = B + (C / 2);
	if(Max(down1, down2) <= Min(up1, up2)) {
		printf("%lld\n", Max(up1, up2) - Min(down1, down2) + 1);
	}
	else {
		printf("%lld\n", up1 - down1 + 1 + up2 - down2 + 1);
	}
}

signed main() {
	#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
	#endif
	int T = 1;
//	read(T);
	while(T--) solve();
	fclose(stdin);
	return 0;
}

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

#define ll long long
#define print(a)          \
    for (auto x : a)      \
        cout << x << " "; \
    cout << endl
#define print_upto(a, n)        \
    for (ll i = 1; i <= n; i++) \
        cout << a[i] << " ";    \
    cout << endl
#define take(a, n)              \
    for (ll i = 1; i <= n; i++) \
        cin >> a[i];

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"
#define watch3(x, y, z) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << " and " << (#z) << " is " << (z) << "\n"

#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(), (c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define inf 1e17
// cout << fixed << setprecision(9) << ans << nl;

typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;

const ll N = 200009;

void solve()
{
    ll b, c;
    cin >> b >> c;

    ll ans = 0;
    if (b < 0)
        ans++;
    b = abs(b);

    if (b == 0)
    {
        ll xr = 0;
        if (c >= 3)
        {
            xr = 1 + (c - 3) / 2;
        }

        ll xl = 0;
        if (c >= 2)
        {
            xl = 1 + (c - 2) / 2;
        }

        cout << 1 + xl + xr << nl;
        return;
    }

    if (c == 0)
    {
        cout << 1 << nl;
        return;
    }

    ll xr;
    if (c < 4)
    {
        xr = 0;
    }
    else
    {
        xr = 1 + (c - 4) / 2;
    }

    ll mxl;
    if (c < 3)
    {
        mxl = 0;
    }
    else
    {
        mxl = 1 + (c - 3) / 2;
    }

    ll xl;
    if (c < 2)
    {
        xl = 0;
    }
    else
    {
        ll limit = min(b * 2, c);
        xl = 1 + (limit - 2) / 2;
    }

    ll mxr;
    if (c < 1)
    {
        mxr = 0;
    }
    else
    {
        ll no = b;
        if (no == 0)
        {
            mxr = 0;
        }
        else
        {
            ll val = 1 + (no - 1) * 2;
            ll limit = min(val, c);
            mxr = 1 + (limit - 1) / 2;
        }
    }

    ans += 1 + xr + mxl + xl + mxr;
    cout << ans << nl;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll t = 1;
    // cin >> t;

    while (t--)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
int q[50][50];int u[50][50];int v[2501];vector<int> s;vector<int> ms;int mt=-1;int tt=0;
time_point<high_resolution_clock> start;
#pragma GCC optimize("O2")
char h(int c){
	if(c==0)return 'D';
	if(c==1)return 'R';
	if(c==2)return 'U';
	return 'L';
}
void bk(int x,int y,int t){
	tt++;
	if(tt>43000000){
		auto stop=high_resolution_clock::now();
		auto duration=duration_cast<milliseconds>(stop-start);
		if(duration.count()>1990)return;
	}
	v[u[x][y]]=1;
	if(t>mt){ms=s;mt=t;}
	for(int i=0;i<=3;i++){
		int a,b;
		if(i==0){a=x+1;b=y;}
		else if(i==1){a=x;b=y+1;}
		else if(i==2){a=x-1;b=y;}
		else {a=x;b=y-1;}
		if((min(a,b)>=0&&max(a,b)<=49&&v[u[a][b]]==0)){
		s.push_back(i);
		bk(a,b,t+q[x][y]);
		s.pop_back();
	}}
	v[u[x][y]]=0;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int x,y;cin>>x>>y;int c=0;
	for(int i=0;i<50;i++)for(int j=0;j<50;j++)cin>>u[i][j];
	for(int i=0;i<50;i++)for(int j=0;j<50;j++)cin>>q[i][j];
	start=high_resolution_clock::now();
	v[u[x][y]]=1;
	bk(x,y,q[x][y]);
	/*while(1){
		vector<pair<int,int>> o;
		for(int i=0;i<=3;i++)o.push_back({l(x,y,(c+i)%4,1),(c+i)%4});
		sort(o.rbegin(),o.rend());
		for(auto i:o){if(f(x,y,i.second,1)&&f(x,y,i.second,2)&&f(x,y,i.second,3)){auto p=w(x,y,i.second,1);x=p.first;y=p.second;c=i.second;cout<<h(c);goto sk1;}}
		break;sk1:continue;
	}
	while(1){
		vector<pair<int,int>> o;
		for(int i=0;i<=3;i++)o.push_back({l(x,y,(c+i)%4,1),(c+i)%4});
		sort(o.rbegin(),o.rend());
		for(auto i:o){if(f(x,y,i.second,1)&&f(x,y,i.second,2)&&f(x,y,i.second,3)){auto p=w(x,y,i.second,1);x=p.first;y=p.second;c=i.second;cout<<h(c);goto sk2;}}
		break;sk2:continue;
	}*/
	for(auto i:ms)cout<<h(i);
	/*while(1){
		vector<pair<int,int>> o;
		for(int i=0;i<=3;i++)o.push_back({l(x,y,(c+i)%4,1),(c+i)%4});
		sort(o.rbegin(),o.rend());
		for(auto i:o){if(f(x,y,i.second,1)&&f(x,y,i.second,2)&&f(x,y,i.second,3)){auto p=w(x,y,i.second,1);x=p.first;y=p.second;c=i.second;cout<<h(c);goto sk3;}}
		break;sk3:continue;
	}*/
	cout<<endl;//cout<<tt<<endl;
  return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>
#include <cassert>
#include <fstream>

#define rep(i, n) for(int i = 0; i < n; i++)
#define per(i, n) for(int i = n - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define mod 1000000007
using namespace std;
template<class T, class U>
T &chmax(T &a, const U &b){ if(a < b) a = b; return a; }
template<class T, class U>
T &chmin(T &a, const U &b){ if(a > b) a = b; return a; }
#define y first
#define x second
constexpr bool istest = false;
constexpr int n = 50;
ifstream file;
ofstream out;
void input_setup(){
	if(istest){
		cout << "write the in file number\n";
		string s;
		cin >> s;
		file.open("C:/Users/souta/downloads/ahc/tools/in/" + s + ".txt");
		if(file.fail()){
			cout << "the file was not found\n";
			return;
		}
		cin.rdbuf(file.rdbuf());
	}
}
//答えるときのやつ
string ans = "";
void output(){
	if(istest){
		out.open("C:/users/souta/downloads/ahc/tools/out.txt");
		if(out.fail()){
			cout << "the file was not found\n";
			return;
		}
		cout.rdbuf(out.rdbuf());
	}
	cout << ans << "\n";
}
pii st_pos;
vvi tiles(n, vi(n)), point(n, vi(n));
void inputs(){
	//start position
	cin >> st_pos.y >> st_pos.x;
	//tiles
	rep(i, n) rep(j, n) cin >> tiles[i][j];
	//points
	rep(i, n) rep(j, n) cin >> point[i][j];
}

//過去に同じ番号のタイルを通ったことがあるのかを確認する
bool checkVisited(const int &Y, const int &X, const vector<pii> &logs){
	int col = tiles[Y][X];
	for(auto a : logs){
		if(col == tiles[a.y][a.x]) return true;
	}
	return false;
}
//とりあえずBFSで探索してみる
int dy[] = {-1,1,0,0};
int dx[] = {0,0,-1,1};
char dir[] = {'U', 'D', 'L', 'R'};
void bfs(){
	priority_queue<pair<pii, int>> que;
	vvi checked(n, vi(n, -1));
	checked[st_pos.y][st_pos.x] = point[st_pos.y][st_pos.x];
	vector<vector<vector<pii>>> logs(n, vector<vector<pii>>(n));

	logs[st_pos.y][st_pos.x].push_back(make_pair(st_pos.y, st_pos.x));

	pii bestpos = st_pos;
	int mx = point[st_pos.y][st_pos.x];

	rep(loop, 1){

		vector<pii> temp = logs[bestpos.y][bestpos.x];
		logs = vector<vector<vector<pii>>>(n, vector<vector<pii>>(n));
		checked = vvi(n, vi(n, -1));
		logs[bestpos.y][bestpos.x] = temp;
		checked[bestpos.y][bestpos.x] = mx;
		que.push(make_pair(bestpos, mx));

		while(!que.empty()){
			pii pos; int score;
			tie(pos, score) = que.top();
			que.pop();
			if(checked[pos.y][pos.x] > score) continue;
			rep(i, 4){
				int Y = pos.y + dy[i];
				int X = pos.x + dx[i];
				if(Y >= n || X >= n || Y < 0 || X < 0) continue;
				if(checkVisited(Y, X, logs[pos.y][pos.x])) continue;

				int v = score + point[Y][X];
				if(checked[Y][X] == -1 || checked[Y][X] < v){
					que.push(make_pair(make_pair(Y, X), v));
					checked[Y][X] = v;
					logs[Y][X] = logs[pos.y][pos.x];
					logs[Y][X].push_back(make_pair(Y, X));
				}
			}
		}

		mx = 0;
		bestpos = st_pos;
		rep(i, n) rep(j, n){
			if(mx < checked[i][j]){
				bestpos = make_pair(i, j);
				mx = checked[i][j];
			}
		}
	}

	vector<pii> track = logs[bestpos.y][bestpos.x];
	pii last = st_pos;
	for(auto a : track){
		rep(i, 4){
			if(last.y + dy[i] == a.y && last.x + dx[i] == a.x){
				ans += dir[i];
				break;
			}
		}
		last = a;
	}
}
int main(){
	input_setup();
	inputs();

	bfs();

	output();
}


#include <bits/stdc++.h>
#define int long long
#define Mid ((l + r) >> 1)
#define lson (rt << 1)
#define rson (rt << 1 | 1)
using namespace std;
int read(){
	char c; int num, f = 1;
	while(c = getchar(),!isdigit(c)) if(c == '-') f = -1; num = c - '0';
	while(c = getchar(), isdigit(c)) num = num * 10 + c - '0';
	return f * num;
}
signed main()
{
	int b = read(), c = read(), ans, minn;
	if(b < 0) ans = c + 1;
	else if(b > 0) {
		if(c <= 2) ans = 2;
		else ans = c;
	} else if(b == 0) {
		ans = c;
	}
	if(b == 0){
		printf("%lld\n", ans);
		return 0;
	}
	if(b < 0) b = -b, c -= 1;
	minn = b - c / 2;
	if(minn <= 0) {
		minn = 1;
		ans++;
	}
	if((b - minn) * 2 < c) ans += (b - minn) * 2;
	else if(b != minn) ans += (b - minn - 1) * 2 + 1;
	printf("%lld\n", ans);
	return 0;
}

#include<cstdio>
#include<set>
#define fo(x,a,b) for(int x=(a),e_=(b);x<=e_;x++)
#define fd(x,a,b) for(int x=(a),e_=(b);x>=e_;x--)
#define fi first
#define se second
#define mp make_pair
#define ww printf

using namespace std;
typedef long long ll;
set<pair<int,int>> s;
int n;

int main(){
	int u,v;
	scanf("%d",&n);
	fo(i,1,n) {
		scanf("%d",&u);
		auto it=s.lower_bound(mp(u,0));
		if(it==s.end() || it->fi!=u) s.insert(mp(u,1));
		else v=it->se, s.erase(it), s.insert(mp(u,v+1));
	}
	while(true){
		auto itl=s.begin(), itr=s.end(); itr--;
		if(itl==itr) break;
		u=itr->fi, v=itr->se;
		u-=itl->fi;
		s.erase(itr);

		auto it=s.lower_bound(mp(u,0));
		if(it!=s.end() && it->fi==u)
			v+=it->se, s.erase(it);
		s.insert(mp(u,v));
	}
	printf("%d",s.begin()->fi);
	return 0;
}


//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FIO ios_base::sync_with_stdio(false); cin.tie(0);
#define trav(x,a) for (auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define endl "\n"
#define case(t) cout << "Case #" << (t) << ": "
#define reada(a, n) for (int _i = 0; _i < (n); _i++) read(a[_i])
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;

template<class T> void read(T& x) { cin >> x; }
template<class X, class Y> void read(pair<X,Y>& a) { read(a.first), read(a.second); }
template<class T, size_t U> void read(array<T,U>& x) { for (int i = 0; i < U; i++) read(x[i]); }
template<class T> void read(vector<T>& x) { trav(y, x) read(y); }
template<class T, class... O> void read(T& x, O&... y) { read(x), read(y...); }

string to_string(const char& x) { return string(1,x); }
string to_string(const char*& x) { return (string)x; }
string to_string(const string& x) { return x; }
template<class T, class U> string to_string(const pair<T,U>& x) { return to_string(x.first) + " " + to_string(x.second); }
template<class T, size_t U> string to_string(const array<T,U>& x) { string ret = ""; for (int i = 0; i < U; i++) ret += (!i ? "" : " ") + to_string(x[i]); return ret; }
template<class T> string to_string(const vector<T>& x) { string ret = ""; bool f = 0; trav(y, x) ret += (!f ? "" : " ") + to_string(y), f = 1; return ret; }
template<class T> string to_string(const set<T>& x) { string ret = ""; bool f = 0; trav(y, x) ret += (!f ? "" : " ") + to_string(y), f = 1; return ret; }
void print() { cout << endl; }
template<class T> void pr(const T& x) { cout << to_string(x); }
template<class T, class... O> void print(const T& x, const O&... y) { pr(x); if (sizeof...(y)) pr(" "); print(y...); }

void solve() {
  int n; read(n);
  vector<int> pr, a(n);
  for (int i = 2; i <= 50; i++) {
    int o = 1;
    for (int j = 2; j < i; j++)
      o &= (i % j) != 0;
    if (o)
      pr.push_back(i);
  }
  ll ans = -1;
  read(a);
  for (int i = 0; i < (1 << (sz(pr))); i++) {
    ll v = 1, o = 1;
    for (int j = 0; j < sz(pr); j++)
      if (i >> j & 1)
        v *= (ll)pr[j];
    for (int j = 0; j < n; j++)
      o &= __gcd((ll)a[j], v) > 1;
    if (o) {
      if (ans < 0)
        ans = v;
      else
        ans = min(ans, v);
    }
  }
  print(ans);
}

int main() {
  FIO
  solve();
  // int t; read(t); while (t--) solve();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N = 100;
typedef long long ll;
int a[N], n, isnot[N];
vector<int>G[N];
int vis[N];
int b[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,  31, 37, 41, 43, 47 };
ll ans = LLONG_MAX;
void dfs(int p, ll sum) {
    if (p >= 15) {
        for (int i = 1; i <= n; i++) {
            if (__gcd(sum, 1ll*a[i]) == 1) {
                return;
            }
        }
        ans = min(ans, sum);
        return;

    }
    dfs(p + 1, sum * b[p]);
    dfs(p + 1, sum);
}

int main() {

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        //a[i] = i + 1;
       // sort(G[a[i]].begin(), G[a[i]].end());
    }
    dfs(0, 1);

    cout << ans << endl;
    return 0;
}

//2 3 5 7 11 13 17 19 23 29  31 37 41 43 47


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <iomanip>

#include <fstream>

using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

// セグ木

ll segnodenum;
vector<ll> segnode;

ll init_num=0;
ll func(ll x,ll y){
    return x+y;
}

void init(vector<ll> v){
    segnodenum=1;
    while(v.size()>segnodenum)segnodenum*=2;
    segnode.resize(2*segnodenum-1,init_num);
    rep(i,segnodenum-1,segnodenum*2-2){
        if(i-(segnodenum-1)<v.size()){
            segnode[i]=v[i-(segnodenum-1)];
        }else{
            segnode[i]=init_num;
        }
    }
    for(ll i=segnodenum-2;i>=0;i--){
        segnode[i]=func(segnode[2*i+1],segnode[2*i+2]);
    }
}

void update(ll x,ll y){ //v[x]をyに変更する
    segnode[x+segnodenum-1]=y;
    ll next=x+segnodenum-1;
    while(next>0){
        next=(next-1)/2;
        segnode[next]=func(segnode[2*next+1],segnode[2*next+2]);
    }
}

ll find(ll i,ll j,ll x,ll y,ll z){     //v[[i,j)]でのfuncの結果を出力する //segnode[x]に着目しているsegnode[x]が担当する範囲は[y,z); //最初はx=-1で
    if(x==-1) return find(i,j,0,0,segnodenum);
    if(j<=y || z<=i)return init_num;
    if(i<=y && z<=j)return segnode[x];
    return func(find(i,j,2*x+1,y,(y+z)/2),find(i,j,2*x+2,(y+z)/2,z));
}

int main(){fastio
    ll n,x;cin>>n>>x;
    vector<ll> v;
    rep(i,0,n-1){
        ll a;cin>>a;
        if(a!=x){
            v.pb(a);
        }
    }
    rep(i,0,(ll)v.size()-1){
        if(i==0){
            cout<<v[i];
        }else{
            cout<<" "<<v[i];
        }
    }
    cout<<endl;

    return 0;

}

#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
const int N=100011,mod=1000000007;
int dp[N][2],f[N][2],n;
inline signed iut(){
	rr int ans=0; rr char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
inline void print(int ans){
	if (ans>9) print(ans/10);
	putchar(ans%10+48);
}
inline signed mo(int x,int y){return x+y>=mod?x+y-mod:x+y;}
signed main(){
	n=iut();
	for (rr int i=1;i<=n;++i){
		rr int x=iut();
		if (i==1) dp[i][1]=x,f[i][1]=1;
		else{
			f[i][0]=f[i-1][1],dp[i][0]=mo(dp[i-1][1],mod-1ll*f[i][0]*x%mod);
			f[i][1]=mo(f[i-1][0],f[i-1][1]),dp[i][1]=mo(mo(dp[i-1][0],dp[i-1][1]),1ll*f[i][1]*x%mod);
		}
	}
	return !printf("%d",mo(dp[n][0],dp[n][1]));
}


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

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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

const int inf = int(1e9);
const ll INF = ll(1e16);
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

ll bp(ll a, ll n, ll cm){
  ll r = 1;
  while(n){
    if(n & 1) r = r * a % cm;
    a = a * a % cm;
    n >>= 1;
  }
  return r;
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());

    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
void solve(){

  ll n, C;
  cin >> n >> C;
  ll a[n], b[n], c[n];
  vector<pll> v;
  rep(i, n){
    cin >> a[i] >> b[i] >> c[i];
    v.pb({a[i], c[i]});
    v.pb({b[i] + 1, -c[i]});
  }
  sort(all(v));
  ll S = 0;
  ll curSum = 0;
  rep(i, sz(v) - 1){
    curSum += v[i].S;
    ll delta = v[i + 1].F - v[i].F;
    S += min(curSum, C) * delta;
  }
  cout << S;
}

int main()
{
  // freopen("input.txt", "r", stdin)
  // freopen("output.txt", "w", stdout);
    Red;
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i){
      solve();
    }
    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;

void solve(int tt) {
    // cout<<"Case #"<<tt<<": ";

}

int n,m,k;

vi c[101];

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

    cin>>n>>k>>m;
    c[1] = vi(k + 1, 1);
    rep(i,2,n+1) {
    	int ub=k*i*(i+1)/2+1;
    	if(i>n+1-i) mini(ub,(int)c[n+1-i].size());
    	c[i] = vi(ub);

    	rep(j,0,c[i-1].size()) {
    		if(c[i-1][j]==0) continue;
    		rep(cc,0,k+1) {
    			if(j+cc*i >= c[i].size()) break;
    			c[i][j+cc*i]+=c[i-1][j];
    			if(c[i][j+cc*i]>=m) c[i][j+cc*i]-=m;
    		}
    	}
    }
    // rep(i,1,n+1) print(i,c[i]);

    vi res(n+1);
    res[1]=k;
    res[n]=k;
    rep(i,2,n) {
    	if(i>n+1-i) break;
    	ll tmp=0;
    	int n1=c[i-1].size();
    	int n2=c[n-i].size();
    	rep(j,0,min(n1,n2)) {
    		tmp=(tmp+(ll)c[i-1][j]*(ll)c[n-i][j]%m)%m;
    	}
    	res[i]=(tmp*(k+1)%m+m-1)%m;
    	res[n+1-i]=res[i];
    }
    rep(i,1,n+1)cout<<res[i]<<endl;

    return 0;
}


#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

bool ok(int n){
    for(int p : {10, 8}) {
        int cn = n;
        while (cn) {
            if (cn % p == 7) return false;
            cn /= p;
        }
    }
    return true;
}

ll extgcd(ll a, ll b, ll &x, ll &y){
    if(a < b) swap(a, b);
    ll d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>Q;
    rep(_, Q){
        cin>>N>>M>>K;
        K %= N;
        K %= N;
        if(K == 0){
            cout<<-1<<endl;
            continue;
        }
        M = N - M;

        ll x, y;
        ll g = extgcd(N, K, x, y);
        if(M%g != 0){
            cout<<-1<<endl;
            continue;
        }
        K /= g; M /= g; N /= g;
        if(x<0) x += N;
        if(y<0) y += N;
        if(K*x == 1) M *= x;
        else M *= y;
        cout<<M%N<<endl;
        /*
        sm = M / mkgcd;
        sk = K / mkgcd;
        ll g = extgcd(max(N, sk), min(N, sk), x, y);
        if(g != 1){
            cout<<-1<<endl;
        }else{
            if(N > sk) swap(x, y);
            //cout<<x<<' '<<y<<endl;
            if(x < 0) x += N;
            assert((sk * x)%N == 1);
            (sm *= x)%=N;
            ll res = N - sm;
            g = extgcd(max(N, K), min(N, K), x, y);
            res %= (N / g);
            cout<<res<<endl;
        }
         */
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 100000000000000
#define mod 998244353

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))

#define loop(i,n)  for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i++)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define makeuniq(v) v.resize(unique(all(v)) - v.begin()); //only uniq element in vector after this
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>

#define pii pair<lli,lli>

#define vi vector<lli>
#define vvi vector<vi>
#define vpi vector<pii>
#define vbool vector<bool>

#define seti set<lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename Head>
void print(Head&& head)
{
    cout<<head<<endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail)
{
    cout<<head<<" ";
    print(tail...);
}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

/*
1D vector -  vi dp(n,value);
*/

ll modmul(ll a, ll b,lli MOD =  mod) {
    return ((a%MOD) * (b%MOD)) % MOD;
}

ll modadd(ll a , ll b){
    return((a%mod)+(b%mod)+mod)%mod;
}

ll modsub(ll a , ll b){
    return((a%mod) - (b%mod) + mod)%mod;
}

lli fastexpo(lli a,lli b ,lli MOD = mod){
    a = a%MOD;
    //b = b%(mod-1); // if mod is prime then only
    lli ans=1;
    while(b){
        if(b&1)
            ans=(ans*1ll*a)%MOD;
        a=(a*1ll*a)%MOD;
        b=b/2;
        }
    return ans;
 }

lli phi(lli n)
{
    lli result = n;
    for (lli p = 2; p * p <= n; ++p) {
        if (n % p == 0) {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}

int main(){
fastio
lli t=1;
cin>>t;
while(t--) {
    lli n,s,k;
    cin>>n>>s>>k;
//    we have to find i such that (k*i)%n = n-s;
// on compaaring ax %n = b where a , b , n are knows  => x = b.a^(-1) %n and a^(-1)%n = a^(phi(n)-1)%n
//we have a = k , x = i , n = n , b = n-s;
//https://cp-algorithms.com/algebra/linear_congruence_equation.html
//https://cp-algorithms.com/algebra/module-inverse.html
lli a = k;
lli b = n-s;
    if(gcd(a,n)==1)
    {
        lli ans = modmul(b,fastexpo(a,phi(n)-1,n),n);
        print(ans);
    }
    else
    {
        lli g = gcd(a,n);
        if(b%g)
            print(-1);
        else
        {
            a/=g;
            b/=g;
            n/=g;
            lli ans = modmul(b,fastexpo(a,phi(n)-1,n),n);
            print(ans);
        }
    }
}
return 0;
}


#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main() {
	int64_t n;
	scanf("%" SCNd64, &n);

	int cnt[3] = { 0 };
	while (n) {
		cnt[n % 10 % 3]++;
		n /= 10;
	}
	int cur = (cnt[1] + 2 * cnt[2]) % 3;
	int k = cnt[0] + cnt[1] + cnt[2];
	int res;
	if (!cur) res = 0;
	else if (cur == 1) {
		if (cnt[1]) {
			if (k == 1) res = -1;
			else res = 1;
		} else {
			if (k == 2) res = -1;
			else res = 2;
		}
	} else {
		if (cnt[2]) {
			if (k == 1) res = -1;
			else res = 1;
		} else {
			if (k == 2) res = -1;
			else res = 2;
		}
	}
	printf("%d\n", res);

	return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
#include <cmath>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INFI = 1001001001;
const ll INFL = 1001001001001001001;
const ll MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, in, fn) for (ll i = in; i <= fn; i++)
#define debug(x) cerr << #x << ": " << x << endl

void solve(std::string S)
{
    ll ans = 0;
    rep(i, 12)
    {

        if (S[i] == 'Z' && S[i + 1] == 'O' && S[i + 2] == 'N' && S[i + 3] == 'e')
            ans++;
    }
    cout << ans << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

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

const int mod = 998244353;

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

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

const int inv2 = 499122177;

int f(int x)
{
    return mul(mul(x, x + 1), inv2);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    cout << mul(f(a), mul(f(b), f(c))) << "\n";
    return 0;
}

#include <bits/stdc++.h>
#define M_PI           3.14159265358979323846  /* pi */
using namespace std;
using  ll = long long;

int main() {
	ll mod = 998244353;
	ll A, B, C;
	cin >> A >> B >> C;

	ll a = (((A % mod) * (A % mod + 1)) / 2) % mod;
	ll b = (((B % mod) * (B % mod + 1)) / 2) % mod;
	ll c = (((C % mod) * (C % mod + 1)) / 2) % mod;

	ll result;

	result = a * b % mod * c % mod;
	cout << result << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll L, R;
    cin >> L >> R;

    ll ans = 0;

    vector<ll> G(R+1);
    for(ll g = R; g >= 2; g--){
        /// [left, right)
        //ll left = (L + g - 1) / g;
        //ll left = L/g + (L % g != 0);
        ll left = (L-1)/g;
        ll right = R / g;

        //ll n = (right - left + 1) * (right - left + 1);
        ll n = (right - left) * (right - left);
        for(ll k = 2*g; k <= R; k += g){
            n -= G[k];
        }

        G[g] = n;

        //prllf("%d: %d, %d, %lld\n", g, left, right, n);

        ans += n;
    }

    //cout << ans << endl;

    for(ll x = L; x <= R; x++){
        if(x == 1) continue;
        for(ll y = x; y <= R; y += x){
            if(x == y) ans -= 1;
            else ans -= 2;
        }

        //ans -= R/x * 2 - 1;
    }

    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(10,1e7);

//DEBUG FUNCTIONS START
#define cerr cout
void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
//#define deb(x...) cerr << "[" << #x << "] = "; _print(x)
#define deb(x...)  _print(x)
#else
#define deb(x...)
#endif
// DEBUG FUNCTIONS END

const int N = 2e5 + 5;

void solve(){

	int n;
	cin >> n;

	vi a(n);
	rep(i,0,n)
		cin >> a[i];

	int ans = 0, p0 = 0, p1 = 0;

	rep(i,0,n){
		ans += i * a[i] * a[i] + p0 - 2 * a[i] * p1;
		p0 += a[i] * a[i];
		p1 += a[i];
	}

	cout << ans;

}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b % mod, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<bitset<100>> edge(N);
    for(unsigned long i{0}; i < N; ++i){
        string S;
        cin >> S;
        for(unsigned long j{0}; j < N; ++j)edge[j][i] = (S[j] == '1');
        edge[i][i] = true;
    }
    for(unsigned long i{0}; i < N; ++i)for(auto& j : edge)for(unsigned long k{0}; k < N; ++k)if(j[k])j |= edge[k];
    long double ans{0};
    for(const auto& i : edge)ans += 1.0L / i.count();
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

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

const int N=101;

int n,g[N][N],C[N][N],vis[N],to[N];

char s[N][N];

void dfs(int x)
{
    if(vis[x])
        return;
    vis[x]=1;
    for(int i=1;i<=n;i++)
        if(g[x][i])
            dfs(i);
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            g[i][j]=s[i][j]-'0';
    for(int i=1;i<=n;i++)
    {
        fill(vis+1,vis+n+1,0);
        dfs(i);
        for(int j=1;j<=n;j++)
            to[j]+=vis[j];
    }
    double ans=0;
    for(int i=1;i<=n;i++)
        ans+=1.0/to[i];
    printf("%.10lf\n",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define mp make_pair
#define pll pair<lli,lli>

int main(){
	int n, s, d;
	cin >> n >> s >> d;
	while(n--){
		int x, y;
		cin >> x >> y;
		if(x < s && y > d){
			cout << "Yes" ;
			return 0;
		}
	}
	cout << "No";
	return 0;
}

#include<bits/stdc++.h>
#include <iostream>
//#include <boost/math/common_factor.hpp>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define all(x) x.begin(), x.end()
#define reg(i,x) for(ll i=0;i<x;i++)
#define regi(i,a,x) for(ll i=a;i<x;i++)
#define rev(i,n) for(ll i=n-1;i>0;i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define watch(x) cout << (#x) << " is " << (x) << endl
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//const ll INF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
ll MAXN=1e9;
const int inf = (int)1e18;
const int N=(int)1e6+7;
#define print(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
/*vi l(1e4+1);
vi adj[1e5+1];
bool vis[1e5+1];
int leader(int v)
{
    if(l[v]!=v) l[v]=leader(l[v]);
    return l[v];
}
int unite(int u,int v)
{
    int v1=leader(u);
    int v2=leader(v);
    l[v1]=v2;
}*/
/*bool sortbysec(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}*/
int fact(int n)
{
    // single line to find factorial
    return (n==1 || n==0) ? 1: n * fact(n - 1);
}

bool comp(pair<ll,ll> &a, pair<ll,ll> &b)
{
    return (2*a.first+a.second > 2*b.first+b.second);
}
/*bool check(ll n)
{
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0) return true;
        if((n/i)%2!=0) return true;
    }
    return false;
}*/
int main()
{
    ll n,s,d;
    cin>>n>>s>>d;
    vpll v(n);
    bool ans=false;
    reg(i,n)
    {
        int x,y;
        cin>>x>>y;
        if(x<s && y>d) ans=true;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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

// k番目に小さな要素
ll select(vector<ll> &a, ll k) {
  for (ll l = 0, r = a.size()-1; l <= r; ) {
    ll p = a[(l+r)/2];
    ll i = l-1, j = r+1;
    while (1) {
      while (a[++i] < p);
      while (a[--j] > p);
      if (i >= j) break;
      swap(a[i], a[j]);
    }
    if (k == i-l) return a[i];
    else if (k < i-l) { r = i-1; }
    else if (k > i-l) { k -= (i-l+1); l = j+1; }
  }
  return -99999999; // k < 0 || k >= n
}

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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

// ２項係数
/*
ll ncrmod(ll n, ll r)
{
  ll ans;

  return ans;
}
*/

// 繰り返し二乗法
ll powmod(int a, int n){//aのn乗を計算します(MOD)。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = (x*a) % MOD;
    }
    a = (a*a) % MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  vector<ll> a(N + 1);

  rep1(i, N) {
	ll cnt = 0;
	ll mx = 0;
	//	cnt = (i == 1) ? 0 : 1;
	for(ll j = 1; j * j <= i; j++) {
	  if(i % j == 0) {
		chmax(mx, a[j]);
		if(j* j != i) 		chmax(mx, a[i / j]);
	  }
	}
	a[i] = mx + 1;
	//cout << "(" << i << ")" << cnt << " ";
	cout << a[i] << " ";

  }

  cout << "\n";

}

int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}

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

int main()
{
    int n;
    cin >> n;
    cout << (n + 99) / 100 << endl;
    return 0;
}


#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

const int MX = 200005;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return sol;
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int x[1005], y[1005];
void solve()
{
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> x[i] >> y[i];
	}
	int sol = 0;
	for (int i = 0;i < n - 1;i++)
	{
		for (int j = i + 1;j < n;j++)
		{
			int a = x[j] - x[i];
			int b = y[j] - y[i];
			if (abs(b)<=abs(a))
			{
				sol++;
			}
		}
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define rep(i,n) for (ll i = 0;i<(n);++i)
#define all(v) v.begin(),v.end()

template <typename T>bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false;}
template <typename T>bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false;}
vector<long long> divisor(long long n){vector<long long> res;long long i = 1;while (i*i<=n){if(n%i==0){res.push_back(i);}i++;}if(res.size()==0)return res;for(long long i = res.size()-1-(res.back()*res.back()==n);i>=0;--i){res.push_back(n/res[i]);}return res;}
long long safe_mod(long long x,long long m){x%=m;if(x<0){x+=m;}return x;}
long long modpow(long long x,long long n,long long mod){long long ans=1;while(n>0){if(n&1){ans*=x;ans%=mod;}n>>=1;x*=x;x%=mod;}return ans;}
long long intpow(long long x,long long n){long long ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
template<typename T>T intpow(T x,T n){T ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
vector<pair<long long,long long>> factor_lst(long long n){vector<pair<long long,long long>> factor_lst;long long d=2;while(d*d<=n){if(n%d==0){long long num=0;while(n%d==0){num+=1;n/=d;}factor_lst.push_back({d,num});}d+=1;}if(n!=1){factor_lst.push_back({n,1});}return factor_lst;}
#define Uniq(a) sort(all(a));a.erase(unique(all(a)),end(a))

int msb(int x){return x==0 ? -1:32-__builtin_clz(x);}//1-indexed
int lsb(int x){return x==0 ? 32:__builtin_ctz(x)+1;}//1-indexed
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(long long x){return __builtin_popcount(x);}

bool ingrid(int i,int j,int H,int W){
    return 0<=i&&i<H&&0<=j&&j<W;
}

const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
template<typename T> void print(vector<T> &v){for(int i=0;i<v.size();++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T> void print(T* v,int size){for(int i=0;i<size;++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T,typename S>void print(pair<T,S>&p){cout<<p.first<<" "<<p.second<<endl;}
const ll LINF=4*1e18;
const ll MINF=5*1e15;
const int INF=2*1e9;
const ld PI=acosl(-1);

void Main();
int main(){cout<<fixed<<setprecision(15);Main();}

void Main(){

ll N;
cin>>N;
ll ans=LINF;
rep(b,60){
    chmin(ans,(N>>b)+b+(N&((1LL<<b)-1)));
}

cout<<ans<<endl;
}


#include <stdio.h>
#define M 5000
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib>
#include <math.h>
#include<cstdio>
#include<cstring>
#include <math.h>
#define vi v(n) vector<ll> v(n);
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll fact[200005];
ll invfact[200005];
const ll N=200005;
const ll MOD=998244353;
ll Power(ll base , ll e)
{
    if(e == 0) return 1;
    ll ans = base; e--;
    while(e)
  {
        if(e & 1) ans = (((ans%MOD) * (base%MOD)) %MOD+MOD)%MOD;
        base = (((base%MOD) * (base%MOD)) %MOD+MOD)%MOD;
        e >>= 1;
  }
  return (ans+MOD) %MOD;
}

ll modinv(ll k)
    {
        return Power(k, MOD-2);
    }

void precompute()
    {
        fact[0]=fact[1]=1;
        for(ll i=2;i<N;i++)
        {
            fact[i]=fact[i-1]*i;
            fact[i]%=MOD;
        }
        invfact[N-1]=modinv(fact[N-1]);
        for(ll i=N-2;i>=0;i--)
        {
            invfact[i]=invfact[i+1]*(i+1);
            invfact[i]%=MOD;
        }
    }

    ll nCr(ll x, ll y)
    {
        if(y>x)
            return 0;
        ll num=fact[x];
        num*=invfact[y];
        num%=MOD;
        num*=invfact[x-y];
        num%=MOD;
        return num;
    }

int main(){
ll n,m;
cin>>n>>m;
vector<ll> dp(m+1,0);
ll times=2;
precompute();
ll ans=0;
fo(i,m){
    ans++;
    dp[i+1]=1;
}
bool ok=true;
while(ok&&times<=n){
    ok=false;
    vector<ll> dp2(m+1,0);
    fo(i,m+1) dp2[i]=0;
    FOR(i,1,m){
        for(int j=i+i;j<=m;j=j+i){
            if(dp[i]){
            dp2[j]+=dp[i];
            ok=true;
            }
        }
    }
   // dbg3(times,accumulate(all(dp2),0),nCr(n-1,times-1));
    ll val=(accumulate(all(dp2),0))%MOD;
    val=((val%MOD)*(nCr(n-1,times-1)%MOD))%MOD;
    ans=(ans+val)%MOD;
    dp=dp2;
    times++;
}
cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;

const int mod = 200;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n) a[i] = a[i] % mod;
    vector<vector<int>> dp(n+1,vector<int>(200));
    vector<vector<int>> pa(200,vector<int>());
    rep(i,n){
        if(pa[a[i]].size() > 0) {
            cout << "Yes" << endl;
            cout << "1 " << i+1 << endl;
            cout << pa[a[i]].size () << " ";
            rep(pi,pa[a[i]].size()) cout << pa[a[i]].at(pi)+1 << " ";
            cout << endl;
            return 0;
        }
        // dp[i+1][a[i]] = 1;
        pa[a[i]].push_back(i);
        rep(j,200){
            auto output = [&](int fr, int to, int add_choice = -1) {
                if (pa[fr].size() == 0) return false;
                if (fr == a[i]) return false;
                if (pa[fr].size()>0 && pa[fr].back()==i) return false;
                if (pa[to].size() == 0) {
                    if(add_choice != -1)
                        pa[to] = pa[fr];
                        pa[to].push_back(add_choice);
                    return false;
                }
                cout << "Yes" << endl;
                cout << pa[to].size() << " ";
                rep(pi,pa[to].size()) cout << pa[to].at(pi)+1 << " ";
                cout << endl;

                cout << pa[fr].size() + 1 << " " ;
                rep(pi,pa[fr].size()) cout << pa[fr].at(pi)+1 << " ";
                cout << i+1 << endl;

                return true;
            };
            // if (output(j, j) || output(j, (j + a[i]) % mod, i)) return 0;
            if (output(j, (j + a[i]) % mod, i)) return 0;
            // dp[i+1][j] += dp[i][j];
            // dp[i+1][(j+a[i])%mod] += dp[i][j];
        }
    }
    cout << "No" << endl;
}

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

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(),(a).rend())
#define ll long long
#define pb(a) push_back(a)

#define PRINTV(v) {for(ll deB=0; deB<(v).size(); deB++){cout << (v)[deB] << " ";}cout << endl;}

int main(){

	ll N;
	cin >> N;

	vector<ll> C(N+1);
	vector<ll> A(N);
	vector<ll> B(N);

	REP(i,N) cin >> C[i+1];
	REP(i,N){
		cin >> A[i];
		cin >> B[i];
	}

	vector< vector<ll> > graph(N+1);
	REP(i,N){
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}

	vector<ll> ans(N+1,0);
	vector<ll> color(1000000,0);
	vector<ll> arrived(N+1,0);
	stack<ll> root;
	root.push(1);
	while(!root.empty()){
		ll node = root.top();
		//fprintf(stderr, "node:%d(size:%d)(color:%d)\n", node, root.size(), C[node]);
		if(arrived[node] == 0){
			arrived[node] = 1;
			if(color[C[node]] == 0){
				ans[node] = 1;
			}
			color[C[node]]++;
			REP(i, graph[node].size()){
				ll next = graph[node][i];
				if(arrived[next] == 0){
					//fprintf(stderr, "push:%d\n", graph[node][i]);
					root.push(graph[node][i]);
				}
			}
		}else{
			root.pop();
			color[C[node]]--;
		}
	}

	for(int i=1; i<=N; i++){
		if(ans[i] == 1){
			cout << i << endl;
		}
	}

	return 0;

abnormal:
	cout << "No" << endl;
	return 0;
}


#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005;
int n, a[MX], b[MX], aux[MX], p[MX], vis[MX];
vii res;

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

	cin >> n;
	forn (i, n) cin >> a[i + 1];
	forn (i, n) cin >> aux[i + 1];
	forn (i, n) cin >> p[i + 1];

	for (int i = 1; i <= n; i++)
		b[i] = aux[p[i]];

	for (int i = 1; i <= n; i++) if (!vis[i]) {
		vi v;
		int u = i;

		while (!vis[u]) {
			vis[u] = 1;
			v.pb(u);
			u = p[u];
		}

		if (v.size() == 1) continue;

		for (int u : v)
			if (b[u] >= a[u]) {
				cout << -1 << endl;
				return 0;
			}

		int ind = 0;
		forn (j, v.size())
			if (a[v[j]] > a[v[ind]])
				ind = j;

		forn (j, (int)v.size() - 1) {
			int to = (ind + j + 1) % (int)v.size();
			res.pb({v[ind], v[to]});
		}
	}

	cout << res.size() << endl;
	for (ii &p : res)
		cout << p.fi << " " << p.se << endl;

	return 0;
}

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

// clang-format off
#define forn(i, x, y) for (int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
#define all(v) v.begin(), v.end()
// clang-format on

using VI = vector<int>;

class UF
{
    vector<int> root;

public:
    UF(int n)
    {
        root.resize(n);
        forn(i, 0, n) root[i] = i;
    }

    int find(int x)
    {
        while (x != root[x])
            x = root[x] = root[root[x]];
        return x;
    }

    int connect(int x, int y)
    {
        return root[find(x)] = find(y);
    }
};

int N;
int X[100], Y[100];

bool check(double r)
{
    UF uf(N + 2);
    forn(i, 0, N)
    {
        if (Y[i] - 2 * r < -100)
            uf.connect(N, i);
        if (Y[i] + 2 * r > 100)
            uf.connect(N + 1, i);
    }

    forn(i, 0, N) forn(j, 0, N)
    {
        if (hypot(X[i] - X[j], Y[i] - Y[j]) < 2 * r)
            uf.connect(i, j);
    }
    return uf.find(N) != uf.find(N + 1);
}

int main()
{
    IOS;
    cin >> N;
    forn(i, 0, N) cin >> X[i] >> Y[i];

    double l = 0.0, r = 100.0, m;
    forn(i, 0, 100)
    {
        m = (l + r) / 2;
        if (check(m))
            l = m;
        else
            r = m;
    }
    cout << fixed << setprecision(10) << l << endl;

    return 0;
}


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

int main()
{
    ll X, Y, ans = 0;
    ll A, B;
    cin >> X >> Y >> A >> B;

    while ((double)X*A<=2e18 && X*A<Y && X*A<= X+B)
    {
            X *= A;
            ans++;
    }

    ans += (Y - X - 1) / B;

    cout << ans << endl;
    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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int 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;
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
void solve(int cntt){
int x , y , a , b;
cin>>x>>y>>a>>b;
int l = (y-1)/x;
int val = 1;
int cnt = 0;
int ans = 0 ;
for(int i = 0 ; i < 50 ; i++){
	  if(val*a < l){
	  	  cnt++;
	  	  val = val*a;
	  	  ans = max(cnt + max(0LL , (y-1-x*val)/b), ans);
	  }
	  else if(val*a == l){
	  	 cnt++;
	  	 val = val*a;
	  	 ans = max(cnt + max(0LL,  (y-1-x*val)/b), ans);
	  	 break;
	  }
}

cout<<max({ans , cnt ,(y-1-x)/b})<<endl;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
t = 1;
int l = 0;
while(t--){
	l++;
solve(l);
}
return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
#define int long long

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
const int INF=1e9+1;

signed main(){
  int n;cin>>n;
  vector<int> l(n,INF),r(n,-INF);
  REP(i,n){
    int x,c;cin>>x>>c;c--;
    chmin(l[c],x);
    chmax(r[c],x);
  }
  int tmpl=0,tmpr=0,nowl=0,nowr=0;
  REP(i,n){
    if(l[i]>r[i])continue;
    int kaka;
    kaka=min(abs(nowl-r[i])+r[i]-l[i]+tmpl,abs(nowr-r[i])+r[i]-l[i]+tmpr);
    tmpr=min(abs(nowl-l[i])+r[i]-l[i]+tmpl,abs(nowr-l[i])+r[i]-l[i]+tmpr);
    tmpl=kaka;
    nowl=l[i],nowr=r[i];
  }
  cout<<min(tmpl+abs(nowl),tmpr+abs(nowr))<<endl;
}

#include <bits/stdc++.h>

using namespace std;

const int N=2e5+10;

long long dis(long long x,long long y){
    return abs(x-y);
}

int main()
{

    int n;
    scanf("%d",&n);
    vector<int> lft(n+1,1e9),rit(n+1,-1e9),C;
    for(int i=0;i<n;++i){
        int x,c;
        scanf("%d%d",&x,&c);
        lft[c]=min(lft[c],x);
        rit[c]=max(rit[c],x);
        C.push_back(c);
    }
    lft[0]=rit[0]=0;

    sort(C.begin(),C.end());
    C.erase(unique(C.begin(),C.end()),C.end());
    C.push_back(0);

    vector<vector<long long> >dp(2,vector<long long>(n+1,0));

    dp[0][C[0]]=dis(0,rit[C[0]])+dis(rit[C[0]],lft[C[0]]);
    dp[1][C[0]]=dis(0,lft[C[0]])+dis(lft[C[0]],rit[C[0]]);

    for(int i=1;i<C.size();++i){
        dp[0][C[i]]=min(dp[0][C[i-1]]+dis(lft[C[i-1]],rit[C[i]])+dis(rit[C[i]],lft[C[i]])
                        ,dp[1][C[i-1]]+dis(rit[C[i-1]],rit[C[i]])+dis(rit[C[i]],lft[C[i]]));
        dp[1][C[i]]=min(dp[0][C[i-1]]+dis(lft[C[i-1]],lft[C[i]])+dis(rit[C[i]],lft[C[i]])
                        ,dp[1][C[i-1]]+dis(rit[C[i-1]],lft[C[i]])+dis(rit[C[i]],lft[C[i]]));
    }

    printf("%lld\n",min(dp[0][0],dp[1][0]));

    return 0;
}