#include<bits/stdc++.h>
using namespace std;
int a[200000];
long long b[200000];
int Mod=1e9+7;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	int tot=0;
	for(int i=1;i<=n;i++)
		if(a[i]!=a[i-1]) b[++tot]=a[i];
	long long sum=1;
	for(int i=1;i<=tot;i++)
	{
		sum=sum*(b[i]-b[i-1]+1)%Mod;
	}
	cout<<sum;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FOREACH(a, b) for (auto &(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define dbg(x) cout << (#x) << " is " << (x) << endl;
#define dbg2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << y << endl;
#define dbgarr(x, sz)                                             \
  for (int asdf = 0; asdf < (sz); asdf++) cout << x[asdf] << ' '; \
  cout << endl;
#define dbgarr2(x, rose, colin)                \
  for (int asdf2 = 0; asdf2 < rose; asdf2++) { \
    dbgarr(x[asdf2], colin);                   \
  }
#define dbgitem(x)                                                           \
  for (auto asdf = x.begin(); asdf != x.end(); asdf++) cout << *asdf << ' '; \
  cout << endl;

const int mod = 1e9 + 7, MAXN = 1e5 + 1;

int n, A[MAXN];
struct Solution {
  int solve() {
    sort(A, A + n);
    auto it = unique(A, A + n);
    n = it - A;
    long res = 1;
    REP(i, n) {
      res = (res * (A[i] - (i ? A[i - 1] : 0) + 1)) % mod;
    }
    return res;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution test;
  string s;
  cin >> n;
  REP(i, n)
  cin >> A[i];
  cout << test.solve() << endl;
}


/*
Author- Aasav Badera
Time- Sat Oct  3 17:21:39 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    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);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        string s;
        cin >> s;
        long long int ans = 0;
        int cntr[n][4] = {0};
        map<char, int> m1;
        m1['A'] = 0;
        m1['T'] = 1;
        m1['G'] = 2;
        m1['C'] = 3;
        rep(i, 0, n)
        {
        	rep(j, 0, 4)
        	{
        		if(j == m1[s[i]])cntr[i][j] = 1;
        		else cntr[i][j] = 0;
        	}
        	if(i)
        	{
        		rep(j, 0 ,4)
        		{
        			cntr[i][j] += cntr[i - 1][j];
        		}
        	}
        }
        rep(i, 0, n)
        {
        	rep(j, i, n)
        	{
        		int itm[4];
        		rep(l, 0 ,4)
        		{
        			itm[l] = cntr[j][l];
        			if(i)
        			{
        				itm[l] -= cntr[i - 1][l];
        			}
        			dbg(i, j, l, itm[l]);
        		}
        		ans += ((itm[0] == itm[1]) and (itm[3] == itm[2]));
        	}
        }
        cout << ans << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define all(x)         x.begin(),x.end()
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
bool func(vector<vector<int>>&dp, int i, int rem, string &s, string &x) {
    if (i == s.size()) {
        return rem == 0;
    }
    if (dp[i][rem] != -1) {
        return dp[i][rem];
    }
    bool f;
    if (x[i] == 'A') {
        f = (func(dp, i + 1, (rem * 10) % 7, s, x) and func(dp, i + 1, (rem * 10 + (s[i] - '0')) % 7, s, x));
    }
    else {
        f = (func(dp, i + 1, (rem * 10) % 7, s, x) or func(dp, i + 1, (rem * 10 + (s[i] - '0')) % 7, s, x));
    }
    return dp[i][rem] = f;
}
inline void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string x;
    cin >> x;
    vector<vector<int>>dp(n, vector<int>(7, -1));
    if (func(dp, 0, 0, s, x)) {
        cout << "Takahashi";
    }
    else
    {
        cout << "Aoki";
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; i++)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
typedef long long ll;

int n;
vector<int> w, maxL;
vector<pair<int,int>> seg;

ll mindist(vector<int>& o) {
  ll ans = 0;
  vector<ll> pos(n);

  for(int i = 1; i < n; i++) {
    int sumw = w[o[i]];
    pos[i] = pos[i-1];

    for(int st = i-1; st >= 0; st--){
      sumw += w[o[st]];
      // sumw = weight of cows [st, i]

      auto lo = lower_bound(all(seg), pair<int,int>{sumw, -1});
      if (lo == seg.begin()) continue;
      int idx = (lo - seg.begin()) - 1;

      pos[i] = max(pos[i], pos[st] + maxL[idx]);
    }
  }

  return pos.back();
}

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

  w.resize(n);
  int mxw = 0;
  forn(i,n){
    cin >> w[i];
    mxw = max(mxw, w[i]);
  }

  //seg[i] = {v,l}
  seg.resize(m);
  forn(i,m) cin >> seg[i].second >> seg[i].first;
  sort(all(seg));

  maxL.resize(m);
  forn(i,m){
    maxL[i] = seg[i].second;
    if (i) maxL[i] = max(maxL[i], maxL[i-1]);
  }

  if (seg[0].first < mxw) {
    cout << "-1";
    return 0;
  }

  vector<int> o(n);
  iota(all(o), 0);

  long long ans = 1ll << 60;
  do{
    ans = min(ans, mindist(o));
  }while(next_permutation(all(o)));

  cout << ans << "\n";
}

#include <bits/stdc++.h>
using namespace std;
int main(){
  #define int long long
  int N,M,maxW=0,ans=0;
  cin>>N>>M;
  vector<int> w(N),l(M),v(M),p(N);
  vector<pair<int,int>> rock(M);
  for(int i=0;i<N;i++){
    cin>>w.at(i);
    maxW=max(maxW,w.at(i));
    p.at(i)=i;
  }
  for(int i=0;i<M;i++){
    cin>>l.at(i)>>v.at(i);
    ans+=l.at(i);
    if(maxW>v.at(i)){
      cout<<-1<<endl;
      return 0;
    }
    rock.at(i)={v.at(i),l.at(i)};
  }
  ans*=N;
  sort(rock.begin(),rock.end());
  unordered_map<int,int> minW;
  for(int i=0;i<M;i++){
    if(i==0){minW[rock.at(i).first+1]=rock.at(i).second;}
    if(i>0){minW[rock.at(i).first+1]=max(rock.at(i).second,minW[rock.at(i-1).first+1]);}
  }
  sort(w.begin(),w.end());
  sort(v.begin(),v.end());
  do{
    vector<int> d(N-1,0);
    for(int i=0;i<N;i++){//右端
      for(int j=0;j<=i;j++){//左端
        int sumW=0,sumD=0;
        for(int k=j;k<=i;k++){//sumD,sumWの計算
          sumW+=w.at(k);
          if(k<i){sumD+=d.at(k);}
        }
        int left=0,right=M-1,sumWW=-1;
        while(left<=right){
          int mid=left+(right-left)/2;
          if(v.at(mid)+1<=sumW){
            left=mid+1;
            sumWW=max(sumWW,v.at(mid)+1);
          }
          else{right=mid-1;}
        }
        int stkj=minW[sumWW];//必要距離
        if(stkj>sumD){d.at(i-1)+=stkj-sumD;}
      }
    }
    int Qans=0;
    for(int i=0;i<N-1;i++){Qans+=d.at(i);}
    ans=min(ans,Qans);
  }while(next_permutation(w.begin(),w.end()));
  cout<<ans<<endl;
}


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

using namespace std;

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

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

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

	cin >> N;
	vector<long long int>v(N);
	for (auto& i : v)cin >> i;
	long long int mx = v[0];
	auto w = v;
	for (int i = 1; i < N; i++)w[i] += w[i - 1];
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += w[i];
		mx = max(mx, v[i]);
		cout << ans + mx * (i + 1) << endl;
	}
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(b-1)),y(up?b:(a-1)){}_RX(int a):_RX(0,a){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

string rev(string x) {
	string y;
	for(auto c : x) {
		y.push_back(c == 'A' ? 'B' : 'A');
	}
	return y;
}

vector<string> solve(const int N) {

	if(N == 1) {
		vector<string> ans;
		ans.push_back("AB");
		return ans;
	}

	auto prev = solve(N - 1);
	vector<string> ans;

	for(auto s : prev) {
		ans.push_back(s + s);
	}
	for(auto s : prev) {
		ans.push_back(s + rev(s));
	}
	string last;
	for(auto i : range(1 << (N - 1))) {
		last.push_back('A');
	}
	for(auto i : range(1 << (N - 1))) {
		last.push_back('B');
	}

	ans.push_back(last);

	return ans;
}

int main() {

	const int N = read_item();
	auto ans = solve(N);
	printf("%d\n", (int)ans.size());
	for(auto s : ans) {
		printf("%s\n", s.c_str());
	}

	return 0;
}

/* wafdayo~~~ */


#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <stdio.h>

constexpr int HeighestDim = 505000;

int n, m, k;
long long int res[101];
int dim_a = 0, dim_b = 0;
int A[HeighestDim + 1], B[HeighestDim];

void mult_a(int v){
    for(int i = dim_a, j = i - v; j >= 0; --i, --j){ A[i] -= A[j]; if(A[i] < 0) A[i] += m; }
}
void div_a(int v){
    for(int i = v, j = 0; i <= dim_a; ++i, ++j){
        A[i] += A[j]; if(A[i] >= m) A[i] -= m;
    }
}

void mult_b(int v){
    dim_b += v;
    for(int i = dim_b, j = i - v; j >= 0; --i, --j){
        B[i] -= B[j]; if(B[i] < 0) B[i] += m;
    }
}
void div_b(int v){
    for(int i = v, j = 0; i <= dim_b; ++i, ++j){
        B[i] += B[j]; if(B[i] >= m) B[i] -= m;
    }
}

int len = 0;
char Buffer[20];
char Output[1500];

int main(void){
    A[0] = 1; B[0] = 1;
    scanf("%d%d%d", &n, &k, &m);
    if(n == 1){ printf("%d\n", k); return 0; }
    else if(n == 2){ printf("%d\n%d\n", k, k); return 0; }
    else if(n == 3){
        printf("%d\n%d\n%d\n", k, k * static_cast<long long int>(k + 2) % m, k);
        return 0;
    }
    res[1] = k; res[n] = k; ++k;
    const int hd = (n >> 1) + (n & 1);
    const int nmt = n - 2;
    {
        int i, j;
        for(i = 1, j = k; i <= hd; ++i, j += k){ dim_a += j; mult_a(j); div_a(i); }
        for(; i <= nmt; ++i, j += k){ mult_a(j); div_a(i); }
        mult_b(k); div_b(1);
    }
    for(int i = 2, j = n - 1, I = 2 * k, J = k * (n - 2); ; I += k, J -= k){
        long long int res_v = 0;
        for(int d = 0; d <= dim_b; ++d) res_v += static_cast<long long int>(A[d]) * B[d] % m;
        if(res_v) res_v = (k * res_v - 1) % m; else res_v = m - 1;
        res[i] = res_v; res[j--] = res_v;
        if(i + 1 > j) break;
        mult_a(j); div_a(J);
        mult_b(I); div_b(i++);
    }

    for(int i = 1; i <= n; ++i){
        if(res[i]){
            int l = 0;
            do { Buffer[l++] = res[i] % 10; res[i] /= 10; } while(res[i]);
            while(l--) Output[len++] = Buffer[l] ^ '0';
        }
        else Output[len++] = '0';
        Output[len++] = '\n';
    }
    fwrite(Output, 1, len, stdout);
    return 0;
}

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

const int MX = 6e5, K = 101;
int M;

int dp[K][2*MX];
int sum[2*MX];

int add(int a, int b) {
    return a+b >= M ? a+b-M : a+b;
}

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

    int n, k;
    cin>>n>>k>>M;
//    n = 100, k = 100, M = 1e9;

    dp[0][0] = 1;
    for (int x=1; x<=n; x++) {
        memset(sum, 0, sizeof sum);
        for (int i=0; i<2*MX; i++) {
            sum[i] = dp[x-1][i];
            if (i>=x)  sum[i] = add(sum[i], sum[i-x]);
        }

        for (int i=0; i<2*MX; i++) {
            dp[x][i] = sum[i];
            if (i>=(k+1)*x)     dp[x][i] = add(sum[i], M-sum[i-(k+1)*x]);
        }
    }

    for (int x=1; x<=n; x++) {
        int A = n-x, B = x-1;

        long long ans = 0;
        for (int i=0; i<2*MX; i++)  ans = (ans + 1LL*dp[A][i]*dp[B][i])%M;
        ans = (ans * (k+1) + M - 1)%M;
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
typedef pair<int,int> pp;
bool com(pp x,pp y){
    if(x.ff==y.ff) return x.ss<y.ss;
    return x.ff<y.ff;
}
ll power(ll x,ll y){
    ll prod=1;
    while(y){
        if(y&1) prod=(prod*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return prod;
}
const int N=1e5+9;
void solve(){
    int n;
    cin>>n;
    cout<<(n+99)/100<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	    solve();
	return 0;
}
/*
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    IOS;
    prec;
    Int a,b,c,x,y,z, ans=0;
    string s,t,r;
    int N;
    cin>>N;
    cout<<(N+99)/100;

    cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define N ((int)5e4 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX ((int)2e9 + 5)
#define fastio ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define endl "\n"
#define ll long long
using namespace std;
int main(){

    fastio ;
     string s ;
     cin>>s ;
     if(s[0]==s[1] && s[2]==s[0] && s[1]==s[2]) puts("Won") ;
     else puts("Lost") ;

    return 0;
}

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

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define endl              "\n"
#define vi                vector<int>
#define ll                long long

void solve()
{
    //Code here
    char a,b,c;
    cin>>a>>b>>c;
    if(a==b&& b==c &&a==c)
        cout<<"Won"<<endl;
    else
        cout<<"Lost"<<endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll T=1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast
    ll n,x;cin>>n>>x;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=0;i<n;i++)
    {
        if(a[i]!=x)
            cout<<a[i]<<" ";
    }
    cout<<"\n";
}

#pragma GCC optimize("O3")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

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

#define test(t)             int t; cin >> t; while(t--)
#define f(i, a, b)          for(int (i) = (a); (i) < (b); ++(i))
#define all(a)              (a).begin(), (a).end()
#define endl                "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define deb(x)              cout << #x << ": " << x << endl;
#define deb2(x,y)           cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)           cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)          cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast                ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    int n, x;
    cin >> n >> x;
    f(i, 0, n)
    {
        ll y;
        cin >> y;
        if(y != x)
            cout << y << " ";
    }
    cout << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define rep_r(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define reps(i,n,m) for(int i=(int)(n); i<(int)(m); ++i)
#define reps_r(i,n,m) for(int i=(int)(m)-1; i>=(int)(n); --i)
#define N 200001
int main(){
    //cout<<fixed<<setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q,t,a,b,state=1;
    string s,s1,s2;
    char c;
    cin>>n>>s>>q;
    s1 = s.substr(0,n);
    s2 = s.substr(n,2*n);
    rep(i,q){
        cin>>t>>a>>b;
        if(t==1){
            if(b-1<n){
                if(state==1){
                    c=s1[a-1];
                    s1[a-1]=s1[b-1];
                    s1[b-1]=c;
                }else{
                    c=s2[a-1];
                    s2[a-1]=s2[b-1];
                    s2[b-1]=c;
                }
            }else if(n<=a-1){
                if(state==1){
                    c=s2[a-n-1];
                    s2[a-n-1]=s2[b-n-1];
                    s2[b-n-1]=c;
                }else{
                    c=s1[a-n-1];
                    s1[a-n-1]=s1[b-n-1];
                    s1[b-n-1]=c;
                }
            }else{
                if(state==1){
                    c=s1[a-1];
                    s1[a-1]=s2[b-n-1];
                    s2[b-n-1]=c;
                }else{
                    c=s2[a-1];
                    s2[a-1]=s1[b-n-1];
                    s1[b-n-1]=c;
                }
            }
        }else if(t==2){
            state *= -1;
        }
    }
    if(state==1) cout<<s1<<s2<<"\n";
    else cout<<s2<<s1<<"\n";
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<LL, int> PR;
const LL INF=1e16;
struct Graph{
  int N, M; VI A, B; VL C; vector<VI> S, T;
  Graph(int n) : N(n), M(0), S(n), T(n) {}
  void setEdge(int s, int t, LL u){
    A.push_back(s); B.push_back(t); C.push_back(u);
    S[s].push_back(M); T[t].push_back(M); M++;
  }
  VL Dijkstra(int s){
    VL D(N, INF); D[s]=0;
    priority_queue< PR, vector<PR>, greater<PR> > Q;
    REP(i, N){ Q.push(make_pair(D[i], i)); }
    while(Q.size()){
      PR p=Q.top(); int v=p.second; Q.pop();
      if(D[v]<p.first){ continue; }
      for(int e:S[v]){
        int u=B[e]; LL nw=D[v]+C[e];
        if(nw<D[u]){ D[u]=nw; Q.push(make_pair(D[u], u)); }
      }
    }
    return D;
  }
};
int main(){
  int N, M, a, b; LL c;
  cin >> N >> M; Graph G(N); VL J(N, INF);
  REP(i, M){
    cin >> a >> b >> c; a--; b--;
    if(a==b){ J[a]=min(J[a], c); }
    G.setEdge(a, b, c);
  }
  vector<VL> d;
  REP(i, N){ d.push_back(G.Dijkstra(i)); }
  REP(i, N){
    LL ans=J[i];
    REP(j, N){
      if(i==j){ continue; }
      ans=min(ans, d[i][j]+d[j][i]);
    }
    if(ans<INF){ cout << ans << "\n"; }
    else{ cout << -1 << "\n"; }
  }
}


#include<iostream>
#include<algorithm>
#include<cstring>
#define debug(a) cout<<#a<<" = "<<a<<endl

using namespace std;

typedef long long ll;
const int N = 5010;
const int MOD = 998244353;

int n , m;
ll C[N];
ll f[N];

ll Q_power(ll a ,ll b){
    ll res = 1;
    while(b){
        if(b & 1) res = res * a % MOD;
        b >>= 1;
        a = a*a % MOD;
    }
    return res;
}

ll X_1(ll a){ return Q_power(a ,MOD - 2) ;}

void init(){
    C[0] = 1;
    for(int i = 1 ; i <= n ; i ++){
        C[i] = C[i - 1] * (n - i + 1) % MOD * X_1(i) % MOD;
    }
}

ll F(int m){
    if(~f[m] == 0){
        f[m] = 0;
        if(!(m & 1)){
            for(int i = 0 ; i * 2 <= m ; i ++){
                f[m] = (f[m] + C[i * 2] * F(m / 2 - i) % MOD) % MOD;
            }
        }
    }
    return f[m];
}

int main(){
    cin >> n >> m;
    memset(f,0xff,sizeof f);
    init(); f[0] = 1;
    cout << F(m) << endl;
    return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
typedef long long ll;
typedef unsigned un;
typedef std::vector<int> P;
typedef std::pair<int,int> pii;
ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();return f*x;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
template <typename T> bool umax(T& a,T t){if(t>a)return a=t,1;return 0;}
template <typename T> bool umin(T& a,T t){if(t<a)return a=t,1;return 0;}
/**********/
const int MAXN = 5011,mod = 998244353;
int C[MAXN][MAXN];
int f[MAXN],pre[MAXN];
void init(int n)
{
	C[0][0]=1;
	for(int i=1;i<=n;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
}
int main()
{
	init(5000);
	int n=read(),m=read(),rest=m;
	f[0]=1;
	for(int i=0;(1<<i)<=m;++i)
	{
		memcpy(pre,f,sizeof f),memset(f,0,sizeof f);
		for(int j=0;j<=rest;++j)
			for(int k=0;k*(1<<i)<=j;k+=2)f[j]=(f[j]+ll(pre[j-k*(1<<i)])*C[n][k])%mod;

	}
	printf("%d\n",f[m]);
	return 0;
}


// #include <bits/stdc++.h>
// string s;
// getline(cin, s);
// g++ -std=c++11 -O2 -Wall test.cpp -o test
// printf("%.9f\n", x); PRECISION

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define F first
#define S second

const long long MOD = 1e9 + 7;
const double EPS = 1e-9;

const int MAX_LENGTH = (2 * 1e5 + 1);
int n, c;
long long x;
long long dp[MAX_LENGTH][2];

void solve() {
    set<int> set_ids;
    unordered_map<int, long long> max_pos;
    unordered_map<int, long long> min_pos;
    int MMIN = 0, MMAX = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> c;
        set_ids.insert(c);
        if (max_pos.find(c) == max_pos.end()) {
            max_pos[c] = x;
            min_pos[c] = x;
        } else {
            max_pos[c] = max(max_pos[c], x);
            min_pos[c] = min(min_pos[c], x);
        }
    }
    vector<int> ids(set_ids.begin(), set_ids.end());
    n = ids.size();
    dp[n - 1][MMIN] = abs(min_pos[ids[n - 1]] - max_pos[ids[n - 1]]) +
                      abs(max_pos[ids[n - 1]]);
    dp[n - 1][MMAX] = abs(min_pos[ids[n - 1]] - max_pos[ids[n - 1]]) +
                      abs(min_pos[ids[n - 1]]);

    for (int i = n - 2; i >= 0; i--) {
        int cur = ids[i];
        int next = ids[i + 1];
        long long d = abs(min_pos[cur] - max_pos[cur]);
        dp[i][MMIN] =
            d + min(dp[i + 1][MMAX] + abs(max_pos[next] - max_pos[cur]),
                    dp[i + 1][MMIN] + abs(min_pos[next] - max_pos[cur]));
        dp[i][MMAX] =
            d + min(dp[i + 1][MMAX] + abs(max_pos[next] - min_pos[cur]),
                    dp[i + 1][MMIN] + abs(min_pos[next] - min_pos[cur]));
    }
    cout << min(abs(min_pos[ids[0]]) + dp[0][MMIN],
                abs(max_pos[ids[0]]) + dp[0][MMAX]);
}

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

    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout <<"Case #" << i << ": ";
        solve();
    }
}

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

int main(){
  int n; cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for(int i=0; i<n; i++){
    cin >> x.at(i);
    cin >> y.at(i);
  }

  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if((x.at(j)-x.at(i))*(y.at(k)-y.at(j)) == (x.at(k)-x.at(j))*(y.at(j)-y.at(i))){
          cout << "Yes" << endl;
          return (0);
        }
      }
    }
  }
  cout << "No" << endl;

}


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

int main()
{
    long long int a,b,c;
    cin>>a>>b>>c;
    long long int sqa=pow(a,2)+pow(b,2);
    long long int sqc=pow(c,2);
    if(sqa<sqc)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
    int a, b, x, y, ans = 0;
    cin >> a >> b >> x >> y;
    if (2 * x >= y) {
        if (a <= b) ans = abs(a - b) * y + x;
        else
            ans = (abs(a - b) - 1) * y + x;
    } else
        ans = abs(a - b) * x * 2 + ((a <= b) ? x : -x);
    cout << ans << endl;
    return 0;
}


//https://cp-algorithms.com/algebra/linear_congruence_equation.html

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

// using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll gcdExtended(ll a, ll b, ll* x, ll* y);

// Function to find modulo inverse of a
ll modInverse(ll a, ll m)
{
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    return (x % m + m) % m;
}

// C function for extended Euclidean Algorithm
ll gcdExtended(ll a, ll b, ll* x, ll* y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    ll x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b % a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b / a) * x1;
    *y = x1;

    return gcd;
}
void solve(){
  // Method 1:(n*x+n-s)%k==0 find min x;
  // or Method 2:  (x*k+s)%n==0 find min x;
  ll n,s,k;
  cin>>n>>s>>k;
  ll b= (k+(s-n)%k)%k;
  ll a=n;
  if(b%__gcd(a,k)!=0){cout<<-1<<endl;return;}
  ll g=__gcd(a,k);
  a/=g;b/=g,k/=g;
  ll z=(b*modInverse(a,k))%k;
  cout<<(z*n+n-s)/(k*g)<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    tc{solve();}
}
// Method 2:
// void solve(){
//   ll n,s,k;
//   cin>>n>>s>>k;
//   ll b=n-s;
//   ll a=k;
//   ll m=n;
//   ll d=__gcd(__gcd(a,b),m);
//   a/=d,b/=d,m/=d;
//   // cout<<a<<b<<m<<endl;
//   if(__gcd(a,m)!=1){cout<<-1<<endl;return;}
//   ll z=(b*modInverse(a,m))%m;
//   cout<<z<<endl;
// }

#include <iostream>

int64_t gcd(int64_t a,int64_t b,int64_t &x,int64_t &y)
{
  if(b==0){x=1;y=0;return a;}
  int64_t d=gcd(b,a%b,y,x);
  y-=a/b*x;
  return d;
}

int main()
{
  int T;
  std::cin>>T;

  for(int i=0;i<T;i++)
  {
    int64_t N,S,K;
    std::cin>>N>>S>>K;

    int64_t result=0;

    int64_t x,y;
    int64_t d=gcd(K,-N,x,y);
    if(S%d==0)
    {
      x*=-S/d;
      x%=N/d;if(x<0)x+=N/d;
      result=x;
    }
    else
    {
      result=-1;
    }

    std::cout<<result<<std::endl;
  }

  return 0;
}


#include <bits/stdc++.h>
//#include <bits/extc++.h>
//#define int long long
#define ll long long
#define ull unsigned ll
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n-1);i>=a;i--)
#define trav(a, x) for(auto& a : x)
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define eb emplace_back
using namespace std;
using vvi = vector<vi>;
using vvl = vector<vl>;
//const ll M = 1e9 + 7;
//const ll M = 998244353;
const ll M = 1e9 + 9;
//const ll M = 1e6;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll binpow(ll a, ll b){
	ll res = (a!=0);
	while(b > 0){
		if(b&1) res = res * a % M;
		a = a * a % M;
		b>>=1;
	}
	return res;
}
const ll inf = 2e18;
void solve(){
	ll n, x;
	cin >> n >> x;
	vl a(n);
	re(a);
	ll ans = -1;
	for(int i=1;i<=n;i++){
		// biggest sum such that (x - s) % i == 0
		vector<vl> dp(i, vl(i + 1, -inf));
		dp[0][0] = 0;
		for(int j=0;j<n;j++){
			vector<vl> new_dp = dp;
			for(int k=0;k<i;k++){
				for(int z=0;z<i;z++){
					if(dp[k][z] != -inf){
						new_dp[(a[j] + k) % i][z + 1] = max(new_dp[(a[j] + k) % i][z + 1], dp[k][z] + a[j]);
					}
				}
			}
			swap(dp, new_dp);
		}
		if(dp[x%i][i] == -inf) continue;
		if(ans == -1){
			ans = (x - dp[x%i][i]) / i;
		}
		else ans = min(ans, (x - dp[x%i][i]) / i);
	}
	cout << ans << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_set>

using namespace std;

typedef long long ll;

void solve() {
    ll a, b;
    cin >> a >> b;
    int n = 73;
    vector<int> s(n);
    vector<int> prime;
    for (int i = 2; i < n; i++) {
        if (s[i] == 0) {
            s[i] = i;
            prime.emplace_back(i);
            for (int j = i; j < n; j += i) {
                s[j] = i;
            }
        }
    }

    int m = b - a + 1;
    n = prime.size();
    vector<int> mask(m);

    for (int i = 0; i < m; i++) {
        ll x = a + i;
        for (int j = 0; j < n; j++) {
            if (x % prime[j] == 0) {
                mask[i] ^= (1 << j);
            }
        }
    }

    vector<ll> dp(1 << n);
    dp[0] = 1;

    for (int i = 0; i < m; i++) {
        vector<ll> dp2(1 << n);
        for (int j = 0; j < (1 << n); j++) {
            if (dp[j] == 0)
                continue;
            dp2[j] += dp[j];
            if ((mask[i] & j) == 0)
                dp2[mask[i] ^ j] += dp[j];
        }
        dp.swap(dp2);
    }

    ll ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        ans += dp[i];
    }

    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#if defined(_DEBUG)
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
    //cin >> q;
    for (; q > 0; q--) {
        solve();
        //cout << endl;
    }
}


#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 998244353;
const long long int INF = 1e18;
const long double PI=3.14159265358979323;
//const long long int pl=1000000;

long long int N,K,A[300000]={},B[300000],res=0;
long long int dp[3005][6005]={},memo[3005]={};
int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for (long long int  i = 0; i < N; i++)
    {
        cin>>A[i]>>B[i];
    }
    for (long long int i = 0; i < N; i++)
    {
        for (long long int j = i+1; j < N; j++)
        {
            for (long long int k = j+1; k < N; k++)
            {
                if((B[j]-B[i])*(A[k]-A[i])==(B[k]-B[i])*(A[j]-A[i])){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }

        }

    }
    cout<<"No"<<endl;

}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main(void)
{
  int N=IN(),A=0,B=0,sz=2*N,tp[sz]={},com[sz];short dp[sz+1]={};
  memset(com,-1,sizeof(com));
  rep(i,N)
  {
    A=IN(),B=IN();
    if(A!=-1){A--;if(tp[A]){return puts("No"),0;}tp[A]=i+1;}
    if(B!=-1){B--;if(tp[B]){return puts("No"),0;}tp[B]=-i-1;}
    if(A!=-1&&B!=-1){com[A]=B;com[B]=A;}
  }
  dp[0]=1;
  rep(i,sz)
  {
    if(!dp[i])continue;
    rep(j,sz-i-1)
    {
      int w=j+2;if(w&1){continue;}else w/=2;
      short ok=1,exist[N]={};
      rep(k,w)
      {
        int p=i+k,q=i+k+w;short same=1;
        if(com[p]!=-1&&!(i<=com[p]&&com[p]<=i+j+1)){ok=0;break;}
        if(com[q]!=-1&&!(i<=com[q]&&com[q]<=i+j+1)){ok=0;break;}
        if(tp[p]!=0&&tp[q]!=0){if(tp[p]<0||tp[p]+tp[q]!=0){ok=0;break;}else same=1;}
        if(tp[p]<0||tp[q]>0){ok=0;break;}
        else
        {
          if(tp[p]!=0){int v=tp[p]-1;if(exist[v]){ok=0;break;}exist[v]=1;}
          if(!same&&tp[q]!=0){int v=-tp[q]-1;if(exist[v]){ok=0;break;}exist[v]=1;}
        }
      }
      if(ok)dp[i+j+2]=1;
    }
  }
  return puts(dp[sz]?"Yes":"No"),0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

ll dp2[150000][20];
ll cost[20][20];// wa―シャルフロイド
int main()
{
	int N;
	cin >> N;

	vector<tuple<int, int, int>> B;
	fx(N) {
		int a, b, c;
		cin >> a >> b >> c;
		B.push_back(make_tuple(a, b, c));
	}

	fx(N) {
		fy(N) {
			cost[x + 1][y + 1] = abs(get<0>(B[x]) - get<0>(B[y])) + abs(get<1>(B[x]) - get<1>(B[y])) + max(0, get<2>(B[y]) - get<2>(B[x]));
		}
	}

	//fy(N) {
	//	fx(N) {
	//		fz(N) {
	//			cost[x+1][z + 1] = min(cost[x + 1][z + 1], cost[x + 1][y + 1] + cost[y + 1][z + 1]);
	//		}
	//	}

	//}

	fx(150000) {
		fy(N) {
			dp2[x][y+1] = LLONG_MAX;
		}

	}

	dp2[1][1] = 0;

	for (int y = 1; y < (1 << N); y += 2) {
		fx(N) {
			if (((1 << x) & y) == 0) { continue; }
			if (dp2[y][x + 1] == LLONG_MAX) { continue; }
			fz(N) {   // 増やし先
				if (((1 << z) & y) != 0) { continue; }
				fw(N) {
					if (((1 << w) & y) == 0) { continue; }
					dp2[y | (1 << z)][z+1] = min(dp2[y | (1 << z)][z+1], dp2[y][x+1] + cost[x + 1][w + 1] + cost[w + 1][z + 1]);
				}
			}
		}
	}

	ll ans = LLONG_MAX;
	fx(N) {
		//if (dp2[(1 << N) - 1][x + 1] == LLONG_MAX) { continue; }
		if (dp2[(1 << N) - 1][x + 1] < 0) { continue; }
		ans = min(ans, dp2[(1 << N) - 1][x + 1] + cost[x + 1][1]);
	}
	ce(ans)

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

struct times{
    bool start;
    ll time = 0;
    ll value = 0;
};

int N,C;
priority_queue<pair<int,times*>> q ;

void solve(){

    cin >> N>> C;

    ll a,b,c;
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b >> c;
        times* t = new times();
        t->start = true;
        t->time = a;
        t->value = c;
        q.push(make_pair(-a*2,t));

        times* f = new times();
        f->start = false;
        f->time = b;
        f->value = c;
        q.push(make_pair(-b*2-1,f));
    }

    ll ans = 0;
    ll cost = 0;
    ll topay = 0;
    ll pos = q.top().second->start;
    for (int i = 0; i < 2*N; i++)
    {
        auto e = q.top();
        q.pop();

        topay = (cost > C) ? C : cost;

        if(e.second->start){
            cost += e.second->value;

            ans += (e.second->time - pos )* topay;
            pos = e.second->time;
        }
        else{
            if(pos <= e.second->time){
                ans += (e.second->time - pos +1 )* topay;
                pos = e.second->time +1;
            }
            cost -= e.second->value;
        }

    }

    cout << ans<< endl;

}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
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 A[3020][5];
ll N;

bool isOK(ll key){
  vector<ll> aup(32);
  rep(i,N){
    ll temp = 0;
    rep(k,5){
      if(A[i][k]>=key){
        temp+=pow(2,k);
      }
    }
    aup[temp]++;
  }
  bool aru = 0;
  rep(i,32){
    rep(k,32){
      rep(t,32){
        if((i|k|t) == 31){
          if(aup[i]>0&&aup[k]>0&&aup[t]>0){
            //cout << i << k << t << endl;
            aru = 1;
          }
        }
      }
    }
  }
  return aru;
}

int main(){
  cin>>N;
  rep(i,N){
    cin>>A[i][0]>>A[i][1]>>A[i][2]>>A[i][3]>>A[i][4];
  }
  ll right = MOD;
  ll left = -1;
  while((right-left)>1){
    ll mid=left+(right-left)/2;
    if(isOK(mid)){
      left = mid;
    }
    else{
      right = mid;
    }
  }
  cout << left << endl;
  return 0;
}

#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
#define For(i,l,r) for(int i=l;i<=r;i++)
#define MAXN 200001
int N,ans;ll now=0;struct A{int a,b;bool operator<(A x)const{return 2ll*a+b>2ll*x.a+x.b;}}a[MAXN];
int main()
{
	cin>>N;For(i,1,N)cin>>a[i].a>>a[i].b,now-=a[i].a;sort(a+1,a+N+1);
	For(i,1,N){if(now>0)break;now+=2ll*a[i].a+a[i].b,ans++;}cout<<ans<<endl;return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll mod=1e9+7;
ll dp[2000+4];

vector<pair<ll,ll>>p;

vector<ll> to[100005];
ll inf =1000000007;

ll keta(ll n){
    ll ans=0;
    while(n!=0){
        ans++;
        n/=10;
    }
    return ans;
}

ll kazu(ll i){
    ll ans=0;
    for(ll k=1;k*k<=i;k++){
        if(i%k==0){
            if(i/k==k)ans++;
            else ans+=2;
        }
    }
    return ans;
}

int main()
{
ll n;
cin>>n;
vector<float>x(n);
vector<float>y(n);
rep(i,n)cin>>x[i]>>y[i];
rep(i,n){
    if(x[i]==x[i+1]){
        for(ll j=i+2;j<n;j++){
            if(x[i]==x[j]){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }else{
        for(ll k=i+1;k<n;k++){
          float lean=(y[k]-y[i])/(x[k]-x[i]);
          for(ll j=k+1;j<n;j++){
            float tmp=(y[j]-y[i])/(x[j]-x[i]);
            if(lean==tmp){
              cout<<"Yes"<<endl;
              return 0;
            }
          }
        }
    }
}
cout<<"No"<<endl;
}

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

typedef long long int in;

int main()
{
    in n,i,j,k;
    cin>>n;

    in a[n],b[n];

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

    for(i=0;i<n;++i)
    for(j=i+1;j<n;++j)
    for(k=j+1;k<n;++k)
    {
        in val=a[i]*(b[j]-b[k])+a[j]*(b[k]-b[i])+a[k]*(b[i]-b[j]);

        if(val==0)
        {
            cout<<"Yes";
            return 0;
        }
    }

    cout<<"No";

    return 0;
}


#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
ll pw(ll a, ll b, ll mod) {
    if (b == 0) return 1 % mod;
    if (b & 1) {
        return (a * pw(a, b - 1, mod)) % mod;
    }
    ll res = pw(a, b / 2, mod);
    return (res * res) % mod;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    ll n;
    ll m;
    cin >> n >> m;
    ll p = m * m;
    cout << (pw(10 % p, n, p) / m) % m;
    return 0;
}

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

int main()
{
    char s,t;
    cin>>s>>t;

    if(s=='Y')
    {
        char p=(t-'a'+'A');
        cout<<p;
    }
    else
    {
        cout<<t;
    }
}


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

using namespace std;
//using namespace atcoder;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using ld = long double;
using vld = vector<ld>;
using vb = vector<bool>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

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

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

template <class T> ostream& operator<<(ostream& s, const vector<T>& a) {
    for(auto i : a) s << i << ' ';
    return s;
}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 62;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
    static const long long mod = 998244353;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint& a) {if ((x += a.x) >= mod) x -= mod; return *this;}
    mint& operator-=(const mint& a) {if ((x += mod - a.x) >= mod) x -= mod; return *this;}
    mint& operator*=(const mint& a) {(x *= a.x) %= mod; return *this;}

    friend const mint operator+(const mint& a, const mint& b) { mint ret = a; return ret += b; }
    friend const mint operator-(const mint& a, const mint& b) { mint ret = a; return ret -= b; }
    friend const mint operator*(const mint& a, const mint& b) { mint ret = a; return ret *= b; }
    friend ostream& operator<<(ostream& s, const mint& a) { return s << a.x; }

    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

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

struct combi {
    const static long long mod = mint::mod;
    int n;
    vector<mint> fac, finv, inv;

    combi(int _n) : n(_n + 1), fac(n, 1), finv(n, 1), inv(n, 1) {
        for (int i = 2; i < n; ++i) {
            fac[i] = fac[i - 1] * i;
            inv[i] =- inv[mod % i] * (mod / i);
            finv[i] = finv[i - 1] * inv[i];
        }
    };

    mint get(int n, int k) {
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        mint ret = fac[n] * finv[k] * finv[n - k];
        return ret;
    }
};

// 素因数分解
// nの(素因数、指数)のペアを返す。計算量はO(√nlogn)
vector<pair<ll, ll>> prime_factorize(ll n) {
    vector<pair<ll, ll>> ret;
    for(ll i = 2; i*i <= n; ++i) {
        if(n % i != 0) continue;
        ll ex = 0;
        while(n % i == 0) {
            ++ex;
            n /= i;
        }
        ret.push_back({i, ex});
    }
    if(n > 1) ret.push_back({n, 1});
    return ret;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    mint ans = 0;
    combi com(n+100);
    for(ll i = 1; i <= m; ++i) {
        vpll vp = prime_factorize(i);
        mint ans_ = 1;
        for(auto [p, e] : vp) ans_ *= com.get(n-1+e, e);
        ans += ans_;
    }
    cout << ans << endl;
    return;
}

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

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int n, m, k;
vector<vector<int>> edges;
vector<int> c;
vector<int> vis;
vector<int> d;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
    cin >> n >> m;
    edges.resize(n+1);
    FOR(i, m){
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    cin >> k;
    c.resize(k);
    FOR(i, k) cin >> c[i];

    vector<vector<int>> dist(k, vector<int>(k));
    for (int i = 0; i < k; i++){
        vector<int> d(n+1, -1);
        d[c[i]] = 0;
        queue<int> Q;
        Q.push(c[i]);
        while (!Q.empty()){
            int v = Q.front();
            Q.pop();
            for (int w : edges[v]){
                if (d[w] == -1){
                    d[w] = d[v] + 1;
                    Q.push(w);
                }
            }
        }
        for (int j = 0; j < k; j++){
            dist[i][j] = d[c[j]];
        }
    }

    int K = 1<<k;
    const int inf = 1e9;
    vector<vector<int>> dp(1 << k, vector<int>(k, inf));
    for (int i = 0; i < k; i++){
        dp[1 << i][i] = 0;
    }
    for (int i = 1; i < (1 << k); i++){
        for (int j = 0; j < k; j++){
            if (dp[i][j] != inf){
                for (int k2 = 0; k2 < k; k2++){
                    if (!(i >> k2 & 1)){
                        if (dist[j][k2] != -1){
                            int i2 = i + (1 << k2);
                            dp[i2][k2] = min(dp[i2][k2], dp[i][j] + dist[j][k2]);
                        }
                    }
                }
            }
        }
    }
    int sol = inf;
    FOR(i, k) umin(sol, dp[K-1][i]);
    cout << (sol < inf ? sol+1 : -1) << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define int long long
#define PI 3.1415926535897932384626
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

const int M=1000000007;

void solution()
{
    int i, j, k, n, m;
    cin>>n;

    pi arr[n];
    for(int i=0;i<n;i++) cin>>arr[i].S>>arr[i].F;

    sort(arr,arr+n);
    vector<pi>pos;
    i=0;
    while(i<n)
    {
        j=i+1;
        while(j<n && arr[j].F==arr[i].F) j++;
        j--;
        pos.pb({arr[i].S,arr[j].S});
        i=j+1;
    }

    int ans=0;
    m=pos.size();
    int dp[m][2];
    dp[0][0]=abs(pos[0].F);
    dp[0][1]=abs(pos[0].S);
    for(int i=1;i<m;i++)
    {
        dp[i][0]=min(abs(pos[i].F-pos[i-1].F)+dp[i-1][1],abs(pos[i].F-pos[i-1].S)+dp[i-1][0]);
        dp[i][1]=min(abs(pos[i].S-pos[i-1].F)+dp[i-1][1],abs(pos[i].S-pos[i-1].S)+dp[i-1][0]);
    }

    ans=min(abs(pos[m-1].F)+dp[m-1][1],abs(pos[m-1].S)+dp[m-1][0]);
    for(pi p:pos) ans+=abs(p.F-p.S);
    cout<<ans;
}

signed main()
{
    int t=1;
    //cin>>t;

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

    return 0;
}

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

typedef long long ll;
const int N = 2e5+7;
ll seg[N<<2],tag[N<<2];
int fa[N],dep[N],siz[N],son[N],top[N],dfn[N],rk[N], w[N];
int a[N], b[N];
int n,m,root;
int tot=0;
vector<int> G[N];
void pushDown(int node,int t){
    if(tag[node]!=0){
        tag[node<<1]+=tag[node];
        tag[node<<1|1]+=tag[node];
        seg[node<<1]=(seg[node<<1]+tag[node]*(t-(t>>1)));
        seg[node<<1|1]=(seg[node<<1|1]+tag[node]*(t>>1));
        tag[node]=0;
    }
    return ;
}
void dfs1(int u,int f,int dp){
    fa[u]=f;
	dep[u]=dp;
	siz[u]=1;
	son[u]=-1;
	for(size_t i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==fa[u]) continue;
		dfs1(v,u,dp+1);
		siz[u]+=siz[v];
		if(son[u]==-1 || siz[v]>siz[son[u]]){
			son[u]=v;
		}
	}
}
void dfs2(int u,int tp){
	top[u]=tp;
	tot++;
	dfn[u]=tot;
	rk[tot]=u;
	//rk[tot]=w[u];
	if(son[u]==-1) return ;
	dfs2(son[u],tp);
	for(size_t i=0;i<G[u].size();i++){
		int v=G[u][i];
		if(v==fa[u] || v==son[u]) continue;
		dfs2(v,v);
	}
}
void build(int node,int l,int r){
	if(l==r){
		//seg[node]=w[rk[l]];
        seg[node] = 0;
		//seg[node]=rk[l]%mod;
		return ;
	}
	int mid=(l+r)>>1;
	build(node<<1,l,mid);
	build(node<<1|1,mid+1,r);
	seg[node]=(seg[node<<1]+seg[node<<1|1]);
}
void update(int node,int l,int r,int ul,int ur,ll val){
    if(r<ul || l>ur)
        return ;
    if(l>=ul && r<=ur){
        tag[node]+=val;
        seg[node]+=val*(r-l+1);
        return ;
    }
    pushDown(node,r-l+1);
    int mid=(l+r)>>1;
    update(node<<1,l,mid,ul,ur,val);
    update(node<<1|1,mid+1,r,ul,ur,val);
    seg[node]=(seg[node<<1]+seg[node<<1|1]);
}
void update1(int u,int v,ll val){
	while(top[u]!=top[v]){
		if(dep[top[u]]<dep[top[v]]) swap(u,v);
		update(1,1,n,dfn[top[u]],dfn[u],val);
		u=fa[top[u]];
	}
	if(dep[u]>dep[v]) swap(u,v);
	update(1,1,n,dfn[u],dfn[v],val);
}
void update2(int u,ll val){
	update(1,1,n,dfn[u],dfn[u]+siz[u]-1,val);
}
ll query(int node,int l,int r,int ql,int qr){
	if(ql>r || qr<l) return 0;
	if(ql<=l && qr>=r) return seg[node];
	pushDown(node,r-l+1);
	int mid=(l+r)>>1;
	return (query(node<<1,l,mid,ql,qr)+query(node<<1|1,mid+1,r,ql,qr));
}
ll query1(int u,int v){
	ll res=0;
	while(top[u]!=top[v]){
		if(dep[top[u]]<dep[top[v]]) swap(u,v);
		res=(res+query(1,1,n,dfn[top[u]],dfn[u]));
		u=fa[top[u]];
	}
	if(dep[u]>dep[v]) swap(u,v);
	res=(res+query(1,1,n,dfn[u],dfn[v]));
	return res;
}
ll query2(int u){
	return query(1,1,n,dfn[u],dfn[u]+siz[u]-1);
}
int main(){
	#ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
    #endif
	scanf("%d", &n);
	//for(int i=1;i<=n;i++) scanf("%d", &w[i]);
	for(int i=1;i<n;i++){
		/* int u,v;
		scanf("%d %d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u); */
        scanf("%d %d", &a[i], &b[i]);
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
	}
    root = 1;
	dfs1(root,root,1);
	dfs2(root,root);
	build(1,1,n);

    scanf("%d", &m);
    int t, e;
    ll x, sum = 0;
	while(m--){
		//int op,u,v,val;
		//scanf("%d", &op);
        scanf("%d %d %lld", &t, &e, &x);
		/* if(op==1){
			scanf("%d %d %d", &u, &v, &val);
			update1(u,v,val);
		}else if(op==2){
			scanf("%d %d", &u, &v);
			printf("%d\n", query1(u,v));
		}else if(op==3){
			scanf("%d %d", &u, &val);
			update2(u,val);
		}else {
			scanf("%d", &u);
			printf("%d\n", query2(u));
		} */
        if(dep[b[e]] > dep[a[e]]) {
            if(t == 1) {
                update2(b[e], -x);
                sum += x;
            }else update2(b[e], x);
        }else {
            if(t == 2) {
                update2(a[e], -x);
                sum += x;
            }else update2(a[e], x);
        }
	}
    for(int i = 1; i <= n; i ++) {
        printf("%lld\n", query(1, 1, n, dfn[i], dfn[i]) + sum);
    }
 	return 0;
}


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

vector<vector<char>> mat;
vector<pair<int,string>> in;
vector<string> in2;
vector<string> in3;
vector<string> in4;
vector<string> in5;
vector<string> in6;
vector<string> in7;
vector<string> in8;
vector<string> in9;
vector<string> in10;
vector<string> in11;
vector<string> in12;
vector<string> concat_in;
int n,m;

void answer_print(){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << mat[i][j] ;
            if(j==n-1) cout << endl;
        }
    }
}

bool isPut(int x,int y,string str){
    if(mat[y][x] != '.') return false;
    if(n-x+1 < str.size()) return false;
    return true;
}

void Put(int x,int y,string str){
    for(int i = x;i<x+str.size();i++){
        mat[y][i] = str[i-x];
    }
}

void solve(){
    int k=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(isPut(j,i,concat_in[k])) {
                Put(j,i,concat_in[k]);
                k++;
            }
        }
    }
}

int main(){

    // input
    cin >> n >> m;
    mat.resize(n);in.resize(m);
    for(int i=0;i<n;i++) mat[i].resize(n,'.');

    for(int i=0;i<m;i++) {
        cin >>in[i].second;
        in[i].first = in[i].second.size();
    }

    for(int i=0;i<in.size();i++){
        switch(in[i].first){
            case 2 : in2.push_back(in[i].second);break;
            case 3 : in3.push_back(in[i].second);break;
            case 4 : in4.push_back(in[i].second);break;
            case 5 : in5.push_back(in[i].second);break;
            case 6 : in6.push_back(in[i].second);break;
            case 7 : in7.push_back(in[i].second);break;
            case 8 : in8.push_back(in[i].second);break;
            case 9 : in9.push_back(in[i].second);break;
            case 10 : in10.push_back(in[i].second);break;
            case 11 : in11.push_back(in[i].second);break;
            case 12 : in12.push_back(in[i].second);break;
            default: break;
        }
    }
    for(int i=0;i<in10.size();i++) concat_in.push_back(in10[i]);
    for(int i=0;i<in5.size();i++) concat_in.push_back(in5[i]);
    for(int i=0;i<in12.size();i++) concat_in.push_back(in12[i]);
    for(int i=0;i<in8.size();i++) concat_in.push_back(in8[i]);
    for(int i=0;i<in11.size();i++) concat_in.push_back(in11[i]);
    for(int i=0;i<in9.size();i++) concat_in.push_back(in9[i]);
    for(int i=0;i<in7.size();i++) concat_in.push_back(in7[i]);
    for(int i=0;i<in6.size();i++) concat_in.push_back(in6[i]);
    for(int i=0;i<in4.size();i++) concat_in.push_back(in4[i]);
    for(int i=0;i<in3.size();i++) concat_in.push_back(in3[i]);
    for(int i=0;i<in2.size();i++) concat_in.push_back(in2[i]);

    solve();

    answer_print();

}

#line 1 "main.cpp"
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int par[400010], rankh[400010], siz[400010], edge[400010];
void init(int n) {
	for (int i = 0; i <= n; i++) {
		par[i] = i;
		rankh[i] = 0;
		siz[i] = 1;
		edge[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) {
		edge[x]++;
		return;
	}
	if (rankh[x] < rankh[y]) {
		par[x] = y;
		siz[y] += siz[x];
		edge[y] += edge[x] + 1;
	}
	else {
		par[y] = x;
		if (rankh[x] == rankh[y])rankh[x]++;
		siz[x] += siz[y];
		edge[x] += edge[y] + 1;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int size(int x) {
	return siz[find(x)];
}
int edges(int x) {
	return edge[find(x)];
}
int n, a[200010], b[200010];
map<int, int> mp;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i] >> b[i];
		mp[a[i]] = 0;
		mp[b[i]] = 0;
	}
	int cnt = 1;
	for (pair<const int, int>& p : mp) {
		p.second = cnt;
		cnt++;
	}
	init(mp.size());
	rep(i, n) {
		unite(mp[a[i]], mp[b[i]]);
	}
	set<int> st;
	int ans = 0;
	REP(i, mp.size()) {
		if (st.find(find(i)) != st.end())continue;
		ans += min(edges(i), size(i));
		st.insert(find(i));
	}
	cout << ans << endl;
}


#include <iostream>
using namespace std;
int main()
{
	int N, M, T;
	cin>>N>>M>>T;
	int max=N;
	int A=0,B=0,C=0;
	for(int i=0;i<M;i++)
	{
		cin>>A;
		N=N-(B>A?(B-A):(A-B));
		if(N<=0)
			break;
		cin>>B;
		N=N+(B-A);
		if(N>max)
			N=max;
	}
	N=N-(T-B);
	if(N>0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

/*
提出前に確認!
- 配列は+10ぐらい余分にとっておく
- setとmultisetを間違えない
*/

/*
デバッグ時にチェック!
- RE
	配列の取りうる最大値、最小値を**すべて**チェックする
*/

int	main(void)
{
	int n, m, t;
	cin >> n >> m >> t;
	int now = n;
	int pre = 0;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		now -= a - pre;
		if (now <= 0)
		{
			cout << "No" << endl;
			return (0);
		}
		now += b - a;
		now = min(now, n);
		pre = b;
	}
	now -= t - pre;
	if (now <= 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return (0);
}


#include<bits/stdc++.h>

using namespace std;

void solve(){
	string s; cin >> s;
	int go = 0, ma = 0;
	for(char c : s){
		if(c == 'o')go++;
		if(c == '?')ma++;
	}
	int ans = 0;
	for(int i = 0; i < 10000; ++i){
		string no = to_string(i);
		while(no.size() < 4)no = '0'+no;
		string co = "xxxxxxxxxx";
		for(char c : no){
			co[c-'0']='o';
		}
		bool ok = 1;
		for(int i = 0; i < 10; ++i){
			if(co[i] == 'o' && s[i] == 'x')ok = 0;
			if(co[i] == 'x' && s[i] == 'o')ok = 0;
		}
		ans+=ok;

	}
	cout << ans << "\n";
}

int main(){
	solve();
}

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

int main()
{
  ull n, a; cin >> n;
  ull ans = 0;
  vector<ull> mod(200);
  rep(i, n)
  {
    cin >> a;
    mod.at(a % 200)++;
  }
  rep(i, 200)
  {
    if (mod.at(i) > 0) ans += mod.at(i) * (mod.at(i)-1) / 2;
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 200005
vector<int>tree[4*N];
void build_tree( int cur , int l , int r, int a[])
{
     if( l==r )
     {
            tree[cur].push_back(a[l]);
            return ;
     }
     int mid = l+(r-l)/2;
     build_tree(2*cur+1 , l , mid, a); // Build left tree
     build_tree(2*cur+2 , mid+1 , r, a); // Build right tree
     vector<int> arr(tree[2*cur+1].size() + tree[2*cur+2].size());
     merge(tree[2*cur+1].begin(), tree[2*cur+1].end(), tree[2*cur+2].begin(), tree[2*cur+2].end(), arr.begin());
     tree[cur] = arr; //Merging the two sorted arrays
}
int query(int cur,int l, int r, int x, int y, int k)
{
      if( r < x || l > y )
      {
            return 0; //out of range
      }
      if( x<=l && r<=y )
      {
              //Binary search over the current sorted vector to find elements smaller than K

              return lower_bound(tree[cur].begin(),tree[cur].end(),k)-tree[cur].begin();
      }
      int mid=l+(r-l)/2;
     return query(2*cur+1,l,mid,x,y,k)+query(2*cur+2,mid+1,r,x,y,k);
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> row[h+1], col[w+1];
    int i, mr = w+1, mc = h+1;
    for(i=1;i<=m;i++)
    {
        int x, y;
        cin >> x >> y;
        row[x].push_back(y);
        col[y].push_back(x);
        if(x == 1)
            mr = min(mr, y);
        if(y == 1)
            mc = min(mc, x);
    }
    for(i=1;i<=h;i++)
        sort(row[i].begin(), row[i].end());
    for(i=1;i<=w;i++)
        sort(col[i].begin(), col[i].end());
   // cout << "hello" << endl;
    int ans = 0;
    vector<pair<int, int>> vec;
    int arr[h+1];
    for(i=0;i<mc;i++)
        arr[i] = w+1;
    for(i=mc;i<=h;i++)
        arr[i] = 0;
    for(i=1;i<mc;i++)
    {
        if(row[i].size() == 0)
            ans+=w, arr[i] = w+1;
        else
            ans+=(row[i][0] - 1), arr[i] = row[i][0];
    }
 //   cout << ans << " " << "hello" << " " << mc << " " << mr << endl;
    build_tree(0, 0, h, arr);
   // cout << "hello" << endl;
    for(i=2;i<mr;i++)
    {
        int up;
        if(col[i].size() == 0)
            up = h;
        else
            up = col[i][0] - 1;
        // how many numbers in range [1, up] are less than 'i' that is count of 'k' such that arr[k] < i, 1 <= k <= up
        ans+=query(0, 0, h, 1, up, i);
    }
    cout << ans << '\n';
}

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

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

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

char readchar() {
  static char buf[1 << 15], *ptr = buf, *end = buf;
  if (ptr == end) ptr = buf, end = buf + fread(buf, 1, 1 << 15, stdin);
  return *ptr++;
}
void writechar(char c = 0) {
  static char buf[1 << 15], *ptr = buf;
  if (ptr == end(buf) or c == 0) fwrite(buf, 1, ptr - buf, stdout), ptr = buf;
  *ptr++ = c;
}
template <class Z = int> Z getint() {
  char c = readchar();
  bool neg = c == '-';
  Z res = neg ? 0 : c - '0';
  while (isdigit(c = readchar())) res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class Z> void putint(Z a, char delim = '\n') {
  if (a < 0) writechar('-'), a = -a;
  int d[40], i = 0;
  do d[i++] = a % 10; while (a /= 10);
  while (i--) writechar('0' + d[i]);
  writechar(delim);
}
string getstring(char delim = '\n') {
  string res;
  for (char c; (c = readchar()) != delim; ) res += c;
  return res;
}
void putstring(string s, char delim = '\n') {
  for (char c : s) writechar(c);
  writechar(delim);
}

struct bipartite_matching {
  vector<vector<int>> g;
  vector<int> r, c, vis;
  bipartite_matching(int h = 0, int w = 0) : g(h), r(h, -1), c(w, -1), vis(h) {}
  void add(int i, int j) { g[i].push_back(j); }
  bool dfs(int i) {
    if (exchange(vis[i], true)) return false;
    for (int j : g[i]) if (c[j] == -1) return r[i] = j, c[j] = i, true;
    for (int j : g[i]) if (dfs(c[j])) return r[i] = j, c[j] = i, true;
    return false;
  }
  int run() {
    while (true) {
      fill(begin(vis), end(vis), false);
      bool updated = false;
      for (int i = 0; i < (int)r.size(); ++i) if (r[i] == -1) updated |= dfs(i);
      if (not updated) break;
    }
    return r.size() - count(begin(r), end(r), -1);
  }
};

signed main(){
  int n;cin>>n;
  bipartite_matching g(n,400000);
  REP(i,n){
    int a,b;cin>>a>>b;a--;b--;
    g.add(i,a);
    g.add(i,b);
  }
  cout<<g.run()<<endl;
  //putint(g.run());
}


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

int main() {
    using ll = long long;
    const ll N = 1e6 + 10;
    ll l, r;
    cin >> l >> r;
    vector<ll> cnt(N, 0);

    ll ans = 0;
    for (ll g = 1e6; g >= 2; g--) {
        ll xk = r / g - (l - 1) / g;
        ll val = xk * xk;
        for (ll i = 2; i * g < N; i++) {
            val -= cnt[i * g];
        }

        cnt[g] = val;

        if (max(2LL, l) <= g and g <= r)
            val -= 2 * xk - 1;

        ans += val;
    }

    cout << ans << endl;
}

#pragma once
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
using namespace std;

int main() {
    long long l, r;
    cin >> l >> r;
    long long res = 0;
    vector<int> cnt(1048576, 0);
    for (long long i = 2; i <= r; i++) {
        if (cnt[i] != 0) { continue; }
        for (long long j = i; j <= r; j += i) { cnt[j]++; }
        for (long long j = i * i; j <= r; j += i * i) { cnt[j] = -1000000007; }
    }
    for (long long i = 2; i <= r; i++) {
        if (cnt[i] < 0) { continue; }
        long long cc = (r / i) - ((l - 1) / i);
        if (cnt[i] % 2) { res += (cc * (cc - 1)) / 2; }
        else { res -= (cc * (cc - 1)) / 2; }
    }
    for (long long i = max(2ll, l); i <= r; i++) { res -= (r / i - 1); }
    cout << 2 * res << '\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define hi ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef int64_t ll;
typedef long double ld;
typedef long long unsigned llu;
#define test                int test; cin>>test; while(test--)
#define loop(i,n,k)         for(int i=n;i<k;i++)
#define rloop(i,n,k)         for(int i=n;i>=k;i--)
#define INT(a)                 int a;scanf("%d",&a);
#define intin(temp)            scanf("%d",&temp);
#define longin(temp)        scanf("%lld",&temp);
#define LLI(a)                 ll a;scanf("%lld",&a);
#define DOUBLE(a)             double a;scanf("%f",&a);
#define LD(a)                 long double a;scanf("%lf",&a);
#define pb(i)                 push_back(i)
#define sz(i)                 i.size()
#define mkp(i,j)            make_pair(i,j)
#define ip                     pair<int,int>
#define lp                    pair<ll,ll>
#define FOR(i,n)            for(i=0;i<n;i++)
#define range(v)            v.begin(),v.end()
#define bye                    return 0;
#define file                freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

template<class c>
c gcd (c a,c b){
    if(b==0)
        return a;
    gcd(b,a%b);
}
template<class c>
c lcm(c a,c b){
    return a/gcd(a,b)*b;
}
template<class a>
bool prime(a n){
    for(a i=2;i<=sqrt(n);i++){
        if(n%i==0)
            return 0;
    }
    return 1;
}
bool bigger(pair<int,int>picachu,pair<int,int> qicachu){
    return (picachu.first<qicachu.first);
}void printarr(int arr[],int n){
    for(int i=0;i<n;i++)
        cout<<arr[i]<<' ';
    cout<<endl;
}
int chartoint(char c) {
    if (c >= 'a' && c <= 'z') return c - 'a';
    if (c >= 'A' && c <= 'Z') return c - 'A' + 26;
    return 52;
}
int kadane(int arr[],int n){
    int maximum= arr[0];
    int max_so_far = 0;
    for(int i=0;i<n;i++){
        max_so_far+=arr[i];
        if(max_so_far>maximum)
            maximum = max_so_far;
        if(max_so_far<0)
            max_so_far = 0;
    }
    return maximum;
}
const int MOD = 1e9+7;
void run(){
    int n,s,d;
    cin >> n >> s >> d;
    int x,y;
    bool flag = false;
    loop(i,0,n){
        cin >> x >> y;
        if(x<s && y>d){
            flag = true;
        }
    }
    if(flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main(){
    hi;
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
      freopen("error.txt", "w", stderr);
      freopen("output.txt", "w", stdout);
       #endif

       {
          run();
       }
      cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
     bye;
}

#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>

using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;

/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);

/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/

/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}

void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

ll solve(vector <ll> &A, vector <int> &T, int n, ll a) {
	ll ats=a;
	for (int i=0;i<n;i++) {
		if (T[i]==1) {
			ats+=A[i];
			}
		else {
			if (T[i]==2) {
				ats=max(ats,A[i]);
				}
			else {ats=min(ats,A[i]);}
			}
		}
	return ats;
	}

ll s(ll a,ll maz, ll did, ll suma, ll r1, ll r2) {
	if (a<=maz) {return r1;}
	if (a>=did) {return r2;}
	return a+suma;
	}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <ll> A(n);
    vector <int> T(n);
    for (int i=0;i<n;i++) {cin>>A[i]>>T[i];}
    int q;
    cin>>q;
    vector <ll> X(q);
    set<ll> Q;
    for (int i=0;i<q;i++) {cin>>X[i];Q.insert(X[i]);}
    ll maz=*Q.begin()-1;
    ll did=*Q.rbegin()+1;
    ll r1=solve(A,T,n,maz+1);
    ll r2=solve(A,T,n,did-1);
    ll suma=0;
    vector <ll> Y;
    for (ll x:Q) {Y.push_back(x);}
    sort(Y.begin(),Y.end());
    int ind1=0;
    int ind2=(int)Y.size()-1;
    while (ind2-ind1>2) {
		int c=(ind1+ind2)/2;
		if (solve(A,T,n,Y[c])>r1) {ind2=c;}
		else {ind1=c;}
		}
	while (solve(A,T,n,Y[ind2])>r1) {ind2--;}
	maz=Y[ind2];

	ind1=0;
    ind2=(int)Y.size()-1;
    while (ind2-ind1>2) {
		int c=(ind1+ind2)/2;
		if (solve(A,T,n,Y[c])>=r2) {ind2=c;}
		else {ind1=c;}
		}
	while (solve(A,T,n,Y[ind1])<r2) {ind1++;}
	did=Y[ind1];
	//cout<<ind1-1<<" "<<solve(A,T,n,Y[ind1-1])<<" "<<Y[ind1-1]<<endl;
	if (ind1>0) {
		suma=solve(A,T,n,Y[ind1-1])-Y[ind1-1];
		}
	//cout<<maz<<" "<<did<<" "<<r1<<" "<<r2<<" "<<suma<<endl;
	for (int i=0;i<q;i++) {
		ll a=X[i];
		ll ats=s(a,maz,did,suma,r1,r2);
		cout<<ats<<endl;
		}
    return 0;
}


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

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

	int a, b;
	cin >> a >> b;
	int x = (a + b) / 2, y = (a - b) / 2;
	cout << x << " " << y;
}

// https://atcoder.jp/contests/arc104/tasks/arc104_a

#include <bits/stdc++.h>
using namespace std;
// #define cerr if(false) cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define ld long double
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()

void solve() {

}

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

    int a, b;
    cin >> a >> b;

    for(int x = -1000; x <= 1000; x++) {
        for(int y = -1000; y <= 1000; y++) {
            if(x+y == a and x-y == b) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

/*

*/

// Did you read the bounds?
// Did you make typos?
// Are there edge cases (N=1?)
// Are array sizes proper (scaled by proper constant, for example 2* for koosaga tree)
// Integer overflow?
// DS reset properly between test cases?
// Is using long longs causing TLE?
// Are you using floating points?


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

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

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

//insert,find_by_order,order_of_key,lower_bound,upper_bound;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

const int N = 200;

void solve()
{

      int n , k;
      cin >> n >> k;

      for(int i = 0;i < n; i++)
      {
            int  d;
            cin >> d;

            if(d != k)
              cout << d << " ";
      }

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

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

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

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values

#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define int ll
#define each(i, a) for (auto &&i : (a))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using vp = vector<P>;
using int128 = __int128_t;//cin coutはできない
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a, b) * b;};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template <class T>
void CVEC(const T &v) {
	int c = v.size() - 1;
	for (int i = 0; i < c; i++) cout << v[i] << ' ';
	if (c > -1) cout << v[c];
	cout << '\n';
}

#pragma endregion header

signed main(){
    int n, k; cin >> n >> k;
	int now = k;
	int pos = 0;
	vector<P> a(n);
	rep(i,n) cin >> a[i].first >> a[i].second;
	sort(ALL(a));
	rep(i,n){
		if(now >= a[i].first - pos){
			now -= (a[i].first - pos);
			pos = a[i].first;
			now += a[i].second;
		}else{
			break;
		}
	}
	pos += now;
	cout << pos << endl;
}


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

const int N=3005;
const int MOD=998244353;
int n,m,p=0,q=1;
int dp[N][N];

void add(int &x,int y){
	x+=y;
	if(x>=MOD) x-=MOD;
}

int main(){
	scanf("%d%d",&n,&m);
	dp[n][m]=1;
	for(int j=n;j>=0;j--){
		for(int k=0;k<=j;k++){
			if(k%2==0) add(dp[j][k],dp[j][k/2]);
			add(dp[j][k],dp[j+1][k+1]);
		}
	}
	printf("%d\n",dp[0][0]);
	return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

//using namespace __gnu_pbds; //required
using namespace std;
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// ordered_set <int> s;
// s.find_by_order(k); returns the (k+1)th smallest element
// s.order_of_key(k); returns the number of elements in s strictly less than k

#define MOD              (998244353) // change as required
#define pb(x)            push_back(x)
#define mp(x,y)          make_pair(x,y)
#define all(x)           x.begin(), x.end()
#define print(vec,l,r)   for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define input(vec,N)     for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x)         cerr << #x << " = " << (x) << endl;
#define leftmost_bit(x)  (63-__builtin_clzll(x))
#define rightmost_bit(x) __builtin_ctzll(x)
#define set_bits(x)      __builtin_popcountll(x)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long int ll;

// highly risky #defines
#define int ll // disable when you want to make code a bit faster
#define endl '\n' // disable when dealing with interactive problems

const int MAXN = 3002;

int dp[MAXN][2*MAXN];

void solve(){
	// code starts from here
	int N, K;
    cin >> N >> K;

    for(int i = 0; i < MAXN; i++){
        dp[i][i] = 1;
        dp[i][0] = 0;
    }
    for(int i = 0; i < MAXN; i++){
        for(int j = i+1; j < 2*MAXN; j++) dp[i][j] = 0;
    }
    for(int i = 2; i <= N; i++){
        for(int j = N; j >= 1; j--){
            dp[i][j] = dp[i-1][j-1] + dp[i][2*j];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[N][K] << endl;
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

signed main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();

	int T = 1;
	// cin >> T;

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

	//cerr << getCurrentTime() << endl;
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
#define P pair<ll,ll>
#define T tuple<int, int, int>
#define PP pair<P,P>
#define ALL(a) a.begin(), a.end()

int main(){
    int n, m, q;
    cin >> n >> m >> q;
    vi w(n), v(n);
    rep(i,n) cin >> w[i] >> v[i];
    vi x(m);
    rep(i,m) cin >> x[i];

    rep(i,q){
        int l, r;
        cin >> l >> r;
        l--; r--;
        auto X = x;
        REP(j,l,r+1){
            X[j] = 1e9;
        }
        sort(ALL(X));
        vector<bool> used(n, false);
        int ans = 0;
        rep(j,m){
            if (X[j] == 1e9) continue;
            int index = -1;
            int MAX = 0;
            rep(k,n){
                if (used[k]) continue;
                if (w[k] <= X[j] && v[k] > MAX){
                    index = k;
                    MAX = v[k];
                }
            }
            if (index == -1) continue;
            used[index] = true;
            ans += MAX;
        }
        cout << ans << endl;
    }
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll mod=1e9+7;
mat I;

mat mul(mat a,mat b)
{
	int n=a.size();
	mat c(n,vll(n));
	rep(i,0,n-1)rep(j,0,n-1)rep(k,0,n-1)
	{
		c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod;
	}
	return c;
}

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return r;
}

mat p(mat a,ll b)
{
	mat r=I;
	while(b)
	{
		if(b%2)
		r=mul(r,a);
		a=mul(a,a);
		b/=2;
	}
	return r;
}
ll n,m,k,e[105][105],a[105];

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>k;

I.resize(n);
rep(i,0,n-1)
{
	I[i].resize(n);
	I[i][i]=1;
}

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

rep(i,0,m-1)
{
	int x,y;
	cin>>x>>y;
	x--;y--;
	e[x][y]=1;
	e[y][x]=1;
}
mat prod(n,vll(n));

rep(i,0,n-1)
{
	ll ed=0;
	rep(j,0,n-1)ed+=e[i][j];
	prod[i][i]=(2*m-ed)%mod;
	rep(j,0,n-1)if(e[i][j])prod[i][j]=1;
}
prod=p(prod,k);

ll den=p(2*m,k);
den=p(den,mod-2);

rep(i,0,n-1)
{
	ll ans=0;
	rep(j,0,n-1)
	{
		ans=(ans+prod[i][j]*a[j])%mod;
	}
	ans=(ans*den)%mod;
	ol(ans);on;
}
return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <algorithm>
#include <cmath>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rrep(i, m, n) for (int i = (int)(m); i > (int)(n); --i)

using namespace std;

template <typename T, typename U>
pair<T, U> tp(T a, U b) {
    return std::make_pair(a, b);
}

constexpr int MOD = 1000000007;

class ARockPaperScissors {
 public:
    void solve(std::istream& cin, std::ostream& cout) {
        int64_t x, y;
        cin >> x;
        if(int(x*1.08) < 206){
            cout << "Yay!" << endl;
        }else if(int(x*1.08) == 206){
            cout << "so-so" << endl;
        }else{
            cout << ":(" << endl;
        }
    }
};

int main() {
	ARockPaperScissors solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*

*/
ll N;
bool is_sorted(ll G[])
{
  rep(i, N-1){
    if (G[i] > G[i+1]) return false;
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  ll T;
  cin >> T;
  rep(i, T){
    cin >> N;
    ll G[N];
    ll cnt = 0;
    vector<ll> ans;
    rep(j, N) cin >> G[j];
    while (!is_sorted(G)){
      ll tmp = -1;
      if (cnt%2 == 0){
        for(ll k=0; k+1<N; k+=2){
          if (G[k] < G[k+1]) continue;
          tmp = k;
        }
        if (tmp == -1) tmp = 0;
      }
      if (cnt%2 == 1){
        for(ll k=1; k+1<N; k+=2){
          if (G[k] < G[k+1]) continue;
          tmp = k;
        }
        if (tmp == -1) tmp = 1;
      }
      swap(G[tmp], G[tmp+1]);
      ans.push_back(tmp+1);
      cnt++;
    }
    ll asz = ans.size();
    cout << asz << endl;
    rep(j, asz){
      cout << ans[j];
      if (j == asz-1) cout << endl;
      else cout << " ";
    }
  }
}


//#define DEBUG

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

const int MAXN = 2e5;
const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = LONG_LONG_MAX;
#define INIT(arr, val) fill(arr, arr+(int)(sizeof(arr)/sizeof(arr[0])), val)
#define REP(i, lb, rb, inc) for(int i = (lb); i < (rb); i += inc)
#define RREP(i, rb, lb, dec) for(int i = (rb)-1; i >= (lb); i -= dec)
typedef long long ll;
typedef queue<int> QI;
typedef vector<int> VI;
#define pb push_back
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define X real()
#define Y imag()
#define endl '\n'
#define dbg(a, b) cerr << "dbg: a " << b << endl;
#define dbg_itv(a, b, c) cerr << "dbg_itv: " << a << " " << b << " : " << c << endl
#define IOS() cin.tie(0); cout.sync_with_stdio(0); cout.tie(0)

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("O3")

PII ext_gcd(int a, int b) {
	if (b == 0) return {1, 0};
	else {
		int k = a/b;
		PII xy = ext_gcd(b, a%b);
		return {xy.S, xy.F - k*xy.S};
	}
}

signed main() {
	IOS();

	int t;
	cin >> t;
	while(t--) {
		ll n, s, k;
		cin >> n >> s >> k;
		ll g = __gcd(n, __gcd(s, k));
		n /= g, s /= g, k /= g;
		if (s % __gcd(k, n) != 0) {
			cout << "-1\n";
			continue;
		}
		ll x = ext_gcd(k, n).F;
		if (x < 0) x += n;
		cout << (x*(n-s))%n << endl;
	}

	#ifdef DEBUG
	cerr << "\nDebug Info:\n--------------------------------\n";
	#endif
}

#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int a;
    set<int> st;

    loop(i,0,n)
    {
        cin>>a;
        st.insert(a);
    }

    LL ans = 1, p = 0;
    for(int x : st)
    {
        ans = (ans * (x - p + 1)) % MOD;
        p = x;
    }

    cout<<ans<<'\n';

    return 0;
}