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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

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

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll LINF = 1e18;

void fail(){
  cout << "No" << endl;
  exit(0);
}

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

  int n; cin>>n;
  vc<vc<int>> c(n, vc<int>(n));
  rep(i,n) rep(j,n) cin>>c[i][j];

  vc<int> a(n), b(n);
  int minb=INF;
  rep(i,n){
    b[i]=c[i][0];
    chmin(minb,b[i]);
  }
  int mina=INF;
  rep(j,n){
    a[j]=c[j][j]-b[j];
    chmin(mina,a[j]);
  }

  rep(i,n){
    rep(j,n){
      if(b[i]+a[j]!=c[i][j]) {
        fail();
      }
    }
  }

  if(mina<0){
    if(abs(mina)>abs(minb)) fail();
    int x=abs(mina);
    rep(i,n) a[i]+=x, b[i]-=x;
  }

  cout<<"Yes"<<endl;
  swap(a,b);
  rep(i,n) cout<<a[i]<<' ';
  cout<<endl;
  rep(i,n) cout<<b[i]<<' ';
  cout<<endl;

}

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pll pair<long long, long long>
#define f first
#define s second
#define debug cout<<"here\n"
#define MOD 1000000009

using namespace std;
const int MAXN = 2e6 + 5;

int where[MAXN];

void solve(){
	int n; cin>>n;
	for(int i=0; i<2*n; i++) where[i] = i;
	string s,ss; cin>>s;
	ss = s;
	int q; cin>>q;
	bool x = 0;
	while(q--){
		int ct,a,b; cin>>ct;
		if(ct == 1){
			cin>>a>>b; a--; b--;
			swap(where[(a+n*x)%(2*n)], where[(b+n*x)%(2*n)]);
		}
		else{
			x ^= 1;
			cin>>a>>b;
		}
	}
	for(int i=0; i<2*n; i++) ss[i] = s[where[i]];
	if(x){
		for(int i=n; i<2*n; i++) cout<<ss[i];
		for(int i=0; i<n; i++) cout<<ss[i];
	}
	else{
		cout<<ss;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0);
	cout<<fixed<<setprecision(12);

	int t =1; //cin>>t;
	for(int i=1; i<= t; i++){
		solve();
		cout<<"\n";
	}

	return 0;
}


//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
//using mint = modint998244353;
//using mint = modint1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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; }

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  string G="atcoder";
  ll T; cin>>T;
  rep(_,T){
    string S; cin>>S;
    ll N=S.size();
    auto MS=S;
    sort(MS.rbegin(),MS.rend());
    if(G>=MS) {cout<<-1<<'\n'; continue;}
    ll ans=INF;
    vector<ll> vec(7,-1);
    rep(i,N){
      rep(j,7){
        if(S[i]==G[j]&&vec[j]==-1) vec[j]=i;
      }
    }
    //for(auto v:vec) cout<<v<<'\n';
    rep(i,8){
      ll sans=0;
      rep(j,i){
        if(vec[j]==-1) goto OUT;
        sans+=abs(vec[j]-j);
      }
      int piyo=0;
      rep(j,N){
        int hoge=0;
        rep(k,i){
          if(j==vec[k]) hoge=1;
        }
        if(hoge) continue;
        if(S[j]>(i==7?'a'-1:G[i])){
          sans+=abs(j-i);
          piyo=1;
          //cout<<i<<' '<<j<<'\n';
          break;
        }
      }
      //cout<<i<<' '<<sans<<'\n';
      if(piyo) chmin(ans,sans);
    }
    OUT:;

    cout<<ans<<'\n';
  }
  return 0;
}

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

int main(void)
{
    string X = "atcoder";
    long long T;
    cin >> T;
    for (long long i = 0; i < T; i++)
    {
        string S;
        cin >> S;
        if (S > X)
        {
            cout << 0 << endl;
            continue;
        }
        else if (S == "a" || S == "aa")
        {
            cout << -1 << endl;
        }
        else if (S[1] != 'a')
        {
            cout << 1 << endl;
            continue;
        }
        else
        {
            for (long long j = 2; j < S.size(); j++)
            {
                if (S[j] > 't')
                {
                    cout << j-1 << endl;
                    break;
                }
                else if (S[j] != 'a')
                {
                    cout << j << endl;
                    break;
                }
                if (j == S.size()-1)
                {
                    cout << -1 << endl;
                    break;
                }
            }
        }
    }
}


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

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll dp[1111][1111],a[1111],b[1111];

int main(void){
	int i,j,n,m;
	std::fill(dp[0],dp[1111],INFLL);
	dp[0][0] = 0ll;
	std::cin >> n >> m;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	for(i=0; i<m; ++i){
		std::cin >> b[i];
	}
	for(i=0; i<=n; ++i){
		for(j=0; j<=m; ++j){
			if(i<n){
				dp[i+1][j] = std::min(dp[i+1][j],dp[i][j]+1);
			}
			if(j<m){
				dp[i][j+1] = std::min(dp[i][j+1],dp[i][j]+1);
			}
			if(i<n && j<m){
				dp[i+1][j+1] = std::min(dp[i+1][j+1],dp[i][j]+((a[i]==b[j])?0:1));
			}
			// std::cout << i << " " << j << " " << dp[i][j] << std::endl;
		}
	}
	std::cout << dp[n][m] << std::endl;
	return 0;
}

// Problem: E - Sequence Matching
// Contest: AtCoder - AtCoder Beginner Contest 185
// URL: https://atcoder.jp/contests/abc185/tasks/abc185_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rp(i, s, e) for (ll i = s; i <= e; i++)
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define pq_max priority_queue<ll>
#define pq_min priority_queue<ll, vi, greater<ll>>
#define printv(v)         \
    for (auto x : v)      \
        cout << x << " "; \
    cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) (ll) x.size()
#define ff first
#define ss second
#define I(a)          \
    for (auto &x : a) \
        cin >> x;
#define iin insert
#define log(args...)                             \
    {                                            \
        string _s = #args;                       \
        replace(_s.begin(), _s.end(), ',', ' '); \
        stringstream _ss(_s);                    \
        istream_iterator<string> _it(_ss);       \
        err(_it, args);                          \
    }
#define logarr(arr, a, b)            \
    for (int z = (a); z <= (b); z++) \
        cout << (arr[z]) << " ";     \
    cout << endl;                    \
    using namespace std;
using namespace std;

// vs tokenizer(string str,char ch) {std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;}

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const ll nax = 1e3 + 5;
ll dp[nax][nax], a[nax], b[nax];
ll n, m;
ll r(ll i, ll j)
{

    if (i == -1 && j == -1)
        return 0;
    if (i == -1)
        return j + 1;
    if (j == -1)
        return i + 1;

    ll &mem = dp[i][j];
    if (mem != -1)
        return mem;
    ll aa, bb, c;
    aa = (a[i] != b[j]) + r(i - 1, j - 1);
    bb = 1 + r(i, j - 1);
    c = 1 + r(i - 1, j);
    return mem = min({aa, bb, c});
}
void solve()
{
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    SET(dp, -1);
    cout << r(n - 1, m - 1);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))
#define inf           (int)(1e9)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int>
#define vpi           vector<pii>
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v) {
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

int sum(int n) {
	if(n <= 0) return 0;
	return n*(n+1)/2;
}

void solve() {
    int l, r;
    cin >> l >> r;
    int k = l*2-1;
    int s = max(k, l);
    int ans = 0;
    if(r >= s)ans = sum(r)-sum(s-1)-k*(r-s+1);
    cout << ans << endl;

}

signed main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    start = clock();

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    int test = 1;
    cin >> test;

    cout << fixed << setprecision(12);

    for(int i = 1; i <= test; ++i){
        solve();
    }

    cerr << time(start);
    return 0;
}

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

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = l + l;
    int y = r + 1;
    ll n = y - x;
    if (n < 0)
        cout << "0\n";
    else
    {
        ll ans = (n * (n + 1)) / 2;
        cout << ans << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, M;
    cin >> N >> M;
    lint P = (N + 1) / 2;
    vector<lint> H(N), W(M);
    rep(i, N) { cin >> H[i]; }
    rep(i, M) { cin >> W[i]; }
    sort(all(H));
    sort(all(W));

    lint odd = 0, even = 0;
    vector<lint> L_odd(N + 100, 0), L_even(N + 100, 0);
    rep(i, N) {
        if (i % 2 == 0) {
            L_even[i + 1] = L_even[i] + H[i];
            L_even[i + 2] = L_even[i] + H[i];
        } else {
            L_odd[i + 1] = L_odd[i] + H[i];
            L_odd[i + 2] = L_odd[i] + H[i];
        }
    }
    rep(i, N) {
        if (i % 2 == 0) {
            even += H[i];
        } else {
            odd += H[i];
        }
    }

    lint mi = LINF;
    for (int k = 0; k < M; k++) {
        lint add = W[k];
        int i    = upper_bound(all(H), add) - H.begin();

        // dd(add, i);
        // dd(L_odd[i], L_even[i]);
        // dd((even - L_even[i]), (odd - L_odd[i]));
        lint tmp;
        if (i % 2 == 1) {
            tmp = (L_odd[i] - L_even[i]) + add;
            // d(tmp);
            tmp += (even - L_even[i]) - ((odd - L_odd[i]));
        } else {
            tmp = (L_odd[i] - L_even[i]) - add +
                  ((even - L_even[i]) - (odd - L_odd[i]));
        }
        // d(tmp);
        if (tmp <= mi) { mi = tmp; }
    }

    cout << mi << endl;
    // dump(H);
    // dump(W);
    // dump(L_odd);
    // dump(L_even);
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
long H[2<<17];
long L[2<<17],R[2<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>H[i];
	H[N]=H[N+1]=-2e9;
	H[N+2]=H[N+3]=2e9;
	N+=4;
	sort(H,H+N);
	for(int i=2;i<N;i+=2)
	{
		L[i]=L[i-2]+H[i-1]-H[i-2];
	}
	for(int i=N-2;i>0;i-=2)
	{
		R[i]=R[i+2]+H[i+1]-H[i];
	}
	long ans=1e18;
	for(int i=0;i<M;i++)
	{
		int W;cin>>W;
		int id=lower_bound(H,H+N,W)-H;
		if(id%2==0)
		{
			ans=min(ans,L[id]+H[id]-W+R[id+1]);
		}
		else
		{
			ans=min(ans,L[id-1]+W-H[id-1]+R[id]);
		}
	}
	cout<<ans<<endl;
}


//
//  blank.cpp
//
//
//  Created by Sagar Singh on 17/12/20.
//

#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#define bug1( x )                   { cerr << (#x) <<"="<< x << endl; }
#define bug2( x , y )               { cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl; }
#define bug3( x , y , z )           { cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl; }
#define bug4( x , y , z , w)        { cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl; }
#define bug5( x , y , z , w ,p)     { cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl; }
#define bug6( x , y , z , w ,p , q) { cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl; }
#define bugn( x , n )               { cerr<<(#x)<<":";for(int i=0;i<n;i++)cout<<(#x)<<"["<<i<<"]:"<< x[i] << "    "; cout<<endl; }
#define bugnm( x , n , m )          { cerr<<(#x)<<endl;for(int i=0;i<n;i++){ cout<<"Row #"<<i<<":"; for(int j=0;j<m;j++) cout<<x[i][j]<<"     "; cout << endl;} }
typedef unsigned long long ul;
typedef long double ld;
typedef long long ll;
using namespace std;

template<typename T, typename K>
inline bool smax(T &x,K y){ return x < y ? x = y, true : false; }
template<typename T, typename K>
inline bool smin(T &x,K y){ return x > y ? x = y, true : false; }

int32_t main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a, b; cin >> a >> b;
    if( a == b ){
        cout << a << endl;
    }else{
        for(int i=0;i<3;++i){
            if( i != a && i != b ){
                cout << i << endl;
                return 0;
            }
        }
    }
}


#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rrep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fore(i,a) for(auto &i:a)
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; }

ll n, k;
ll a[805][805];

bool check(ll lim){
    ll thanlim[805][805];
    ll median = k*k/2+1;
    rep(i,0,n){
        rep(j,0,n){
            if(a[i][j] >= lim) thanlim[i][j] = 1;
            else thanlim[i][j] = 0;
        }
    }
    vector<vector<int> > s(n+1, vector<int>(n+1, 0));
    rep(i,0,n){
        rep(j,0,n){
            s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+thanlim[i][j];
        }
    }
    bool all_thanlim = true;
    rep(i,0,n-k+1){
        rep(j,0,n-k+1){
            ll cnt = s[i+k][j+k]+s[i][j]-s[i+k][j]-s[i][j+k];
            if(cnt < median) all_thanlim = false;
        }
    }
    return all_thanlim;
}

int main(){
    cin >> n >> k;
    rep(i, 0, n) rep(j, 0, n) cin >> a[i][j];
    ll inf = 1000000001;
    ll ok = 0, ng = inf;
    while (ok + 1 != ng) {
        int md = (ok + ng) / 2;
        if (check(md)) ok = md;
        else ng = md;
    }
    printf("%lld\n", ok);
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define int long long
#define sz(x) (ll)(x.size())
using namespace std;

const int mod = 1e9+7;

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

ll add()
{
    return 0;
}

template <typename T, typename... Types>
T add(T var1, Types... var2){
    return (((((ll)(var1)) % mod + (ll)(add(var2...))) % mod) + mod) % mod;
}

ll mul(){
    return 1;
}

template <typename T, typename... Types>
T mul(T var1, Types... var2){
    return (((ll)(var1)) % mod * (ll)(mul(var2...))) % mod;
}

const int inf = 1e18;

void solve(){
  int n,x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<vector<int>> dp_ways(n,vector<int>(2));
  vector<vector<int>> dp_val(n,vector<int>(2,-inf));

  int v1 = (x + a[n-1] - 1)/a[n-1];
  v1 *= a[n-1];
  v1 -= x;
  int v2 = v1 - a[n-1];

  dp_val[n-1][0] = v1;
  dp_ways[n-1][0] = 1;

  if (abs(v2) < a[n-1]) {
    dp_val[n-1][1] = v2;
    dp_ways[n-1][1] = 1;
  }

  for (int i = n-2; i >= 0; --i) {
    int high = a[i+1]/a[i];
    int low = -high;

    v1 = (x+a[i] - 1)/a[i];
    v1 *= a[i];
    v1 -= x;
    v2 = v1 - a[i];

    dp_val[i][0] = v1;

    // 0-0
    int req = (dp_val[i][0] - dp_val[i+1][0])/a[i];
    if (req > low and req < high) {
      dp_ways[i][0] += dp_ways[i+1][0];
    }

    // 1-1
    if (dp_val[i][1] != inf) {
      int req = (dp_val[i][0] - dp_val[i+1][1])/a[i];
      if (req > low and req < high) {
        dp_ways[i][0] += dp_ways[i+1][1];
      }
    }

    if (abs(v2) <  a[i]) {
      dp_val[i][1] = v2;

      int req = (dp_val[i][1] - dp_val[i+1][0])/a[i];
      if (req > low and req < high) {
        dp_ways[i][1] += dp_ways[i+1][0];
      }

      if (dp_val[i][1] != inf) {
        int req = (dp_val[i][1] - dp_val[i+1][1])/a[i];
        if (req > low and req < high) {
          dp_ways[i][1] += dp_ways[i+1][1];
        }
      }

    }

  }

  cout << dp_ways[0][1] + dp_ways[0][0] << "\n";

}

signed main(){
  fast;
  int test = 1;
  int i=1;
  while(test--){
    solve();
  }
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

template <int mod>
struct ModInt {
  int64_t x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
  int get() const { return x; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  using Mint = ModInt<int(1e9 + 7)>;
  int H, W;
  cin >> H >> W;
  string S[H];
  for (int i = 0; i < H; i++) cin >> S[i];
  Mint ans = 0;
  int u[H][W], l[H][W];
  int K = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      u[i][j] = 0;
      l[i][j] = 0;
      if (S[i][j] == '#') continue;
      u[i][j] = 1;
      l[i][j] = 1;
      K++;
      if (i > 0) u[i][j] += u[i - 1][j];
      if (j > 0) l[i][j] += l[i][j - 1];
    }
  }
  int d[H][W], r[H][W];
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      d[i][j] = 0;
      r[i][j] = 0;
      if (S[i][j] == '#') continue;
      d[i][j] = 1;
      r[i][j] = 1;
      if (i + 1 < H) d[i][j] += d[i + 1][j];
      if (j + 1 < W) r[i][j] += r[i][j + 1];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      int k = u[i][j] - 1 + d[i][j] - 1 + l[i][j] - 1 + r[i][j] - 1 + 1;
      ans += (Mint(2).pow(k) - 1) * Mint(2).pow(K - k);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin>>s;
    bool flag = true;
    for(int i = 0;i<s.length();i++){
        if(i&1){
            if(!isupper(s[i])){
                flag = false;
                break;
            }
        }
        else{
            if(!islower(s[i])){
                flag = false;
                break;
            }
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

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

ll mod = 1000000007;

int main() {
    ll N; cin >> N;
    ll base = 1,cnt = 0;
    ll ans = 2e18;
    rep(i,62){
        ans = min(ans,N/base+N%base+cnt);
        base *= 2; cnt++;
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair< ll, ll > Pi;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

int main() {
    ll H,W,N,M;
    cin >>H>>W>>N>>M;
    vector<ll>A(N),B(N),C(M),D(M);
    //vector<ll>A2(H),B2(N),C2(M),D2(M);

    vvl G(H,vl(W));
    vvl G1(H);
    vvl G2(W);
    vvl G3(H);
    vvl G4(W);
    rep(i,N){
        cin>>A[i]>>B[i];
        A[i]--,B[i]--;
        G1[A[i]].pb(B[i]);
        G2[B[i]].pb(A[i]);
        G[A[i]][B[i]]=1;
    }

    rep(i,M){
        cin>>C[i]>>D[i];
        C[i]--,D[i]--;
        G3[C[i]].pb(D[i]);
        G4[D[i]].pb(C[i]);
        G[C[i]][D[i]]=2;
    }
    rep(i,H){
        sort(all(G1[i]));
        sort(all(G3[i]));
    }

    rep(i,W){
        sort(all(G2[i]));
        sort(all(G4[i]));
    }
    ll ans=0;
    rep(i,H){
        rep(j,W){

            if(G[i][j]==2)continue;
            if(G[i][j]==1){
                ans++;
                continue;
            }
            bool flag=0;
            ll idx1 = lower_bound(all(G1[i]),j)-G1[i].begin();
            ll idx2 = lower_bound(all(G3[i]),j)-G3[i].begin();
            ll w1=G1[i].size();
            ll w2=G3[i].size();
            if(idx1!=w1 && idx2==w2){
                flag=1;
            }else if(idx1!=w1){
                if(G1[i][idx1]<G3[i][idx2]){
                    flag=1;
                }
            }
            if(idx1!=0&&idx2==0){
                flag=1;
            }else if(idx1!=0){
                if(G1[i][idx1-1]>G3[i][idx2-1]){
                    flag=1;
                }
            }

            ll idx3 = lower_bound(all(G2[j]),i)-G2[j].begin();
            ll idx4 = lower_bound(all(G4[j]),i)-G4[j].begin();
            ll h1=G2[j].size();
            ll h2=G4[j].size();
            if(idx3!=h1 && idx4==h2){
                flag=1;
            }else if(idx3!=h1){
                if(G2[j][idx3]<G4[j][idx4]){
                    flag=1;
                }
            }
            if(idx3!=0&&idx4==0){
                flag=1;
            }else if(idx3!=0){
                if(G2[j][idx3-1]>G4[j][idx4-1]){
                    flag=1;
                }
            }
            ans+=flag;

        }
    }
    cout<<ans<<endl;

    return 0;

}

#include <bits/stdc++.h>

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18;
const int N = 1507;

int a[N][N];
bool vld[N][N];

int main(){
	setIO();
	int h, w, n, m;
	cin >> h >> w >> n >> m;
	for (int i = 0; i < n; i++){
		int r, c;
		cin >> r >> c;
		a[r][c] = 1;
	}
	for (int i = 0; i < m; i++){
		int r, c;
		cin >> r >> c;
		a[r][c] = -1;
	}
	// right
	for (int i = 1; i <= h; i++){
		bool ok = 0;
		for (int j = 1; j <= w; j++){
			if (a[i][j] == 1) ok = 1;
			else if (a[i][j] == -1) ok = 0;
			vld[i][j] |= ok;
		}
	}
	// left
	for (int i = 1; i <= h; i++){
		bool ok = 0;
		for (int j = w; j >= 1; j--){
			if (a[i][j] == 1) ok = 1;
			else if (a[i][j] == -1) ok = 0;
			vld[i][j] |= ok;
		}
	}
	// down
	for (int i = 1; i <= w; i++){
		bool ok = 0;
		for (int j = 1; j <= h; j++){
			if (a[j][i] == 1) ok = 1;
			else if (a[j][i] == -1) ok = 0;
			vld[j][i] |= ok;
		}
	}
	// up
	for (int i = 1; i <= w; i++){
		bool ok = 0;
		for (int j = h; j >= 1; j--){
			if (a[j][i] == 1) ok = 1;
			else if (a[j][i] == -1) ok = 0;
			vld[j][i] |= ok;
		}
	}
	int ans = 0;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (vld[i][j]) ans++;
		}
	}
	cout << ans << endl;
}


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

#define mem(ar,x) memset(ar,x,sizeof(ar))
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<int>
#define pi pair<int,int>
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define pb push_back
#define int long long
#define ff first
#define ss second
#define maxn 200005
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(float 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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int32_t main() {

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

    fastio;

int a,b;
cin>>a>>b;
int s1=0,s2=0;

while(a){
    s1+=a%10;a/=10;
}
while(b){
    s2+=b%10;b/=10;
}
if(s1>=s2)cout<<s1;
else cout<<s2;

}

#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); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#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(){
  string s, t;
  cin >> s >> t;
  if(s[0] + s[1] + s[2] >= t[0] + t[1] + t[2]){
    cout << s[0] + s[1] + s[2] - '0' * 3;
  }else
    cout << t[0] + t[1] + t[2] - '0' * 3;

}
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;

}


//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> //
#include <vector> //
#include <algorithm> //
#include <queue> //
#include <string> //
#include <functional> //
#include <set> //
#include <unordered_map> //
#include <random> //
#include <ctime> //
#include <bitset> //
#include <cassert>

// #include <atcoder/all>
// using namespace atcoder;
// g++ t.cpp -o t -I .

#define DB cerr<<"D"<<endl

struct _zo{_zo(){std::cin.tie(nullptr);std::cout.tie(nullptr);std::ios::sync_with_stdio(false);}}__zo;
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
using P=pair<ll,ll>;
using Q=pair<pair<ll,ll>,ll>;
const ll M = 998244353;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll mod_pow(ll x, ll a, ll m) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;} bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
int ketasu(ll a) {int res=0; while(a>0) res++, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  int n;cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ll an=0, sm=0;
  for(int i=0;i<n;i++) {
    add(an, (sm + a[i]) * a[i] % M);
    sm = sm * 2 + a[i];
    sm %= M;
  }
  cout<<an<<endl;
}
//

// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest

#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!

#ifndef ONLINE_JUDGE // setting up print debugging
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<#x<<"="<<x<<endl
#define ERR2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 998244353
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

ll binexpy(ll x,ll n)
{
	if(n==0)
	{
		return 1;
	}
	else if(n%2==0)
	{
		return binexpy(x*x,n/2);
	}
	else
	{
		return x*binexpy(x*x,(n-1)/2);
	}

}
ll binexpymod(ll x,ll n,ll mod)
{
	ll prod = 1;
	if(n==0)
	{
		return 1;
	}
	else if(n%2==0)
	{
		prod = ((x%mod)*(x%mod))%mod;
		return binexpymod(prod,n/2,mod);
	}
	else{
		prod = ((x%mod)*(x%mod))%mod;
		return ((x%mod)*binexpymod(prod,(n-1)/2,mod))%mod;
	}
}

	//cout<<binexpy(2,60);
	//cout<<endl;
	//cout<<binexpymod(2,60,2);
ll modInverse(ll n, ll p)
{
	return binexpymod(n, p-2, p);
}

ll nCrmod(ll n, ll r, ll p)
{
if (r==0)
	return 1;
	ll fac[n+1];
	fac[0] = 1;
	for (ll 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;
}

int main()
{
	int t;
	t = 1;
	int Case = 0;
	while(t--)
	{
        ll n;
        cin >> n;
        vector<ll>A(n);
        ll ans = 0;
        for(int i=0;i<n;i++){
            cin >> A[i];
            ans = (  ans+(binexpymod(A[i], 2, MOD))  )%MOD;
        }
        sort(all(A));
        ll post = 0;
        for(int i=n-1;i>=1;i--){
            post = ((post*2)%MOD + A[i])%MOD;
            ll temp = (A[i-1]*post)%MOD;
            ans = (ans+temp)%MOD;
        }
        cout << ans << endl;
	}
	return 0;
}


#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>

#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}

template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}

int cmp(int a, int b)
{
	if((3+b-a)%3==1) return b;
	return a;
}

struct solve
{
	solve(){}
	char calc(int k, vi&a)
	{
		if(k==0) return "RPS"[a[0]];

		int n=a.size();
		int m=n;
		if(m&1) m*=2;
		vi b(m);

		for(int i=0;i<m;i++)
		{
			b[i]=cmp(a[(i*2)%n], a[(i*2+1)%n]);
		}
		return calc(k-1, b);
	}
	char operator()(int k, vi&a) {
		return calc(k, a);
	}
};

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

	for(;;)
	{
		int n, k;
		cin >> n >> k;
		if(cin.fail()) break;
		string s;
		cin >> s;

		vi a(n);
		for(int i=0;i<n;i++)
		{
			if(s[i]=='R') a[i]=0;
			if(s[i]=='P') a[i]=1;
			if(s[i]=='S') a[i]=2;
		}

		cout << solve()(k, a) << "\n";
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
char win(char c,char d){
    if(c==d)return c;
    if(c>d)swap(c,d);
    if(c=='R'&&d=='S')return 'R';
    if(c=='P'&&d=='R')return 'P';
    return 'S';
}
int main(){
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    rep(i,k){
        s+=s;
        string ns;
        rep(j,s.size()/2)ns+=win(s[j*2],s[j*2+1]);
        s=ns;
    }
    out(s[0]);
}


#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

struct union_find {
    vector<int64_t> par;
    vector<int64_t> _size;
    vector<ll> sa, sb;

    union_find(int64_t _n, vector<ll> a, vector<ll> b) {
        par.resize(_n);
        _size.assign(_n, 1);
        for(int64_t i = 0; i < _n; ++i) par[i] = i;
        sa = a, sb = b;
    }

    int64_t root(int64_t x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int64_t x, int64_t y) {
        x = root(x), y = root(y);
        if (x != y) {
            if (_size[x] > _size[y]) swap(x, y);
            par[y] = x;
            _size[x] += _size[y];
            sa[x] += sa[y];
            sb[x] += sb[y];
        }
    }

    int64_t size(int64_t x) {
        return _size[root(x)];
    }

    bool ok(int64_t x) {
        return sa[root(x)] == sb[root(x)];
    }

    bool same(int64_t x, int64_t y) {
        return root(x) == root(y);
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    Vec a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    union_find uf(n, a, b);
    rep(i, m) {
        ll c, d;
        cin >> c >> d;
        --c, --d;
        uf.unite(c, d);
    }

    bool flg = true;
    rep(i, n) flg &= uf.ok(i);
    if (flg) puts("Yes");
    else
        puts("No");

    return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
#include<tuple>
#include<deque>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
const long long LINF = 1001002003004005006;
const double PI = acos(-1);
int dir4row[] = { 1,0,-1,0 };
int dir4col[] = { 0,1,0,-1 };
int dir8row[] = { 1,1,0,-1,-1,-1,0,1 };
int dir8col[] = { 0,1,1,1,0,-1,-1,-1 };

/*-----------------------------------------------*/

vector<long long> a, b;

struct UnionFind {
	vector<int> r;
	vector<long long> sum1, sum2;
	int N;
	UnionFind(int n) {
		r = vector<int>(n, -1);
		N = n;
		sum1 = vector<long long>(n);
		sum2 = vector<long long>(n);
		for (int i = 0; i < n; ++i) {
			sum1[i] = a[i];
			sum2[i] = b[i];
		}
	}
	int root(int x) {
		if (r[x] < 0) {
			return x;
		}
		return r[x] = root(r[x]);
	}
	bool unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) {
			return false;
		}
		if (r[a] > r[b]) {
			swap(a, b);
		}
		sum1[a] += sum1[b];
		sum1[b] = 0;
		sum2[a] += sum2[b];
		sum2[b] = 0;
		r[a] += r[b];
		r[b] = a;
		return true;
	}
	bool solve() {
		for (int i = 0; i < N; ++i) {
			if (sum1[i] != sum2[i]) {
				return false;
			}
		}
		return true;
	}
};

int main() {
	int n, m; cin >> n >> m;
	a = vector<long long>(n);
	b = vector<long long>(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int c, d; cin >> c >> d;
		c--;
		d--;
		uf.unite(c, d);
	}
	if (uf.solve()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float 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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// -----------------------------------------------------------------------------------
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//---------------------------------------------------------------------------
const int MOD = 1e9+7;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ll x,y;
        cin >> x >> y;
        ll ss = y*(y+1)/2;
        ll gg = x*(x-1)/2;
        ans+=(ss-gg);
    }
    cout << ans <<"\n";
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		long long int x,y;
		cin>>x>>y;
		sum+=(x+y)*(y-x+1)/2;
	}
	cout<<sum<<endl;
	return 0;
}


/*
求 k*k 矩阵最小中位数值
*/
#include <bits/stdc++.h>
using namespace std;
const int maxx=805;
long long mp[maxx][maxx];
long long sum[maxx][maxx];
int n,k,inx;
long long l=1e9+5,r=-1;
int check(int x){//每个小矩阵中 比x大的数字要超过 inx
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){//sum[i][j]存的是小矩阵内 >= mid 的数量
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(mp[i][j]>=x);
		}
	}
	for(int i=k;i<=n;i++){
		for(int j=k;j<=n;j++){//如果有小矩阵中
			int tmp=sum[i][j]-sum[i-k][j]-sum[i][j-k]+sum[i-k][j-k];
			if(tmp < inx) return false;
		}
	}
	return true;
}
int main(){
	scanf("%d%d",&n,&k);
	inx= k * k/2 + 1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			scanf("%lld",&mp[i][j]);
			l=min(mp[i][j],l);
			r=max(mp[i][j],r);
		}
	}
	while(l<r){
		int mid=(l+r+1)>>1;
		if(check(mid))//猜 mid 值,然后去验证每个小矩阵中>=mid的数字个数是否合法
			l=mid;
		else
			r=mid-1;
	}
	printf("%lld",l);//最小中位数值
//	while(l<=r){
//		int mid=(l+r)/2;
//		if(check(mid)) ans=mid,l=mid+1;
//		else r=mid-1;
//	}cout<<ans;

}

#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
#define INF (1ll << 60)
ll mod = 1000000007;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p & 1)a *= x; x *= x; p >>= 1; }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p & 1)a = a * x % mod;  x = x * x % mod; p >>= 1; }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k + 1) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll modinv(ll a) { ll b = mod, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }u %= mod; if (u < 0) u += mod; return u; }

int main(void) {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> a(n, vector<int>(n));
	int r = 0, l = 0;
	rep(i, 0, n)rep(j, 0, n)cin >> a[i][j], r = max(r, a[i][j]);
	while (r - l > 1) {
		int m = (r + l) / 2;
		vector<vector<int>> s(n + 1, vector<int>(n + 1));
		rep(i, 0, n) {
			rep(j, 0, n) {
				if (a[i][j] > m)s[i + 1][j + 1] = 1;
				s[i + 1][j + 1] += s[i][j + 1] + s[i + 1][j] - s[i][j];
			}
		}
		bool ok = false;
		rep(x, 0, n - k + 1) {
			rep(y, 0, n - k + 1) {
				if (s[x + k][y + k] - s[x][y + k] - s[x + k][y] + s[x][y] < k * k / 2 + 1) {
					ok = true;
					break;
				}
			}
			if (ok)break;
		}
		if (ok)r = m;
		else l = m;
	}
	printf("%d\n", r);
	return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<char> str;
  for(int i=0; i<m; i++) {
    string s;
    cin >> s;
    for(int j=0; j<s.size(); j++) str.push_back(s.at(j));
  }

  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      cout << str.at(j*20 + i);
    }
    cout << endl;
  }
  return 0;
}

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

int n;
mt19937 mt;
const int TRIES = 750;
const int SHUFFLES = 0;

bool check(string s, vector<vector<char>>& a, int i, int j) {
    bool isOk = true;
    for (int k = 0; k < s.size() && isOk; ++k) {
        if (s[k] != a[i][(j + k) % n]) {
            isOk = false;
        }
    }
    if (isOk) {
        return true;
    }
    for (int k = 0; k < s.size() && isOk; ++k) {
        if (s[k] != a[(i + k) % n][j]) {
            isOk = false;
        }
    }
    return isOk;
}

int calc(vector<string>& v, vector<vector<char>>& a) {
    int cnt = 0;
    for (string& s : v) {
        bool found = false;
        for (int i = 0; i < n && !found; ++i) {
            for (int j = 0; j < n && !found; ++j) {
                if (check(s, a, i, j)) {
                    found = true;
                }
            }
        }
        cnt += found;
    }
    return cnt;
}

pair<int, vector<vector<char>>> gen(vector<string>& v) {
    shuffle(v.begin(), v.end(), mt);
    vector<vector<char>> a(n, vector<char>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            a[i][j] = char(mt() % 8 + int('A'));
        }
    }
    int i = 0, j = 0;
    for (auto s : v) {
        if (j + s.size() >= n) {
            j = 0;
            ++i;
        }
        if (i >= n) {
            break;
        }
        for (int k = 0; k < s.size(); ++k, ++j) {
            a[i][j] = s[k];
        }
    }
    pair<int, vector<vector<char>>> res = {calc(v, a), a};
    for (int i = 0; i < SHUFFLES; ++i) {
        auto curr = res;
        shuffle(curr.second.begin(), curr.second.end(), mt);
        curr.first = calc(v, curr.second);
        if (curr.first > res.first) {
            res = curr;
        }
    }
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    mt.seed(time(nullptr));
    int m;
    cin >> n >> m;
    vector<string> v(m);
    for (auto& i : v) {
        cin >> i;
    }
    pair<int, vector<vector<char>>> res = gen(v);
    for (int i = 0; i < TRIES; ++i) {
        auto curr = gen(v);
        if (curr.first > res.first) {
            res = curr;
        }
    }
    for (auto& i : res.second) {
        for (auto& j : i) {
            cout << j;
        }
        cout << '\n';
    }
	return 0;
}


#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    inf          1e9
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cill n.tie(NULL);cout.tie(NULL)

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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<ll,int> pii;
typedef pair<int,vi> pp;
typedef pair<pair<int,int>,int> pain;

int dr[8]= {-1,0,+1,0,-1,-1,+1,+1};
int dc[8]= {0,+1,0,-1,-1,+1,-1,+1};

int kx[8]= {-1,+1,+1,-1,+2,+2,-2,-2};
int ky[8]= {+2,+2,-2,-2,-1,+1,+1,-1};

const int N=100005;

int main()
{
   ffix(12);
   dn a,b,c,d;
   cin>>a>>b>>c>>d;
   dn ans=a+((c-a)*b)/(b+d);
   cout<<ans<<endl;
}

#include <iostream>
#include <vector>

std::vector<int> StringsToInt(std::string str, std::string delimit) {
  std::vector<int> vec;

  if (str.find(delimit) == std::string::npos) {
    vec.emplace_back(std::atoi(str.c_str()));
    return vec;
  }

  for (std::size_t pos = 0;
       str.find(delimit) != std::string::npos;) {
    pos = str.find(delimit);
    vec.emplace_back(std::atoi(str.substr(0, pos).c_str()));
    str = str.substr(pos + delimit.size(), str.size());
  }
  vec.emplace_back(std::atoi(str.c_str()));
  return vec;
}

int main() {
  std::string dish, orange;
  if (std::getline(std::cin, dish) && std::getline(std::cin, orange)) {
    int sumDish = std::atoi(dish.c_str());
    std::vector<int> vOrange = StringsToInt(orange, " ");

    int max = 0;
    int left=0, right=sumDish, min=0, sum=0;
    while(true) {
      for (int k=left, count=1; k < right; ++k, ++count) {
        if (k == left) {
          min = vOrange.at(k);
        }
        int n = vOrange.at(k);
        if (min > n) {
          min = n;
        }
        sum = min * count;
        if (sum > max) {
          max = sum;
        }
      }
      for (int k=right-1, count=1; k > left-1; --k, ++count) {
        if (k == (right-1)) {
          min = vOrange.at(k);
        }
        int n = vOrange.at(k);
        if (min > n) {
          min = n;
        }
        sum = min * count;
        if (sum > max) {
          max = sum;
        }
      }
      if (left > right) {
        break;
      }
      ++left;
      --right;
    }
    std::cout << max << std::endl;
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=5e5;
int dp[N+10][2];
char a[N+10],b[N+10];
bool xora[N+10],xorb[N+10];
int main(){
	int n;
	scanf("%d%s%s",&n,a+1,b+1);
	for(int i=1;i<=n;i++){
		xora[i]=xora[i-1]^(a[i]-'0');
		xorb[i]=xorb[i-1]^(b[i]-'0');
	}
	int l=1;
	long long ans=0;
	for(int i=1;i<=n;i++){
		l=max(l,i);
		if(xora[l]==xorb[i])continue;
		while(l<=n&&xora[l]!=xorb[i])l++;
		if(l>n){
			puts("-1");
			return 0;
		}
		ans+=l-i;
	}
	cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, K, p[105], sz[105], arr[55][55], fac[55], ans = 1, mod = 998244353;

ll fs(ll x) {
	if (x == p[x]) return x;
	return p[x] = fs(p[x]);
}

int main() {
	fastio; cin >> n >> K;
	FOR(i, 1, n) FOR(j, 1, n) cin >> arr[i][j];
	FOR(i, 1, 2*n) p[i] = i, sz[i] = 1;
	fac[0] = 1; FOR(i, 1, n) fac[i] = (fac[i-1] * i) % mod;
	FOR(i, 1, n) FOR(j, 1, n) if (fs(i) != fs(j)) {
		bool ok = 1;
		FOR(k, 1, n) if (arr[i][k] + arr[j][k] > K) ok = 0;
		if (ok) {
			sz[fs(j)] += sz[fs(i)];
			p[fs(i)] = fs(j);
		}
	}
	FOR(i, 1, n) FOR(j, 1, n) if (fs(n+i) != fs(n+j)) {
		bool ok = 1;
		FOR(k, 1, n) if (arr[k][i] + arr[k][j] > K) ok = 0;
		if (ok) {
			sz[fs(n+j)] += sz[fs(n+i)];
			p[fs(n+i)] = fs(n+j);
		}
	}
	FOR(i, 1, 2*n) if (fs(i) == i) ans = (ans * fac[sz[i]]) % mod;
	cout << ans;
}


#include "bits/stdc++.h"
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, m = 0, n = 0, p = 0, q = 0, mod =
998244353
, pi = 3.1415926535;
    string s1, s2;
    char moji;

    cin >> a;
    vector<long long> v(a,0);
    vector<vector<vector<long long>>> dp(a+1,vector<vector<long long>>(5001,vector<long long>(51,0)));

    for(int i=0;i<a;i++)
    {
        cin >> v.at(i);
    }
    p=accumulate(v.begin(),v.end(),0);
    if(p%2)
    {
        cout << 0 << endl;
        return 0;
    }
  for(int i=0;i<a+1;i++)
  dp.at(i).at(0).at(0)=1;
      for(int j=0;j<a;j++)
      {
          for(int k=0;k<5001;k++)
          {
              for(int l=0;l<50;l++)
              {
                if(v.at(j)>k)
                {
                  dp.at(j+1).at(k).at(l+1)=dp.at(j).at(k).at(l+1);
                }
                else
                {
                  dp.at(j+1).at(k).at(l+1)=dp.at(j).at(k-v.at(j)).at(l)+dp.at(j).at(k).at(l+1);
                }
                dp.at(j+1).at(k).at(l+1)%=mod;
              }
          }
      }
      for(int i=1;i<a;i++)
      {
          n=dp.at(a).at(p/2).at(min((long long)i,a-i));
          for(int j=1;j<=i;j++)
          {
              n*=j;
              n%=mod;
          }
          for(int j=1;j<=a-i;j++)
          {
              n*=j;
              n%=mod;
          }
          m+=n;
          m%=mod;
      }
      cout << m << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int Mod = 998244353;
int N, a[105], f[105][20010], fac[105];
int main () {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
#endif
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = fac[0] = 1; i <= N; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	int zero = 1e4 + 3;
	f[0][zero] = 1;
	for (int i = 1, sum = 0; i <= N; i++) {
		sum += a[i];
		for (int j = i; ~j; j--)
			for (int k = -sum + zero; k <= sum + zero; k++)
				if (j) f[j][k] = (f[j - 1][k - a[i]] + f[j][k + a[i]]) % Mod;
				else f[j][k] = f[j][k + a[i]];
	}
	int ans = 0;
	for (int i = 1; i <= N; i++)
		ans = (ans + 1ll * f[i][zero] * fac[i] % Mod * fac[N - i]) % Mod;
	cout << ans << endl;
    return 0;
}


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

#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
#define DOR(i,s,t) for(int i=(s),_t=(t); i>=_t; --i)
#define EOR(i,x) for(int i=Head[x]; ~i; i=Nxt[i])

typedef long double db;
typedef long long ll;

namespace Eddd {
	inline char sc() {
		return getchar();
		static const int LEN=100000;
		static char Buf[LEN],*OP=Buf,*ED=Buf;
		if(OP==ED) ED=(OP=Buf)+fread(Buf,1,LEN,stdin);
		return *OP++;
	}
	template<class T> void rd(T &x) {
		static int c,f;x=f=0;
		while(c=sc(),c<48) if(c=='-') f=1;
		do x=(x<<3)+(x<<1)+(c^48);
		while(c=sc(),c>47);if(f) x=-x;
	}
	template<class T> void pt(T x) {
		if(x<0) putchar('-'),x=-x;
		else if(!x) putchar('0');
		static int Stk[30],tp=0;
		for(; x; x/=10) Stk[tp++]=x%10;
		while(tp) putchar(Stk[--tp]^48);
	}
	template<class T> void ptk(const T &x) {
		pt(x);putchar(' ');
	}
	template<class T> void ptn(const T &x) {
		pt(x);putchar('\n');
	}
	template<class T> bool chkmi(T &x,const T &y) {
		return x>y?x=y,true:false;
	}
	template<class T> bool chkmx(T &x,const T &y) {
		return x<y?x=y,true:false;
	}
}
using namespace Eddd;

ll A[55];
ll C[55];
ll f[55][2];
int main() {
	int n;
	rd(n);
	ll num;
	rd(num);
	FOR(i,1,n) rd(A[i]);
	DOR(i,n,1) {
		C[i]=num/A[i];
		num%=A[i];
	}
	FOR(i,1,n-1) A[i]=A[i+1]/A[i];
//	FOR(i,1,n-1) {
//		cerr << C[i] << " " << A[i] << endl;
//	}
	f[0][0]=1;
	FOR(i,1,n-1) {
		f[i][0]+=f[i-1][0];
		if(C[i]) f[i][1]+=f[i-1][0];
		if(C[i]+1==A[i]) {
			f[i][1]+=f[i-1][1];
		} else {
			f[i][0]+=f[i-1][1];
			f[i][1]+=f[i-1][1];
		}
	}
	ptn(f[n-1][0]+f[n-1][1]);
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
    static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
}
};

struct h_pair{
    size_t operator()(const PLL&x)const{
        return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
    }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];
VI G[MV], rz;

void dfs_visit(int s, int p)
{
    if(!arr[ar[s]])
    rz.pb(s);
    arr[ar[s]]++;
    for(auto u : G[s])
    {
        if(u != p)
        dfs_visit(u, s);
    }
    arr[ar[s]]--;
    return;
}

void solve(int T)
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>ar[i];
    for(int i=0;i<n-1;i++)
    {
        int s,d;
        cin>>s>>d;
        G[s].pb(d);
        G[d].pb(s);
    }
    dfs_visit(1, -1);
    sort(begin(rz), end(rz));
    for(auto &&u : rz)
    cout<<u<<"\n";
    return;
}

int main(void)
{
    FLASH();
    //freopen("cowjog.in", "r", stdin);
    //freopen("cowjog.out", "w", stdout);
    int T;
    T = 1;

#ifndef ONLINE_JUDGE
    time_t time_t1, time_t2;
    time_t1 = clock();
#endif

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

#ifndef ONLINE_JUDGE
    time_t2 = clock();
    SETF();
    cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
    UNSETF();
#endif

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll N;
ll C[110000];
vector<ll> G[110000];
ll cnt[110000];

vector<ll> res;

void init() {
    cin >> N;
    repp(i,1,N+1) cin >> C[i];
    rep(i,N-1) {
        ll a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
}

void dfs(ll now, ll from) {
    for (ll to : G[now]) {
        if (to==from) continue;
        if (cnt[C[to]]==0) res.push_back(to);
        cnt[C[to]]++;
        dfs(to,now);
        cnt[C[to]]--;
    }
}

int main() {
    init();
    cnt[C[1]]++;
    res.push_back(1);
    dfs(1,0);
    sort(all(res));
    for (ll ans : res) cout << ans << endl;
}


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

using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define cell(a,b) int((a+(b-1))/b)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl '\n'
#define INF 10e9

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

bool sortbyPair(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}

int main()
{

    int n,i;
    ll c=0;
    cin>>n;
    vector<int> a(n);
    map<int,int> mp;
    for(int &it:a)
    {
        cin>>it;
        mp[it]++;
    }
    for(int &it:a)
    {
        c+=(n-mp[it]);
        n--;
        mp[it]--;
    }
    cout<<c<<nl;

}

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

int solve(int a) {
  return a;
}

int main() {
  int N; cin >> N;
  int A[110];
  int B[110];

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  int ans = 0;
  for (int i = A[0]; i <= B[0]; i++) {
    bool is = true;
    for (int j = 1; j < N; j++) {
      if(i < A[j] || B[j] < i) is = false;
    }
    if (is == true) ans++;
  }

  cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = (1LL<<60)-1;

#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)(a.size())

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

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

//コーナーケースに気をつけろ！
int main() {
    int a, b, c;    cin >> a >> b >> c;
    cout << 21 - a - b - c << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;

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

int main(){
    int a;
    int b;
    int w;
    int Max = 0;
    int Min = 1000000000;
    cin >> a >> b >> w;
    for(int i = 1; i <= 1000000; i++){
        if(a*i <= w*1000 && w*1000 <= b*i){
            Min = min(Min,i);
            Max = max(Max,i);
        }
    }
    if(Max == 0) {
        cout << "UNSATISFIABLE" << endl;
    }else{
        cout << Min << " " << Max << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define eps 1e-8
#define maxm 600005
#define maxn 200005
#define ls (tot << 1)
#define rs (tot << 1 | 1)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;char ch = getchar();
    while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
    return x * f;
}

int t, l, r;
ll ans;

int main(){
	int i, j, x;
	t = read();
	while(t--){
		l = read(), r = read();
		ans = 0;
		ans += 1ll * (r + 1) * (r + 2) / 2;
		if(l){
			ans -= 1ll * l * (r + 1 + r - l + 2);
			ans += 1ll * l  * l;
			if(r < 2 * l - 2) ans -= 1ll * (l - 1 - (r - l + 2) + 1 + 1) * (l - 1 - (r - l + 2) + 1) / 2;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
long long ans=0, first, last, num;
int l, r, n;
int main() {
    cin>>n;
    while(n--) {
        ans=0;
        cin>>l>>r;
        if(l==r && l==0) cout<<1<<endl;
        else if(l+l>r) cout<<0<<endl;
        else {
            first=l+l;
            last=r;
            num=last-first+1;
            ans=1LL*(1+num)*num/2;
            cout<<ans<<endl;
        }
    }

    return 0;
}
/*
5
2 6
0 0
1000000 1000000
12345 67890
0 1000000

6
1
0
933184801
500001500001

*/


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

using namespace __gnu_pbds;
using namespace std;

#define ld long double
#define ll long long
#define ull unsigned long long
#define pb push_back
#define eb emplace_back
#define endl '\n'
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename A, typename B>
string to_string(pair<A, B> p);

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template<typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string) s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first)res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template<size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++)res += static_cast<char>('0' + v[i]);
  return res;
}

template<typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first)res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template<typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template<typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " +
         to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define err(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define err(...) 42
#endif
ll const N = 1e5 * 2, NN = 1e5 * 2 + 2, mod = 1e9 + 7;

void task_a() {
  string s;
  cin >> s;
  deque<char> dq;
  int cnt = 0;
  for (int i = 0; i < s.length(); ++i) {
    if(s[i]=='R') {
      cnt++;
      continue;
    }
    if (cnt % 2 == 0) {
      if (dq.empty())dq.pb(s[i]);
      else {
        if (dq.back() == s[i]) {
          dq.pop_back();
        } else {
          dq.pb(s[i]);
        }
      }
    } else {
      if (dq.empty())dq.push_front(s[i]);
      else {
        if (dq.front() == s[i]) {
          dq.pop_front();
        } else {
          dq.push_front(s[i]);
        }
      }
    }
  }
  if (cnt % 2 == 0) {
    while (!dq.empty()) {
      cout << dq.front();
      dq.pop_front();
    }
  } else {
    while (!dq.empty()) {
      cout << dq.back();
      dq.pop_back();
    }
  }
}

void task_b() {

}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  // cin >> t;
  for (int i = 1; i <= t; ++i) {
    task_a();
    // task_b();
  }
  return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>
#include<map>
#include<cassert>

using namespace std;

#define ll long long
#define reps(i, a, b) for(int i = a; i < b; i++)
#define rreps(i, a, b) for(int i = a-1; i >= b; i--)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) rreps(i, n, 0)
#define P pair<int, int>

const ll mod = 1000000007;
const int INF = 1001001001;

ll N;
vector<pair<ll, ll> > prime;

void prime_fact(ll x){
    for (ll i = 2; i * i <= x; i++){
        if(x % i == 0){
            pair<ll, ll> p = make_pair(i, 0);
            while (x % i == 0){
                x /= i;
                p.second++;
            }
            prime.push_back(p);
        }
    }
    if(x > 1){
        pair<ll, ll> p = make_pair(x, 1);
        prime.push_back(p);
    }
}

int ans = 0;

void f(ll n, int num){
    if(num == prime.size()){
        // cout << n << endl;
        ll x = (2 * N) / n;
        if((x - ( n - 1)) % 2 == 0) ans++;
        return;
    }
    ll a = 1;
    rep(i, prime[num].second+1){
        f(n*a, num+1);
        a *= prime[num].first;
    }
}

int main(){
    cin >> N;
    prime_fact(2*N);
    f(1, 0);
    cout << ans << endl;
}


#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

char v[65][5];
int n;
ll dp[65][2];
bool mark[65][2];

ll f(int i, int j) {
	if(i == n) return j;
	if(mark[i][j]) return dp[i][j];

	mark[i][j] = true;
	ll ans = 0;

	if(v[i][0] == 'A') {
		if(!j) ans = 2*f(i+1, 0);
		else ans = f(i+1, 1) + f(i+1, 0);
	}
	else {
		if(!j) ans = f(i+1, 0) + f(i+1, 1);
		else ans = 2*f(i+1, 1);
	}

	return dp[i][j] = ans;
}

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

	for(int i = 0; i < n; i++) {
		scanf(" %s", v[i]);
	}

	printf("%lld\n", f(0, true) + f(0, false));

	return 0;
}

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

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

#define kj <<" "<<
#define kjb <<" ";
#define dg <<","<<
#define ml <<'\n';
#define co cout<<
#define ter cout<<endl;
#define sibi cout<<"TES"<<endl;
#define tes(x) cout<<"TES"<<x<<endl;
#define kpr(x) cout<<"("<<x.st dg x.nd <<")" ml

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

LL fals(int p);

LL tru(int p){
	//sibi
	//co "t" ml
	LL ret=0;
	if(p==0){
		bemer[p]=1;
		return 1;
	}
	if(bemer[p]!=-1){
		return bemer[p];
	}
	if(s[p-1]=="AND"){
		ret=tru(p-1);
		bemer[p]=ret;
		return bemer[p];
	}
	else{
		ret+=2*tru(p-1);
		//sibi
		ret+=fals(p-1);
		bemer[p]=ret;
		return bemer[p];
	}
}

LL fals(int p){
	//co "f" kj p ml
	LL ret=0;
	if(p==0){
		salah[p]=1;
		return 1;
	}
	if(salah[p]!=-1){
		return salah[p];
	}
	if(s[p-1]=="OR"){
		salah[p]=fals(p-1);
		//co "kh" kj p kj fals(p-1) ml
		return salah[p];
	}
	else{
		LL ret=0;
		ret+=2*fals(p-1);
		ret+=tru(p-1);
		salah[p]=ret;

		return salah[p];
	}
}

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	//srand(time(0));
	cin>>b;
	//cin.ignore();
	//sibi
	FOR(i,b){
		//sibi
		cin>>s[i];
		//operator ke i untuk ngoperasike i sama i+1
	}
	//sibi
	memset(bemer,-1,sizeof(bemer));
	memset(salah,-1,sizeof(salah));
	//cout<<b<<endl;

	r=tru(b);
	FOR(i,b+1){
		//co bemer[i] kj salah[i] ml
	}
	cout<<r<<endl;
}
/*

*/


#pragma GCC optimize("O3")
#pragma GCC target("avx")
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl
#define out2(x, y) cout << x << " " << y << " " << endl
const ll INF = 1LL << 60;
const int BIG = 1e9;
const int LN = 1000000000;
vector<char> alp = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                    'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                    's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int main() {
    cout << fixed << setprecision(15);

    int n, d, h;
    cin >> n >> d >> h;
    double maxh = -1;
    rep(i, n) {
        int di, hi;
        double tmp;
        cin >> di >> hi;
        tmp = h - (double)d * (h - hi) / (d - di);
        if (tmp > maxh) maxh = tmp;
    }
    if (maxh < 0) maxh = 0;
    cout << maxh << endl;
}

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

void Malena(){
	int n,d,h;cin>>n>>d>>h;
	vector<vector<int>>bars(n,vector<int>(2));
	for(int i=0;i<n;++i){
		cin>>bars[i][0]>>bars[i][1];
	}
	int low=0,hi=1001;
	int eps=1e-6;
	while(abs(hi-low)>eps){
		int mi=low+(hi-low)/2;
		int found=0;
		for(int i=0;i<n;++i){
			if(bars[i][1] - ( ((h-mi)/d)*bars[i][0])-mi > 0){
				found++;
			}
		}
		(found?low:hi)=mi;
	}
	cout<<setprecision(12)<<low<<'\n';
}

signed main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t;
	t=1;
	//cin>>t;
	while(t--){
		Malena();
	}
	return 0;
}


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

int main() {
	int a1,a2,a3,a4;
	cin >> a1 >> a2 >> a3 >> a4;
	int ans = a1;
	if(ans > a2) ans = a2;
	if(ans > a3) ans = a3;
	if(ans > a4) ans = a4;
	cout << ans << endl;
	  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define f(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define ps(x,y)   fixed<<setprecision(y)<<x
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{

    FIO;
    int t=1;
    // cin>>t;
    while(t--)
    {
       int a,b,c,d;
       cin>>a>>b>>c>>d;
       cout<<min(min(a,b),min(c,d))<<endl;
    }
return 0;
}


#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
// warning: pragmas don't work on USACO and just set to O0

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //gp_hash_table<T, U, chash>;
#include <ext/pb_ds/tree_policy.hpp> //tree<T, U, cmp, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std; using namespace __gnu_pbds;
// shorter template (CF specialization, because compile time better)

inline int RAND(int l, int r) {
    mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> unifd(l, r); return unifd(mt);
}

template <class T> using pq = priority_queue<T, vector<T>, greater<T>>;
using ll = long long; using db = double; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>;
using vll = vector<ll>; const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};

#define ff first
#define ss second
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define pf push_front

//#define TC
const ll INF = 1e18; const db EPS = 1e-8;
const int MOD = 1e9 + 7, //998244353
          _ = 2e5 + 5;

void solve() {
    ll N;
    cin>>N;
    ll x=1;
    ll ans=0;
    ll y=1;
    while(true){
        x*=1000;
        if(N>=x) {
            ll res = (min(x*1000,N+1)-x)*y;
            ans+=res;
        }
        else {
            break;
        }
        y++;
    }
    cout<<ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0); //cout << setprecision(3) << fixed << showpoint;
    int t = 1;

    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

void solve() {
  using ll = long long;
  int n, m; cin >> n >> m;
  vector<int> a(n), b(n);
  for(auto &x : a) cin >> x;
  for(auto &x : b) cin >> x;
  vector<vector<int>> g(n);
  while(m--) {
    int c, d; cin >> c >> d; --c, --d;
    g[c].emplace_back(d);
    g[d].emplace_back(c);
  }
  vector<bool> seen(n, false);
  auto dfs = [&](auto dfs, int v) -> complex<ll> {
    complex<ll> ret(a[v], b[v]);
    seen[v] = true;
    for(auto &nv : g[v]) {
      if(!seen[nv]) {
        ret += dfs(dfs, nv);
      }
    }
    return ret;
  };
  for(int i=0; i<n; ++i) {
    if(!seen[i]) {
      auto ret = dfs(dfs, i);
      if(real(ret) != imag(ret)) {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}

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

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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

const ll OO = (ll)1e18;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

vi a, b;

ll sum1, sum2;

void dfs(int curr, vector<vi> &adj, vi &vis)
{
    vis[curr] = 1;
    sum1 += a[curr];
    sum2 += b[curr];
    for (int i = 0; i < (int)adj[curr].size(); ++i)
    {
        int next = adj[curr][i];
        if (vis[next])
            continue;
        dfs(next, adj, vis);
    }
}

int main()
{
    FASTIO
#ifdef LOCAL
    FILEIO
#endif
    int n, m;
    cin >> n >> m;
    int in;
    forn(i, 0, n)
    {
        cin >> in;
        a.push_back(in);
    }
    forn(i, 0, n)
    {
        cin >> in;
        b.push_back(in);
    }
    int c, d;
    vector<vi> adj(n + 1);
    forn(i, 0, m)
    {
        cin >> c >> d;
        --c, --d;
        adj[c].pb(d);
        adj[d].pb(c);
    }

    vi vis(n, 0);

    forn(i, 0, n)
    {
        if (vis[i])
            continue;
        sum1 = 0, sum2 = 0;
        dfs(i, adj, vis);
        if (sum1 != sum2)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<string> VS;
//template
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;}
//repetition
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPS(i,N) for(int i=0; i<=int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
//container util
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//constant
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    ll N; cin >> N;
    ll ans=0;

    REP(i,N) {
        ll tmp_1,tmp_2; cin>>tmp_1>>tmp_2;
        if ((tmp_2-tmp_1)%2==0) ans += ((tmp_1 + tmp_2) * ((tmp_2 - tmp_1)/2) + (tmp_2+tmp_1)/2);
        else ans += ((tmp_1 + tmp_2) * ((tmp_2 - tmp_1 + 1)/2));
    }

    cout << ans << endl;
}

#include <bits/stdc++.h>
#define ll unsigned long long
#define pi 3.141592653
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define MAX 100005
using namespace std;
ll count(ll n)
{
    ll c=0;
    while(n!=0)
    {

        c++;
        n=n/10;
    }

    return c;
}
int isPrime(ll n)
{
    // Corner case
    if (n <= 1)
        return 0;

    // Check from 2 to n-1
    for (ll i = 2; i < n; i++)
        if (n % i == 0)
            return 0;

    return 1;
}
ll modFact(ll n, ll p)
{
    if (n >= p)
        return 0;

    ll result = 1;
    for (ll i = 1; i <= n; i++)
        result = (result * i) % p;

    return result;
}
ll divisor(ll n)
{   ll h=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            h=i;
            break;
        }
    }
    return h;
}
bool sortbysec(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}
 const int logN = 20;
int f[MAX][logN],mval[MAX][logN],depth[MAX];
vector<pair<int,int> >v[100005];
void dfs(int u)
{
	for(int i=1;i<logN;i++)
	{
		f[u][i]=f[f[u][i-1]][i-1];
		mval[u][i]=max(mval[u][i-1],mval[f[u][i-1]][i-1]);
	}
	for(auto i:v[u])
	{
		int ver=i.first,w=i.second;
		if(!depth[ver])
		{
			f[ver][0]=u;
			mval[ver][0]=w;
			depth[ver]=depth[u]+1;
			dfs(ver);
		}
	}
}
ll sum(ll x)
{
   ll s = 0;
   while (x != 0) {
      s = s + x % 10;
      x = x / 10;
   }
  return s;
}

ll fact(ll n);

ll nCr(ll n, ll r)
{
	return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
ll fact(ll n)
{
	int res = 1;
	for (int i = 2; i <= n; i++)
		res = res * i;
	return res;
}
ll modularExponentiation(ll x,ll n,ll M)
{
 if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
ll xorOfArray(ll arr[], ll n)
{
    // Resultant variable
    ll xor_arr = 0;

    // Iterating through every element in
    // the array
    for (ll i = 1; i <=n; i++) {

        // Find XOR with the result
        xor_arr = xor_arr ^ arr[i];
    }

    // Return the XOR
    return xor_arr;
}

// Returns (a * b) % mod
ll moduloMultiplication(ll a,
							ll b,
							ll mod)
{
	ll res = 0; // Initialize result

	// Update a if it is more than
	// or equal to mod
	a %= mod;

	while (b)
	{
		// If b is odd, add a with result
		if (b & 1)
			res = (res + a) % mod;

		// Here we assume that doing 2*a
		// doesn't cause overflow
		a = (2 * a) % mod;

		b >>= 1; // b = b / 2
	}

	return res;
}

int main()
{
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll m=998244353;
ll a,b,c;
cin>>a>>b>>c;
ll x=a*(a+1)/2;//moduloMultiplication(a,a+1,998244353);
ll y=b*(b+1)/2;//moduloMultiplication(b,b+1,998244353);
ll z=c*(c+1)/2;//moduloMultiplication(c,c+1,998244353);

ll s=moduloMultiplication(x,y,998244353);
ll ans=moduloMultiplication(s,z,998244353);
cout<<ans;
    return 0;
}


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

typedef long long ll;

int n, m;
ll x, y;
map<ll, vector<ll>> mp;
set<ll> s;
ll in[200005];
ll out[200005];
int cnt1, cnt2;

int main()
{
    cin>>n>>m;
    for (int i=1; i<=m; ++i)
    {
        cin>>x>>y;
        mp[x].push_back(y);
    }
    s.insert(n);
    for (auto t : mp)
    {
        cnt1 = 0;
        cnt2 = 0;
        for (auto it : t.second)
        {
            if (s.count(it)) out[++cnt2] = it;
            if (it-1>=0 && s.count(it-1)) in[++cnt1] = it;
            if (it+1<=2*n-1 && s.count(it+1)) in[++cnt1] = it;
        }
        for (int i=1; i<=cnt2; ++i) s.erase(out[i]);
        for (int i=1; i<=cnt1; ++i) s.insert(in[i]);
    }
    cout<<s.size();

    return 0;
}

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

#define debug(x) cout << #x << " is " << x << endl
typedef long long ll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;

int n, m;
vector<P> p;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	int x, y;
	for (int i = 0; i < m; ++i) {
 		cin >> x >> y;
 		p.push_back({x, y});
	}
	sort(p.begin(), p.end());
	set<int> s;
	s.insert(n);
	int l = 0;
	while (l < m) {
		vector<int> a, b;
		int r = l;
		while (r < m) {
			if (p[r].first == p[l].first) r++;
			else break;
		}
		for (int i = l; i < r; ++i) {
			int y = p[i].second;
			if ((s.find(y - 1) != s.end() || s.find(y + 1) != s.end()) && s.find(y) == s.end()) a.push_back(y);
			if ((s.find(y - 1) == s.end() && s.find(y + 1) == s.end()) && s.find(y) != s.end()) b.push_back(y);
		}
		for (int e : a) s.insert(e);
		for (int e : b) s.erase(e);
		l = r;
	}
	cout << (int)s.size() << '\n';
	return 0;
}