#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 5005, inf = 1e9;
#define fi first
#define se second
int mod = 1e9 + 7;
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    a.push_back(0);
    sort(a.begin(), a.end());
    ll ans = 1;
    for (int i = n; i > 0; i--){
        ans *= a[i] - a[i - 1] + 1;
        ans %= mod;
    }
    cout << ans;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i,j,n) for(long long i = j ; i < n ; ++i)
#define fr(i,j,n) for(long long i = j ; i >= n ; --i)
#define ones(x) __builtin_popcount(x)
#define endl '\n'
#define sz(v) v.size()

using namespace std;
//using namespace __gnu_pbds;
typedef long long  ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef deque<int> di;
typedef deque<long long> dll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpll;
/*typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
const ll N = 2e5 + 100;
const ll M = 1e5 + 100;
const ll inf = 9e18;
const ll mod = 1e9 + 7;
ll n,a[N];

ll mul(ll x,ll y){
	return (x*y)%mod;
}

void solve(){
	cin >> n;
	a[0] = 0;
	f(i,1,n+1) cin >> a[i];
	sort(a+1,a+n+1);
	ll ans = 1;
	f(i,0,n) ans = mul(ans,a[i+1]-a[i]+1);
	cout << ans << endl;
}

int main(){
	fastio;
	ll tc = 1;
	// cin >> tc;
	while(tc--) solve();
	return 0;
}


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

int main() {
  string s;
  cin>>s;
  deque<char> t;

  bool flg=false;
  range(i,0,s.size()){
    if(s[i]=='R'){
      flg=!flg;
      continue;
    }

    if(flg){
      if(!t.empty() && t.front()==s[i]){
        t.pop_front();
        continue;
      }
      t.emplace_front(s[i]);
    }else{
      if(!t.empty() && t.back()==s[i]){
        t.pop_back();
        continue;
      }
      t.emplace_back(s[i]);
    }
  }

  if(flg) reverse(t.begin(),t.end());
  for(char c:t){
    cout<<c;
  }
  cout<<endl;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second
typedef long long ll;
using Graph = vector<vector<ll>>;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

ll dp[2000][2000];
ll nCr(ll n, ll r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n%MOD;
       if(dp[n][r]) return dp[n][r]%MOD;
       return dp[n][r] = nCr(n-1,r)%MOD + nCr(n-1,r-1)%MOD;
}

ll H(ll n, ll r) {
    return nCr(n+r-1, r)%MOD;
}

int prime[10000000];
bool is_prime[100000000 + 1];

int sieve(int n) {
    int pcnt = 0;
    for(int i = 0; i <= n; i++) {
        is_prime[i] = true;
    }

    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++) {
        if(is_prime[i]) {
            prime[pcnt++] = i;
            for(int j = 2*i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    return pcnt;
}

struct UnionFind {
	//自身が親であれば、その集合に属する頂点数に-1を掛けたもの
	//そうでなければ親のid
	vector<ll> r;
	UnionFind(ll N) {
		r = vector<ll>(N, -1);
	}
	ll root(ll x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}
	bool unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}
	ll size(ll x) {
		return -r[root(x)];
	}

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

void solve1() {
    string s; cin >> s;
    for(int i = 0; i < (int)s.size(); i++) {
        if(s[i] == '.' ) {
            cout << endl;
            return;
        }
        cout << s[i];

        if(i == (int)s.size()-1) {
            cout << endl;
            return;
        }

    }
}

int main()
{
    solve1();
}


//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define up upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

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

int n;
int arr[2005];

unordered_set<int> uni;
unordered_map<int,int> m;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);

	cin>>n;
	rep(x,0,n) cin>>arr[x];

	int mn=1e9+5;
	rep(x,0,n) mn=min(mn,arr[x]);

	rep(x,0,n){
		if (uni.count(arr[x])) continue;
		uni.insert(arr[x]);

		int curr=1;
		while (curr*curr<arr[x]){
			if (arr[x]%curr==0){
				m[curr]=__gcd(m[curr],arr[x]);
				m[arr[x]/curr]=__gcd(m[arr[x]/curr],arr[x]);
			}
			curr++;
		}
		if (curr*curr==arr[x]){
			m[curr]=__gcd(m[curr],arr[x]);
		}
	}

	int ans=0;
	for (auto &it:m){
		if (it.fi==it.se && it.fi<=mn) ans++;
	}
	cout<<ans<<endl;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ks std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a)
#define fi first
#define se second

using namespace std;
const int N=2e5+10;
const ll mod=1e9+7;
const int inf=INT_MAX;

inline ll rd()
{
    ll s=0,f=0;
    char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();}
    return f?-s:s;
}
inline void out(int x)
{
    if(x>9) out(x/10);
    putchar(x%10+'0');
}

struct ttt
{
    int n,t;
    int x[N],y[N];
    set<pii> st;
    int dj(int i,int j) {return x[i]*x[j]+y[i]*y[j]; }
    int cj(int i,int j) {return x[i]*y[j]-x[j]*y[i]; }
    void init()  //数据初始化
    {

    }
    void input() //数据输入
    {
        cin>>n;
        fr(i,0,n) cin>>x[i]>>y[i];
        fr(i,1,n) x[i]-=x[0],y[i]-=y[0];t=dj(1,1);
        fr(i,1,n) st.insert({dj(1,i),cj(1,i)});
        fr(i,0,n) cin>>x[i]>>y[i];
    }
    void query() //答案求解
    {
        if(n==1) {cout<<"Yes"<<endl;return ;}
        fr(i,0,n){
            fr(j,0,n){
                if(i==j) continue;
                int nx=x[i]-x[j],ny=y[i]-y[j];
                if(nx*nx+ny*ny!=t) continue;
                int f=1;
                fr(k,0,n) if(k!=i) x[k]-=x[i],y[k]-=y[i];
                x[i]=0,y[i]=0;
                fr(k,0,n) if(k!=i&&k!=j&&!st.count({dj(j,k),cj(j,k)})) {f=0;break; }
                if(f){
                    cout<<"Yes"<<endl;
                    return ;
                }
            }
        }
        cout<<"No"<<endl;
    }
    void debug() //调试
    {

    }
} as;

int main()
{
    ks;
    //int T;cin>>T;while(T--)
    as.input(),as.query();
    return 0;
}


/// Solution No.:

/// Approach:

/// Complexity: space:  O()
///             time:   O()

/// Comment:

/// Verdict:

/// Report:

#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <string.h>
#include <climits>
#include <set>
#include <cassert>
#include <cfloat>
#include <stack>
#include <unordered_map>
#include <functional>
#include <chrono>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

/// Recommended not to use
///using namespace std;
///using namespace __gnu_pbds;

#define p(x) std::cout<<#x<<" = "<<x<<"\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod1 1000000007
#define mod2 998244353
#define absolute(x) (((x)<0)?(-(x)):(x))

/// #define _DEBUG

typedef long long int ll;
typedef unsigned long long llu;
typedef long double lld;
template <class T> using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<class T> using matrix = std::vector<std::vector<T>>;

/// lld pi = 2 * acos(0.0);   /// precision error
lld pi = 2 * acosl(0.0);

int test_case_number, test_case=1;

/// Direction Array
/// int dx[]={0, 0, 1, -1, -1, 1, -1, 1};
/// int dy[]={-1, 1, 0, 0, 1, 1, -1, -1};

/// typedef struct
/// {
///
/// } structure;

///place for problem specific functions

void function_name()
{
    int a, b, x, y;
    scanf("%d %d %d %d",&a, &b, &x, &y);
    int answer =0;
    if(a==b)
    {
        answer = x;
    }
    else if(b<a)
    {
        b++;
        answer= x+(a-b)*(std::min(2*x, y));
    }
    else if(a<b)
    {
        answer = x+(b-a)*(std::min(2*x, y));
    }
    printf("%d\n", answer);
}
void function_name(int v1, int v2, int v3)
{

}
void function_name(std::string line)
{

}
class initial_works
{
public:

    void with_test_case_number()
    {
        scanf("%d", &test_case_number);
        ///getchar();
        while(test_case <= test_case_number)
        {
            function_name();
            test_case++;
        }
    }

    void single_iteration()
    {
        function_name();
    }

    void without_test_case_number()
    {
        int v1, v2, v3;
        while(scanf("%d %d %d", &v1, &v2, &v3)==3 && v1!=0)
        {
            function_name(v1, v2, v3);
            test_case++;
        }
    }

    void eoof()
    {
        char dummy_char_array[100]={0};
        while(scanf("%[^\n]", &dummy_char_array)!=EOF)
        {
            ///it only takes the absence of one getchar to ruin your life. Don't understand remove the getchar below and then input the sample input
            getchar();
            ///if not given getchar. the dummu_char_array will not take new input as there is newline after the first input is taken. It will continue with the previous value.
            /// So, the function will run with same argument.
            std::string line = dummy_char_array;
            function_name(line);
            test_case++;
        }
    }
};

int main()
{
    //std::ios_base::sync_with_stdio(false);
    #ifdef _DEBUG
        ///freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    initial_works a;
    a.single_iteration();

    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,x,y;
    cin>>a>>b>>x>>y;
    int ans = x+min(abs(b+1-a)*y,abs(b-a)*y);
    if(a>b){
    	ans = min(ans,2*x*(a-b)-x);
	}else if(b>a){
		ans = min(ans,2*x*(b-a)+x);
	}
	cout<<ans;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  long long sum = 0;
  long long sum2 = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += (long long)(N - 1) * A.at(i) * A.at(i);
    sum2 += A.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    sum2 -= A.at(i);
    sum -= 2 * A.at(i) * sum2;
  }
  cout << sum << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define hell        1000000007
const int nax=1e5+20;

int main(){

//  int t; cin >> t;

    int t = 1;

    while(t--){

        int n; cin >> n;

        map<ll, ll> cnt;
        ll ans = 0;

        for(int i = 0; i < n; i++) {
            ll x;
            cin >> x;
            cnt[x]++;
        }

        for(int i = -200; i <= 200; i++) {
            for(int j = -200; j <= 200; j++) {
                ans += cnt[i]*cnt[j]*(i-j)*(i-j);
            }
        }

        ans /= 2;

        cout << ans;
        cout << endl;

    }

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n){
        if (i==n-1) break;
        double i_ans = n / double(n-i-1);
        ans += i_ans;
    }
    printf("%.10f\n", ans);
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

int N;
using Double = long double;

void MAIN() {
    scanf("%d", &N);

    Double e = 0;
    for (int i=N-1; i>=1; i--) {
	e = e + (Double)(N) / i;
    }
    printf("%.20f\n", (double)e);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


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

int main()
{

    int n;
    cin>>n;

    int a=1;

    while(n--)
    a*=2;

    queue<pair<int,int>>q;

    for(int i=0;i<a;i++)
    {
        int x;
        cin>>x;
        q.push({x,i+1});
    }

    while(q.size()>2)
    {
        int k=q.size();

        for(int i=0;i<k;i+=2)
        {
            int a,b,in1,in2;
        a=q.front().first;in1=q.front().second;
        q.pop();
        b=q.front().first;in2=q.front().second;
        q.pop();

        if(a>b)
        {
            q.push({a,in1});
        }
        else
        {
            q.push({b,in2});
        }
        }

    }

     int a1,b,in1,in2;
        a1=q.front().first;in1=q.front().second;
        q.pop();
        b=q.front().first;in2=q.front().second;
        q.pop();

        if(a1>b)
        {
            cout<<in2;
        }
        else
        {
            cout<<in1;
        }

    return 0;
}

#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int size = 2<<(n-1);
	vector<int> a(size);
	for(int i=0;i<size;i++){
		scanf("%d",&a[i]);
	}
	int index1, index2;
	int max1 = 0;
	int max2 = 0;
	for(int i=0;i<(size/2);i++){
		if(max1<a[i]){
			max1 = a[i];
			index1 = i;
		}
	}
	for(int i=(size/2);i<size;i++){
		if(max2<a[i]){
			max2 = a[i];
			index2 = i;
		}
	}
	if(max1==max(max1,max2)){
		printf("%d",index2+1);
	}
	else{
		printf("%d",index1+1);
	}
}


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

int main(){
  ll N;
  cin >> N;
  ll M = N, cnt = 0;
  vector<ll> A(10,0);
  while(M > 0){
    A[cnt] = M % 10;
    M /= 10;
    cnt++;
  }
  ll rev = 0, cnt2 = 0;
  while(true){
    if(A[cnt2] == 0) cnt2++;
    else break;
  }
  rep(i,cnt){
    rev += A[i];
    rev *= 10;
  }
  rev /= 10;
  rev *= pow(10,cnt2);
  if(N == rev) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

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

int main() {
  string S;string s="";cin>>S;
  for(int i=S.size()-1;i>=0;i--){

  if(S.at(i)=='6')s+="9";
    else{
  if(S.at(i)=='9')s+="6";
      else {s+=S.at(i);}}}
  cout<<s;
}


/*

    /////    /////            //////////////////
    /////   /////             //////////////////
    /////  /////              /////
    ///// /////               /////
    //////////        o       /////
    /////\\\\\                /////
    ///// \\\\\               /////
    /////  \\\\\              //////////////////
    /////   \\\\\             //////////////////

    date updated : 20-10-2020

*/

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define PI 3.14159265359
#define boostIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define deb(i) cout << "#i : " << i << endl
#define deb2(i, n) cout << "#i : " << i << " #n : " << n << endl
#define rep(i,a,b) for(int i = a; i < b; i++)
#define vi vector<int>
#define iv(vec) for(auto &c : vec) cin >> c;
#define sint set<int>
#define in insert
#define finds(e, s) find(e.begin(), e.end(), s)
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define sortf(c) sort(c.begin(), c.end())
#define sortr(c) sort(c.begin(), c.end(), greater<>())
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) ((int)(x).size())

inline int min(int a, int b) { return (a < b) ? a : b;}
inline int max(int a, int b) { return (a > b) ? a : b;}
inline int gcd(int a, int b){if(a==0) return b;return gcd(b%a,a);}

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

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

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

const int MOD =998244353;
const int hell=1000000007;
const int N = 100005;
const int INF = 1e18;

/*________________________________________________________________________________*/

void ___solve() {

        int x, y; cin >> x >> y;
        if(abs(x-y) < 3) cout << "Yes" << endl;
        else cout << "No" << endl;
}

int32_t main(int32_t argc, char* argv[])
{
    boostIO;
    cin.exceptions(cin.failbit);
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int TT = 1;
    //cin >> TT;
    while(TT--) {

        ___solve();
    }
    return 0;
}

#include<bits/stdc++.h>
#define x first
#define y second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mem(x,val) memset(x,val,sizeof x)
#define pii pair<int,int>
#define pb emplace_back
#define ar array
#define int long long
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define F0R(i, n) FOR(i, 0, n)
#define FOR1(i, n) FOR(i, 1, n+1)
#define wopen(x) freopen((x),"w",stdout)
#define ropen(x) freopen((x),"r",stdin)
using namespace std;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

const int N = 4e5 + 5;
int n, a, b, cnt, ist, ans;
vector<int> g[N];
bitset<N> vis;

void dfs(int u, int p = 0){
    cnt++;
    for(int v : g[u]){
        if(v == p) continue;
        if(vis[v]) {
            ist = 0;
            continue;
        }
        vis[v] = 1;
        dfs(v, u);
    }
}

signed main(void){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    if(min(n,m)+3 > max(n,m)){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define pll pair<LL,LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;
int read(){
	char ch=getchar(); int x=0,fl=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') fl=-1;
	for(;isdigit(ch);ch=getchar()) x=(x<<3)+(x<<1)+(ch-'0');
	return x*fl;
}
const int N=200005;

int n,m,q,maxn=1e8;
LL a[N],b[N];
void upd(pll &a,pll b){
	a.fi+=b.fi; a.se+=b.se;
}
struct seg{
	int ls[N<<5],rs[N<<5],cnt;
	LL C[N<<5],S[N<<5];

	pll qry(int rt,int l,int r,int ql,int qr){
		if(!rt||ql>qr) return mp(0LL,0LL);
		if(ql<=l&&r<=qr) return mp(C[rt],S[rt]);
		int mid=(l+r)>>1;
		pll res=mp(0LL,0LL);
		if(ql<=mid) upd(res,qry(ls[rt],l,mid,ql,qr));
		if(qr>mid) upd(res,qry(rs[rt],mid+1,r,ql,qr));
		return res;
	}
	void mdf(int rt,int l,int r,int pv,LL sgn){
		C[rt]+=sgn; S[rt]+=1LL*sgn*pv;
		if(l==r) return;
		int mid=(l+r)>>1;
		if(pv<=mid){
			if(!ls[rt]) ls[rt]=++cnt;
			mdf(ls[rt],l,mid,pv,sgn);
		}
		else{
			if(!rs[rt]) rs[rt]=++cnt;
			mdf(rs[rt],mid+1,r,pv,sgn);
		}
	}
}t[2];

int main(){
	n=read(); m=read(); q=read();
	t[0].cnt=t[1].cnt=1;
	for(int i=1;i<=n;i++) t[0].mdf(1,0,maxn,a[i]=0,1);
	for(int i=1;i<=m;i++) t[1].mdf(1,0,maxn,b[i]=0,1);
	LL ans=0LL;
	while(q--){
		int opt=read(),x=read(),y=read();
		opt--;
		if(!opt){
			t[0].mdf(1,0,maxn,a[x],-1);
			if(y<a[x]){
				pll tmp=t[1].qry(1,0,maxn,y,a[x]);
				ans-=1LL*a[x]*tmp.fi;
				ans+=1LL*tmp.se;
				tmp=t[1].qry(1,0,maxn,0,y-1);
				ans-=1LL*tmp.fi*a[x];
				ans+=1LL*tmp.fi*y;
			}
			else if(y>a[x]){
				pll tmp=t[1].qry(1,0,maxn,a[x],y);
				ans-=1LL*tmp.se;
				ans+=1LL*y*tmp.fi;
				tmp=t[1].qry(1,0,maxn,0,a[x]-1);
				ans-=1LL*a[x]*tmp.fi;
				ans+=1LL*y*tmp.fi;
			}
			a[x]=y;
			t[0].mdf(1,0,maxn,y,1);
		}
		else{
			t[1].mdf(1,0,maxn,b[x],-1);
			if(y<b[x]){
				pll tmp=t[0].qry(1,0,maxn,y,b[x]);
				ans-=1LL*b[x]*tmp.fi;
				ans+=1LL*tmp.se;
				tmp=t[0].qry(1,0,maxn,0,y-1);
				ans-=1LL*tmp.fi*b[x];
				ans+=1LL*tmp.fi*y;
			}
			else if(y>b[x]){
				pll tmp=t[0].qry(1,0,maxn,b[x],y);
				ans-=1LL*tmp.se;
				ans+=1LL*y*tmp.fi;
				tmp=t[0].qry(1,0,maxn,0,b[x]-1);
				ans-=1LL*b[x]*tmp.fi;
				ans+=1LL*y*tmp.fi;
			}
			b[x]=y;
			t[1].mdf(1,0,maxn,y,1);
		}
		cout<<ans<<'\n';
	}
	return 0;
}

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

template<int mod> struct ModInt{
    long long x=0;
    constexpr ModInt(long long x=0):x((x%mod+mod)%mod){}
    constexpr ModInt operator+(const ModInt& r)const{return ModInt(*this)+=r;}
    constexpr ModInt operator-(const ModInt& r)const{return ModInt(*this)-=r;}
    constexpr ModInt operator*(const ModInt& r)const{return ModInt(*this)*=r;}
    constexpr ModInt operator/(const ModInt& r)const{return ModInt(*this)/=r;}
    constexpr ModInt& operator+=(const ModInt& r){ if((x+=r.x)>=mod) x-=mod; return *this;}
    constexpr ModInt& operator-=(const ModInt& r){ if((x-=r.x)<0) x+=mod; return *this;}
    constexpr ModInt& operator*=(const ModInt& r){ if((x*=r.x)>=mod) x%=mod; return *this;}
    constexpr ModInt& operator/=(const ModInt& r){ return *this*=r.inv();}
    constexpr bool operator==(const ModInt& r){ return x == r.x;}
    constexpr bool operator!=(const ModInt& r){ return x != r.x;}
    ModInt inv() const {
        long long s=x,sx=1,sy=0,t=mod,tx=0,ty=1;
        while(s%t!=0){
            long long temp=s/t,u=s-t*temp,ux=sx-temp*tx,uy=sy-temp*ty;
            s=t;sx=tx;sy=ty;
            t=u;tx=ux;ty=uy;
        }
        return ModInt(tx);
    }
    ModInt pow(long long n) const {
        ModInt a=1;
        ModInt b=*this;
        while(n>0){
            if(n&1) a*=b;
            b*=b;
            n>>=1;
        }
        return a;
    }
    friend constexpr ostream& operator<<(ostream& os,const ModInt<mod>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<mod>& a) {return is >> a.x;}
};
using mint = ModInt<MOD>;

int main(){
    int n;
    cin >> n;
    char aa,ab,ba,bb;
    cin >> aa >> ab >> ba >> bb;

    if(n == 2 || (ab == 'B' && bb == 'B')) cout << 1 << endl;
    else if(ab == 'A' && aa == 'A') cout << 1 << endl;
    else if((ab == 'A' && aa == 'B' && ba == 'B') || (ab == 'B' && bb == 'A' && ba == 'A')){
        cout << mint(2).pow(n-3) << endl;
    }else{
        vector<mint> fib(n,0);
        fib[1] = 1;
        for(int i=2;i<n;i++) fib[i] = fib[i-1] + fib[i-2];
        cout << fib[n-1] << endl;
    }

    return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define              ll              long long

#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()

#define            pb                push_back
#define          sz(a)               (int)a.size()
#define         fastio               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long

ll pw(ll a,ll b){ll r=1;while(b>0){if(b&1)r=(r*a);a=(a*a);b/=2;}return r;}
ll gcd(ll a, ll b) {if(!b)return a;return gcd(b,a % b);}
ll lcm(ll a,ll b){return(a*b)/gcd(a,b);}
ll fact(ll n, ll mod){ll ret=1;for(ll i=1;i<=n;i++)ret=(ret*i)%mod;return ret;}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(ll i=5;i*i <= n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}

void solve()
{
	int k;
	cin >> k;
	vector<int> cnt(10,k);
	string a,b;
	cin >> a >> b;
	for(int i = 0; i <4;i++){
		cnt[a[i] - '0']--;
		cnt[b[i] - '0']--;
	}
	int wins = 0;
	int games= 0 ;
	for(int A = 1;A<=9;A++)
	{
		for(int B = 1;B<=9;B++)
		{
			if(A==B)continue;
			cnt[A]--;
			cnt[B]--;
			if(cnt[A]<0||cnt[B]<0){
				cnt[A]++;
				cnt[B]++;
				continue;
			}
			games += (cnt[A]+1) * (cnt[B] + 1);
			int score_a=0,score_b=0;
			vector<int> v1(10,0),v2(10,0);
			for(int i =0;i < 4;i++){
				v1[a[i] -'0']++;
				v2[b[i]-'0']++;
			}
			v1[A]++;
			v2[B]++;
			for(int i = 1;i<=9;i++){
				score_a+=i * pw(10,v1[i]);
				score_b+=i * pw(10,v2[i]);
			}
			if(score_a>score_b){
				wins+=(cnt[A]+1)*(cnt[B]+1);
			}
			cnt[A]++;
			cnt[B]++;
		}
	}
	for(int A = 1;A<=9;A++)
	{
		if(cnt[A]<2)continue;
		games+=(cnt[A] - 1) * cnt[A];
		int score_a=0,score_b=0;
			vector<int> v1(10,0),v2(10,0);
			for(int i =0;i < 4;i++){
				v1[a[i] -'0']++;
				v2[b[i]-'0']++;
			}
			v1[A]++;
			int B = A;
			v2[B]++;
			for(int i = 1;i<=9;i++){
				score_a+=i * pw(10,v1[i]);
				score_b+=i * pw(10,v2[i]);
			}
			if(score_a>score_b){
				wins+=cnt[A] * (cnt[A] -1);
			}
			cnt[A]++;
			cnt[B]++;
	}
	cout << fixed << setprecision(16) << double(wins)/double(games);
}

int32_t main()
{
	//fastio;
    int t = 1;
   	//cin >> t;
    while(t--)
    {
        solve();
    }
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<set>
#include<algorithm>
#include<string.h>
#include<map>
#define LL long long
#define INF 0x3f3f3f3f
#define mod 100000007
using namespace std;
int k,cnt1[100],cnt2[100];
string s, t;
int main() {
	cin >> k >> s >> t;
	for (int i = 0; i < 4; ++i) {
		cnt1[s[i] - '0']++;
		cnt2[t[i] - '0']++;
	}
	double ans = 0;
	for (int i = 1; i <= 9; ++i) {
		if (cnt1[i] + cnt2[i] >= k)
			continue;
		int x1=0;
		cnt1[i]++;
		for (int k = 1; k <= 9; ++k)
			x1 += k * (int)pow(10, cnt1[k]);
		for (int j = 1; j <= 9; ++j) {
			if (cnt1[j] + cnt2[j] >= k)continue;
			cnt2[j]++;
			int x2 = 0;
			for (int k = 1; k <= 9; ++k)
				x2 += k * (int)pow(10, cnt2[k]);
			if (x1 > x2)
				ans += ((double)k - ((double)cnt1[i] + cnt2[i] - 1-(i==j))) * ((double)k - ((double)cnt1[j] + cnt2[j] - 1-(i==j)) - (i == j));
			cnt2[j]--;
		}
		cnt1[i]--;
	}
	cout << ans / (9.0 * k - 8) / (9.0 * k - 9) << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef struct Point {
	int x,y,z;
}Point;
int f(Point a ,Point b){
	int v1 = abs(a.x - b.x);
	int v2 = abs(a.y - b.y);
	int v3 = max(0,b.z - a.z);
	return v1+v2+v3;
}
int main(){
	int n; cin>>n;
	Point a[n];
	int x,y,z;
	for(int i=0;i<n;i++) { cin>>x>>y>>z; a[i]={x,y,z}; }
	int dp[1<<n][n];
	const int INF = 0x3f3f3f3f;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			dp[i][j]=INF;
		}
	}
	dp[1][0]=0;
	for(int i=2;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
			int tgt = i^(1<<j);
			for(int k=0;k<n;k++){
				dp[i][j]=min(dp[i][j],dp[tgt][k]+f(a[k],a[j]));
			}
		}
	}
}
int ans = INF;
for(int i=0;i<n;i++){ ans = min(ans,dp[(1<<n)-1][i]+f(a[i],a[0])); }
cout<<ans<<'\n';
return 0;
}


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

int main()
{
    int N,M;
    string a;
    random_device rnd;

    cin >> N >> M;

    for(int i=0; i<M; i++) {
        cin >> a;
    }

    for(int y=0; y<N; y++) {
        for(int x=0; x<N; x++){
            char a = rnd()%8 + 'A';
            cout << a;
        }

        cout << endl;
    }
};

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

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

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

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

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

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


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a)
#define dumparr(a,n)
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

template <size_t N>
class GreaterThan {
public:
   bool operator() (const std::bitset<N> &lhs, const std::bitset<N> &rhs) const
   {
      size_t i = N;
      while ( i > 0 ) {
         if ( lhs[i-1] == rhs[i-1] ) {
            i--;
         } else if ( lhs[i-1] > rhs[i-1] ) {
            return true;
         } else {
            return false;
         }
      }
      return false;
   }
};
void solve(long long A, long long B){
  vector<vector<ll>> m(B-A+1,vector<ll>(B-A+1));
  For(i,B-A+1){
    FOR(j,i+1,B-A+1){
      m[i][j]=m[j][i]=gcd(i+A,j+A);
    }
  }
  vector<ll> allnum(B-A+1);
  bitset<73> start;
  For(i,B-A+1){
    start[i]=true;
    allnum[i]=i+A;
  }
  map<bitset<73>,ll,GreaterThan<73>> q;
  q[start]=1;
  auto addmap = [](map<bitset<73>, ll,GreaterThan<73>> &q, const bitset<73> &bs, ll x) {
    if(q.count(bs))
    {
      q[bs]+=x;
    }
    else
    {
      q[bs]=x;
    }
  };
  for (auto [primes, cnt] : q)
  {
    if (primes.none())
    {
      continue;
    }
    ll i = 0;
    for (i = 0; i < 73; i++)
    {
      if (primes[i])
        break;
    }
    auto newprimes = primes;
    newprimes[i] = false;
    addmap(q, newprimes, cnt);
    For(j, B - A + 1)
    {
      if (m[i][j] != 1)
      {
        newprimes[j] = false;
      }
    }
    addmap(q, newprimes, cnt);
  }
  bitset<73> clean;
  cout<<q[clean]<<endl;
}

int main(){
  cout<<setprecision(1000);
  long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
  solve(A, B);
  return 0;
}


#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using ll = int64_t;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>
#define vv(T) vector<vector<T>>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  for (auto e : v) {
    o << e << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1

using ld = long double;

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  v(string) ss(N);
  cin >> ss;
  v(bitset<100>) es(N);
  bitset<100> vs;
  auto dfs = [&](auto dfs, int r, int v)->void {
    vs[v] = true;
    es[v][r] = true;
    F0R(i, N) {
      if (!vs[i] && ss[v][i] == '1') {
        dfs(dfs, r, i);
      }
    }
  };
  F0R(i, N) {
    vs.reset();
    dfs(dfs, i, i);
  }

  ld r = 0;

  F0R(i, N) {
    int pc = 0;
    F0R(j, N) {
      if (es[i][j]) pc++;
    }
    //show(pc);
    r += (ld)N / pc;
  }

  cout << std::fixed << std::setprecision(15);
  cout << (r/N);
}
#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 4e2 + 10;
ll n, a[maxN], ans;
int read();
int main(){
	n = read();
	for(int i = 0; i < n; i++){
		ll x = read() + 200;
		a[x]++;
		for(int j = 0; j <= 400; j++) ans += (x - j) * (x - j) * a[j];
	}
	cout << ans;
	return 0;
}
int read(){
	int s = 0, f = 1; char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(isdigit(ch)) s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
	return s * f;
}


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

  num = (n*k*(100*n + k + 101))/2;

  cout << num << endl;
}

//{{
/*
 * Created at: 06/21/21 22:14:44
 *
 * FB: https://facebook.com/tgbaodeeptry
 * From Viet Nam with Love :D
 *
 */

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

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)
#define RED(i, a, b) for (int i = int(a); i > int(b); --i)
#define FOR(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define FOD(i, a, b) for (int i = int(a); i >= int(b); --i)
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define endl '\n'

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

const int MOD = 1e9 + 7;
const int MAXN = 1e5;
const int INF = INT_MAX;

template <class T> void re(T &x) { cin >> x; };
template <class T> void re(vector<T> &v, int n) {
  FOR(i, 0, n - 1) cin >> v[i];
};
template <class T> void re(vector<T> &v, int f, int t) {
  FOR(i, f, t) cin >> v[i];
};
template <class T> void re(T v[], int n) { FOR(i, 0, n - 1) cin >> v[i]; };
template <class T> void re(T *v, int f, int t) { FOR(i, f, t) cin >> v[i]; };
template <class H, class... T> void re(H &v, T &... args) {
  re(v);
  re(args...);
};

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
template <typename T> void dbg_out(vector<T> a) {
  for (auto c : a) cerr << ' ' << c;
  cerr << endl;
};
template <typename T> void dbg_out(vector<T> a, int n) {
  FOR(i, 0, n - 1) cerr << ' ' << a[i];
  cerr << endl;
};
template <typename T> void dbg_out(vector<T> a, int u, int v) {
  FOR(i, u, v) cerr << ' ' << a[i];
  cerr << endl;
};
template <typename T> void dbg_out(T a[]) {
  for (auto c : a) cerr << ' ' << c;
  cerr << endl;
};
template <typename T> void dbg_out(T a[], int n) {
  FOR(i, 0, n - 1) cerr << ' ' << a[i];
  cerr << endl;
};
template <typename T> void dbg_out(T a[], int u, int v) {
  FOR(i, u, v) cerr << ' ' << a[i];
  cerr << endl;
};

#if defined(_CRUN) || defined(_RUN)
#define pd(...)                         \
  cerr << "(L:" << __LINE__ << "): "    \
       << "[" << #__VA_ARGS__ << "] =", \
      dbg_out(__VA_ARGS__)
#else
#define pd(...)
#endif

#if defined(_CRUN)
#define c_input() freopen("input", "r", stdin)
#define c_output() freopen("output", "r", stdin)
#else
#define c_input()
#define c_output()
#endif

void ps(){};
template <typename Head, typename... Tail> void ps(Head H, Tail... T) {
  cout << H;
  ps(T...);
};
template <typename T> void ps(vector<T> a, int n) {
  FOR(i, 0, n - 1) cout << a[i] << ' ';
};
template <typename T> void ps(T a[], int n) {
  FOR(i, 0, n - 1) cout << a[i] << ' ';
};

ll add_mod(ll a, ll b) { return ((a % MOD) + (b % MOD)) % MOD; }
ll sub_mod(ll a, ll b) { return ((a % MOD) - (b % MOD) + MOD) % MOD; }
ll mul_mod(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll pow_mod(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) ans = mul_mod(ans, a);
    a = mul_mod(a, a);
    b >>= 1;
  };
  return ans;
};

ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }
ll pow(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) ans *= a;
    a *= a;
    b >>= 1;
  };
  return ans;
};

void solve();
void init();
bool multi_test = false;
// ---- main below ----- ///

int main() {
  fast_io();
  init();

  int T = 1;
  if (multi_test) re(T);

  FOR(i, 1, T) solve();
}
//}}

void init() {
  // multi_test = true;
}

void solve() {
  int n, k;
  re(n, k);

  // n floor, k room
  // each floor: i * k * 100 + k * (k + 1) / 2

  ps((ll) (k * 100) * (n * (n + 1) / 2) + (k * (k + 1) / 2) * n);
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/scc>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<ll> c(n);
    rep(i,n) c[i] = a[i]*2+b[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    sort(c.rbegin(),c.rend());
    ll now = 0;
    rep(i,n){
        now += c[i];
        if(now > sum){
            cout << i+1 << endl;
            return 0;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2005;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll cnt = 0;
    vector<ll>v(n);
    for(int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        cnt -= x;
        v[i] = 2 * x + y;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    while(cnt <= 0)
    {
        cnt += v.back();
        v.pop_back();
        ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_set>

using namespace std;

long long ipow(long long x, long long y) {
    long long ans = 1;
    for (long long i = 0; i < y; i++) {
        ans *= x;
    }
    return ans;
}

long long int keta(long long int n) {
    long long int ans = 0;
    while (true)
    {
        if (n == 0)break;
        n /= 10;
        ans++;
    }
    return ans;
}

int main() {
    vector<int> ans(1001, 0);

    int n, m;
    cin >> n >> m;

    int temp;

    for (int i = 0; i < n; i++) {
        cin >> temp;
        ans[temp]++;
    }

    for (int i = 0; i < m; i++) {
        cin >> temp;
        ans[temp]++;
    }

    for (int i = 0; i < 1001; i++) {
        if (ans[i] == 1) {
            cout << i << " ";
        }
    }

    return 0;
}

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

int main()
{
ll n,q; cin >> n >> q;
vector<ll> a(n);
rep(i,n) cin >> a[i];
pair<ll,ll> k[q];
rep(i,q){
    cin >> k[i].first;
    k[i].second=i;
}
sort(k,k+q);
vector<ll> ans(q);
ll num=0;
rep(i,q){
    while(a[num]<=k[i].first+num && num<n) num++;
    ans[k[i].second]=k[i].first+num;
}
rep(i,q) cout << ans[i] << endl;
}


///Bismillahir Rahmanir Raheem
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define PI 2 * acos(0.0)
#define NFS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define fore(arr) for (auto &x : (arr))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define SORT(v) sort((v).begin(), (v).end())
#define FIND(v, x) ((v).find(x) != (v).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) x *(y / gcd(x, y))
#define MAX 2000010
#define bug cout << "*_*\n"
using namespace std;
int toint(char c)
{
    return (c - 48);
}
void solve()
{
    ll n;
    double x;
    cin >> n >> x;
    double sum = 0;
    int ans = -1, flag = 1;
    for (int i = 1; i <= n; i++)
    {
        double a, b;
        cin >> a >> b;
        sum += (a / 100.0) * b;
        if ((sum - x) > 0.000001 && flag)
        {
            flag = 0;
            ans = i;
        }
    }
    cout << ans << endl;
}
int main()
{
    NFS;
#ifndef ONLINE_JUDGE
    freopen("D:/code/C++/OJ/in.txt", "r", stdin);
    freopen("D:/code/C++/OJ/out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

int N;
int M;
int C[10011];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, N) {
	int x;
	scanf("%d", &x);
	C[x] |= 1;
    }

    REP (i, M) {
	int x;
	scanf("%d", &x);
	C[x] |= 2;
    }

    VI ans;
    REP (i, 10011) if (C[i] == 1 || C[i] == 2) ans.push_back(i);
    rprintf("%d", ans.begin(), ans.end());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
    IOS;

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

    clock_t startTime=clock();

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<a*d-b*c;

    cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

int main() {
  int N, C;
  cin >> N >> C;

  map<int, ll> mp;
  rep(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    mp[a] += c;
    mp[b + 1] -= c;
  }

  ll ans = 0;
  int p = 0;
  ll s = 0;
  for (auto a : mp) {
    ans += min(s, (ll)C) * (a.first - p);
    s += a.second;
    p = a.first;
  }

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


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef   long long int ll;
typedef long double db;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.14159265358979323846264338327950288419716939937510
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define at(s,pos) *(s.find_by_order(pos))
#define set_ind(s,val) s.order_of_key(val)
long long int M = 1e9 + 7 ;
long long int inf = 9 * 1e18;
//CLOCK
ll begtime = clock();
#define time() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//CLOCK ENDED
ll n, m;
// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (deg < 0)
		return 0;
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
//binomial
ll modinv(ll n) {
	return binpow(n, M - 2);
}
//GCD
ll gcd (ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}
v<v<pll>> adj;
v<ll> used, col;
void dfs(ll s, ll p) {
	used[s] = 1;
	col[s] = p;
	for (auto u : adj[s]) {
		if (!used[u.fi]) {
			if (p == u.se) {
				dfs(u.fi, (p + 1) % n);
			}
			else {
				dfs(u.fi, u.se);
			}
		}
	}
	used[s] = 2;
}
int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n >> m;
	adj.resize(n);
	used.assign(n, 0);
	rep(i, m) {
		cin >> x >> y >> z;
		x--; y--;
		adj[x].eb(y, z - 1);
		adj[y].eb(x, z - 1);
	}
	col.resize(n);
	dfs(0, 0);
	rep(i, n) {
		cout << col[i] + 1 << '\n';
	}

	return 0;

}

#include <bits/stdc++.h>
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef long double ld; typedef pair<lint, lint> plint; typedef pair<ld, ld> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;++i)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;--i)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
#define fi first
#define se second
struct fast_ios { fast_ios() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
template<class T> auto add = [](T a, T b) -> T { return a + b; };
template<class T> auto f_max = [](T a, T b) -> T { return max(a, b); };
template<class T> auto f_min = [](T a, T b) -> T { return min(a, b); };
template<class T> using V = vector<T>;
using Vl = V<lint>; using VVl = V<Vl>;
template< typename T > ostream& operator<<(ostream& os, const vector< T >& v) {
	for (int i = 0; i < (int)v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : "");
	return os;
}
template< typename T >istream& operator>>(istream& is, vector< T >& v) {
	for (T& in : v) is >> in;
	return is;
}
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; }
lint gcd(lint a, lint b) { if (b == 0) return a; else return gcd(b, a % b); }
lint ceil(lint a, lint b) { return (a + b - 1) / b; }
lint digit(lint a) { return (lint)log10(a); }
lint e_dist(plint a, plint b) { return abs(a.fi - b.fi) * abs(a.fi - b.fi) + abs(a.se - b.se) * abs(a.se - b.se); }
lint m_dist(plint a, plint b) { return abs(a.fi - b.fi) + abs(a.se - b.se); }
void Worshall_Floyd(VVl& g) { REP(k, SZ(g)) REP(i, SZ(g)) REP(j, SZ(g)) chmin(g[i][j], g[i][k] + g[k][j]); }
const lint MOD1000000007 = 1000000007, MOD998244353 = 998244353, INF = 1e18;
lint dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 }, dy[8] = { 0, 1, 0, -1, -1, -1, 1, 1 };
bool YN(bool flag) { cout << (flag ? "YES" : "NO") << endk; return flag; } bool yn(bool flag) { cout << (flag ? "Yes" : "No") << endk; return flag; }
struct Edge {
	lint from, to;
	lint cost;
	Edge(lint u, lint v, lint c) {
		cost = c;
		from = u;
		to = v;
	}
	bool operator<(const Edge& e) const {
		return cost < e.cost;
	}
};
struct WeightedEdge {
	lint to;
	lint cost;
	WeightedEdge(lint v, lint c = 1) {
		to = v;
		cost = c;
	}
	bool operator<(const WeightedEdge& e) const {
		return cost < e.cost;
	}
};
using WeightedGraph = V<V<WeightedEdge>>;
typedef pair<lint, plint> tlint;
typedef pair<plint, tlint> qlint;
typedef pair<string, lint> valstring;

lint A, B, C, D;
int main() {
	cin >> A >> B >> C >> D;
	yn(!(A * B <= D && D <= A * C));
}


#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()

#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"

//#define inf 1<<30

// isupper() -> upper case check
// tolower() -> convert upper to lower case
// idx = str.find("bear", pos)) != string::npos =>substring find
// Tuple access -> get<0>(v[i])
// cmnt - ctrl []
// stoi("...") -> decimel
// istringstream ss(str) while(ss >> n)

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tpl = tuple<int, int, int>;
using pcc = pair<char, char>;

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

int dr[] = {-1, 0, 1,  0};// up, right, down, left
int dc[] = { 0, 1, 0, -1};

// King moves similar to 8 direction
//int dr[] = {-1, -1, 0, 1, 1,  1, 0, -1};
//int dc[] = { 0,  1, 1, 1, 0, -1,-1, -1};

// Knight moves
int kr[] = {-1,  1, -2, -2, -1, 1,  2,  2};
int kc[] = {-2, -2, -1,  1,  2, 2, -1,  1};
// diagonal moves
int dgr[] = {-1, -1,  1, 1};
int dgc[] = { 1, -1, -1, 1};

int ans, k;
vector<pii>v, ara;
int cnt[111];

void fun(int idx)
{
    if(idx == k) {
        int cur = 0;
        for(pii p: ara) {
            //printf("%d %d\n", p.ff, cnt[p.ff]);
            if(cnt[p.ff] >= 1 && cnt[p.ss] >= 1) cur++;
        }
        ans = max(ans, cur);
        return;
    }

    int x = v[idx].ff;
    ++cnt[x];
    fun(idx+1);
    --cnt[x];

    int y = v[idx].ss;
    ++cnt[y];
    fun(idx+1);
    --cnt[y];
    return;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    //vector<pii>ara;

    for(int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        ara.pb({x, y});
    }
    //int k;
    cin >> k;

    //int cnt[n*n];
    //memset(cnt, 0, sizeof cnt);

    for(int i=0; i<k; i++) {
        int x, y;
        cin >> x >> y;

        v.pb({x, y});
        //if(!cnt[x]) cnt[x] = 1;
        //else cnt[y]++;
    }

    //int ans = 0;

    fun(0);

    cout << ans << endl;
}

int main()
{
    fast_io;

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

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

    return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(m),b(m);
	rep(i,m) cin >> a[i] >> b[i];
	int k;
	cin >> k;
	vector<int> c(k),d(k);
	rep(i,k) cin >> c[i] >> d[i];
	int ans = 0;
	rep(is,1<<k){
		int sum = 0;
		vector<int> sara(n+1);
		rep(i,k){
			if(is>>i&1)sara[d[i]]++;
			else sara[c[i]]++;
		}
		rep(i,m){
			if(sara[a[i]] == 0) continue;
			if(sara[b[i]] == 0) continue;
			sum++;
		}
		ans = max(ans,sum);
	}
	cout << ans << endl;
	return 0;
}

// cout << fixed << setprecision(15) <<  << endl;


#pragma region Macros
#include <bits/stdc++.h>
#if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
#endif
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class T>using vec = vector<T>;
template<class T, class U>using umap = unordered_map<T, U>;
using ll = long long;
using P = pair<ll, ll>;
using vl = vec<ll>;
#define fi first
#define se second
#define el endl
constexpr ll INF = numeric_limits<ll>::max()/2-1;
#pragma endregion

#pragma region IOMacros
template<class T>
istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;}
template<class T>
ostream &operator<<(ostream &stream, vec<T>& objs){REP(i, objs.size())stream << objs[i] << " ";stream << el;return stream;}

#define I(T, ...) ;T __VA_ARGS__;__i(__VA_ARGS__);
void __i() {}
template<class T, class... Ts> void __i(T&& o, Ts&&... args){cin >> o;__i(forward<Ts>(args)...);}

void O() {cout << el;}
template<class T, class... Ts> void O(T&& o, Ts&&... args){cout << o << " ";O(forward<Ts>(args)...);}
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

struct edge{ll to, cost, k;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    fill(ALL(d), INF);
  }

  void add_edge(ll s, ll t, ll cost, ll k){
    edge e;
    e.to = t, e.cost = cost;
    e.k=k;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    fill(ALL(d), INF);
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        ll t = ((d[v]+e.k-1)/e.k)*e.k;
        if(d[e.to]>t+e.cost){
          d[e.to] = t+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};

void Main(){
    I(ll, N, M, X, Y);
    X--;Y--;
    graph g(N);
    REP(i, M){
        I(ll, A, B, T, K);
        A--;B--;
        g.add_edge(A, B, T, K);
        g.add_edge(B, A, T, K);
    }
    g.dijkstra(X);
    if(g.d[Y] == INF){
        cout << -1 << el;return;
    }
    cout << g.d[Y] << el;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll z = 0, mod = 1000000007, MAX = 10000000000;

int main(){
  ll N;
  cin >> N;

  vector<ll> data(1, 0);
  ll now = 0;
  for (ll i = 0; i < N; i++){
    ll a;
    cin >> a;

    now = a - now;
    if (i % 2 == 1){
      data.push_back(now);
    }
    else{
      data.push_back(now * -1);
    }
  }

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

  ll ans = 0, combo = 0, prev = data[0];
  for (ll i : data){
    if (i == prev){
      combo++;
    }
    else{
      ans += (combo * (combo - 1)) / 2;
      combo = 1;
      prev = i;
    }
    //cout << i << ' ' << combo << ' ' << ans << endl;
  }
  ans += (combo * (combo - 1)) / 2;

  cout << ans << endl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n;
    cin>>n;
    pair<ll,ll>p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i].fi>>p[i].se;
    }
    ll val,val1,ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            val=p[j].se-p[i].se;
            val1=p[j].fi-p[i].fi;
            ll val2=__gcd(val,val1);
            val/=val2;
            val1/=val2;
            if(abs(val)<abs(val1))
            {
                ans++;
            }
            if(val1==1 && abs(val)==1)
            {
                ans++;
            }

        }
    }
    cout<<ans<<endl;

}

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

struct UnionFind {
	// それ自身の場合はsize の-1 掛けたもの
	// それ以外は自分の親のid
	vector<int> r;

	UnionFind(int N) {
		r = vector<int>(N, -1);
	}

	int root(int x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}

	bool unite(int x, int y){
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x,y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}

	int size(int x){
		return -r[root(x)];
	}
};

const int ncol= 400000;

int main() {
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	UnionFind UF(ncol);
	map<int,int> deg;// 頂点i に接続する 辺の数
	set<int> v;// 頂点
	rep(i,n){
		cin >> a[i] >> b[i];
		UF.unite(a[i],b[i]);
		deg[a[i]]++;
		deg[b[i]]++;
		v.insert(a[i]);
		v.insert(b[i]);
	}
	// 頂点数、辺の数
	map<int,int> nhen;// 辺の数
	for (auto it : v) {
		int g=UF.root(it);
		nhen[g] += deg[it];
	}
	// for (auto it : v) {
	// 	int g=UF.root(it);
	// 	cout << "id: " << g << ", n edge: " << nhen[g] << endl;
	// }
	vector<bool> touch(ncol,false);
	int ans=0;
	for (auto it : v) {
		int g=UF.root(it);
		int nv = UF.size(it);
		int nedge = nhen[g]/2;
		// cout << "id: " << g << ", n vert: " << nv << ", n edge: " << nedge << endl;
		if (touch[g]==false) {
			if (nedge >= nv ) {
				ans += nv;
			} else {
				ans += nv-1;
			}
		}
		touch[g] = true;
	}
	cout << ans << endl;
	return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P = pair<ll,ll>;
    const int INF=1001001001;
    const int mod=998244353;

    int main() {
      int N,M;
      cin>>N>>M;
      vector<int>w(N);
      int wmx=0;
      rep(i,N){cin>>w[i];chmax(wmx,w[i]);}
      vector<int>l(M),v(M);
      int vmn=INF;
      vector<P>b(M);
      rep(i,M){cin>>l[i]>>v[i];b[i]={v[i],l[i]};chmin(vmn,v[i]);}
      if(wmx>vmn){cout<<-1<<endl;return 0;}
      sort(b.begin(),b.end());
      rep(i,M){
        if(i>0){chmax(b[i].second,b[i-1].second);}
      }
      vector<int>num(N);
      iota(num.begin(),num.end(),0);
      ll ans=1e18;
      do{
        vector<ll>dp(N);
        rep(i,N){
          ll mx=0;
          for(int j=i;j<N;j++){
            mx+=w[num[j]];
            int r=lower_bound(b.begin(),b.end(),P(mx,0))-b.begin();
            if(r-1>=0){chmax(dp[j],dp[i]+b[r-1].second);}
          }
        }
        chmin(ans,dp[N-1]);
      }while(next_permutation(num.begin(),num.end()));

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

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

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-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 >> M;
	vector<int>weight(N);
	for (auto &i : weight)cin >> i;
	vector<int>l(M);
	vector<int>d(M);
	for (int i = 0; i < M; i++) {
		cin >> l[i] >> d[i];
	}
	if (*max_element(weight.begin(), weight.end()) > *min_element(d.begin(), d.end())) {
		cout << -1 << endl;
		return 0;
	}
	vector<int>sum(1 << N);
	for (int i = 0; i < 1 << N; i++) {
		for (int j = 0; j < N; j++) {
			if ((i >> j) & 1) {
				sum[i] += weight[j];
		//		cout << i << " " << sum[i] << endl;
			}
		}
	}
	map<int, int>mp;
	for (int i = 0; i < M; i++) {
		mp[d[i]] = 0;
	}
	for (auto i : sum)mp[i] = 0;
	int cnt = 0;
	for (auto &i : mp) {
		i.second = cnt++;
	}
	vector<int>mn(cnt);
	for (int i = 0; i < M; i++) {
		mn[mp[d[i]]] = max(l[i], mn[mp[d[i]]]);
	}
	for (int i = 1; i < cnt; i++) {
		mn[i] = max(mn[i], mn[i - 1]);
	}
	int ans = MOD;
	vector<int>p(N);
	for (int i = 0; i < N; i++) {
		p[i] = i;
	}
	do {
		vector<int>place(N);
		for (int i = 1; i < N; i++) {
			for (int j = 0; j < i; j++) {
				int bit = 0;
				for (int k = j; k <= i; k++) {
					bit |= 1 << p[k];
				}
			//	cout << i << " " << j << " " << bit << endl;
				place[i] = max(place[i], place[j] + mn[mp[sum[bit]] - 1]);
			}
		}
	//	cout << place.back() << endl;
		ans = min(ans, place.back());
	} while (next_permutation(p.begin(), p.end()));
	cout << ans << endl;
}


#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#if __has_include(<atcoder/all>)
#include <atcoder/all>
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++)
#define rrep(i, a, b) for(int i = (int)(a); i >= (int)(b); i--)
const int MOD = 1000000007;
const int MOD2 = 998244353;
const ll INF = 1e18;
const ld PI = acos(-1);

signed main() {
    int N,K;
    cin >> N >> K;
    vector<vector<int>> A(N,vector<int>(N));
    rep(i,0,N-1) rep(j,0,N-1) cin >> A[i][j];
    int ok=INF,ng=-1;
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        vector<vector<int>> newA(N+K,vector<int> (N+K,0));
        rep(i,0,N-1){
            rep(j,0,N-1){
                if(A[i][j]<=mid){
                    newA[i][j]++;
                    newA[i][j+K]--;
                    newA[i+K][j]--;
                    newA[i+K][j+K]++;
                }
            }
        }
        rep(i,0,N+K-1){
            rep(j,0,N+K-1){
                if(i&&j) newA[i][j]+=newA[i][j-1]+newA[i-1][j]-newA[i-1][j-1];
                else if(i) newA[i][j]+=newA[i-1][j];
                else if(j) newA[i][j]+=newA[i][j-1];
            }
        }
        bool isok=false;
        int base=(K*K+1)/2;
        rep(i,0,N-1){
            rep(j,0,N-1){
                //cout << newA[i][j] << endl;
                if(newA[i][j]>=base){
                    isok=true;
                }
            }
        }
        if(isok){
            ok=mid;
        }
        else{
            ng=mid;
        }
    }
    cout << ok << endl;
}

#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

ll Atoi(string s, ll radix, ll m)
{
	ll ans = 0;
	for (ll i = 0; i < s.size(); i++)
	{
		char t = s[i];
		if (ans > m/radix)
			return 0;
		ans = ans * radix + t - '0';
	}
	return ans  <= m;
}

int main()
{
	string x;
	ll m;
	cin >> x >> m;

	if (x.size() == 1) {
		cout << Atoi(x, 10, m) << endl;
		return 0;
	}

	ll d = *max_element(x.begin(), x.end()) - '0' + 1;
	ll l = d, r = m;
	ll ans = 0;
	for (; l<=r; ) {
		ll mid = (l + r) / 2;
		if (Atoi(x, mid,m)) {
			ans = mid;
			l = mid + 1;

		}
		else {
			r = mid - 1;
		}
	}
	//cout << ans << " " << d << endl;
	if (d > ans) {
		cout << 0 << endl;
	}
	else {
		cout << ans - d + 1 << endl;
	}
}


#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define endl '\n'
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    s<<endl;
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++) {
        if(n%i==0) {
            ret.pb(i);
            if(i*i!=n) {
                ret.pb(n/i);
            }
        }
    }
    sort(ALL(ret));
    return ret;
}

vector<pair<ll,ll>> factorize(ll n) {
    vector<pair<ll,ll>> res;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i) continue;
        res.emplace_back(i,0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}

int solve(){
    ll n;
    cin>>n;
    Vec div = divisor(n*2);
    ll ans = 0;
    dbg(div.size());
    Each(x, div){
        ll tmp = 2*n/x + 1 -x;
        if(tmp%2==0){
            ans++;
        }
    }
    out(ans);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    scanf("%lld",&n);
    ll ans=0;
    for(int i=1;n%2==0;i++)
    {
        n=n/2;
    }
    if(n==1)
    {
        printf("2\n");
        return 0;
    }
    for(int i=1; i<sqrt(n); i=i+2)
    {
        if(n%i==0&&(n/i)%2!=0)
        {
            ans=ans+2;
        }
        else if(n%i==0&&(n/i)%2==0)
        {
            ans=ans+1;
        }
        else
        {
            ;
        }
    }
    float a=sqrt(n);
    int b=(int)a;
    if(b==a&&b%2!=0)
        ans++;
    printf("%lld\n",ans*2);
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = 2; i <= 2*n; i++){
        if(i + k > 2*n) continue;
        if(i + k < 2) continue;
        ll tmp;
        if(i <= n+1) tmp = i-1;
        else tmp = 2*n-i+1;
        if(i + k <= n+1) tmp *= k + i - 1;
        else tmp *= 2*n - k - i + 1;
        ans += tmp;
    }
    cout << ans << endl;
}

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
long long n,m,i,ans;
long long f(long long x)
{
	if(x<2||x>n+n) return 0;
	return min(x-2+1,n+n-x+1);
}
int main()
{
	cin>>n>>m;
	fz(i,2,n+n){
		ans+=f(i+m)*f(i);
	}
	cout<<ans<<endl;
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
using namespace std;
template<class T> struct cLtraits_identity{
  using type = T;
}
;
template<class T> using cLtraits_try_make_signed =
  typename conditional<
    is_integral<T>::value,
    make_signed<T>,
    cLtraits_identity<T>
    >::type;
template <class S, class T> struct cLtraits_common_type{
  using tS = typename cLtraits_try_make_signed<S>::type;
  using tT = typename cLtraits_try_make_signed<T>::type;
  using type = typename common_type<tS,tT>::type;
}
;
template<class S, class T> inline auto max_L(S a, T b)
-> typename cLtraits_common_type<S,T>::type{
  return (typename cLtraits_common_type<S,T>::type) a >= (typename cLtraits_common_type<S,T>::type) b ? a : b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Moebius_L(T n){
  T i;
  int res = 1;
  if(n%4==0){
    return 0;
  }
  if(n%2==0){
    n /= 2;
    res = -res;
  }
  for(i=3;i*i<=n;i+=2){
    if(n%i==0){
      n /= i;
      res = -res;
    }
    if(n%i==0){
      return 0;
    }
  }
  if(n > 1){
    res = -res;
  }
  return res;
}
long long L;
long long R;
long long res;
long long solve(){
  long long i;
  long long res = 0;
  res += R - L;
  for(i=(2);i<(R+1);i++){
    res -=Moebius_L(i)* (R/i - L/i) * (R/i - L/i);
  }
  for(i=(max_L(2, L+1));i<(R+1);i++){
    res -= (R / i) * 2;
  }
  if(L == 0){
    res--;
  }
  return res;
}
int main(){
  rd(L);L += (-1);
  rd(R);
  res = solve();
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay version 20210619-1 [beta]

// --- original code ---
// ll L, R, res;
//
// ll solve(){
//   ll i, res = 0;
//   res += R - L;
//   rep(i,2,R+1) res -= Moebius(i) * (R/i - L/i) * (R/i - L/i);
//   rep(i,max(2,L+1),R+1) res -= (R / i) * 2;
//   if(L == 0) res--;
//   return res;
// }
//
// {
//   rd(L--,R);
//   res = solve();
//   wt(res);
// }

#include <bits/stdc++.h>
using namespace std;
struct binary_indexed_tree{
  int N;
  vector<int> BIT;
  binary_indexed_tree(int N): N(N), BIT(N + 1, 0){
  }
  void add(int i, int x){
    i++;
    while (i <= N){
      BIT[i] += x;
      i += i & -i;
    }
  }
  int sum(int i){
    int ans = 0;
    while (i > 0){
      ans += BIT[i];
      i -= i & -i;
    }
    return ans;
  }
  int sum(int L, int R){
    return sum(R) - sum(L);
  }
};
int main(){
  int N;
  cin >> N;
  vector<int> l(N), r(N);
  for (int i = 0; i < N; i++){
    int t;
    cin >> t >> l[i] >> r[i];
    l[i] *= 2;
    r[i] *= 2;
    if (t == 3 || t == 4){
      l[i]++;
    }
    if (t == 1 || t == 3){
      r[i]++;
    }
  }
  vector<int> x;
  for (int i = 0; i < N; i++){
    x.push_back(l[i]);
    x.push_back(r[i]);
  }
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  int M = x.size();
  for (int i = 0; i < N; i++){
    l[i] = lower_bound(x.begin(), x.end(), l[i]) - x.begin();
    r[i] = lower_bound(x.begin(), x.end(), r[i]) - x.begin();
  }
  binary_indexed_tree L(M), R(M);
  long long ans = 0;
  for (int i = 0; i < N; i++){
    ans += i;
    ans -= R.sum(l[i] + 1);
    ans -= L.sum(r[i], M);
    L.add(l[i], 1);
    R.add(r[i], 1);
  }
  cout << ans << endl;
}


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

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

const int MAXN = 2e5+5;

int d[MAXN];
int t_in[MAXN];
int t_out[MAXN];
int timer = 0;
vi edges[MAXN];

void dfs(int v, int depth) {
	d[v] = depth;
	t_in[v] = timer++;
	for (int u : edges[v]) {
		dfs(u, depth + 1);
	}
	t_out[v] = timer++;
}

int main() {
	int n;
	scanf("%d", &n);
	fore(i, 2, n) {
		int x;
		scanf("%d", &x);
		edges[x].pb(i);
	}
	dfs(1, 0);
	vector<vi> lst(n + 1);
	fore(i, 1, n) {
		lst[d[i]].pb(t_in[i]);
	}
	forn(i, n) {
		sort(lst[i].begin(), lst[i].end());
	}
	int queries;
	scanf("%d", &queries);
	forn(q, queries) {
		int u, d;
		scanf("%d%d", &u, &d);
		if (lst[d].empty()) {
			printf("0\n");
			continue;
		}
		auto beg = lower_bound(lst[d].begin(), lst[d].end(), t_in[u]);
		auto end = upper_bound(lst[d].begin(), lst[d].end(), t_out[u]);
		printf("%d\n", end - beg);
	}
}

//================code===================//

//#define TLE

#ifdef TLE
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <ctime>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long

#define ld double
#define fa(i,a,b) for(LL i=(a);i<(LL)(b);++i)
#define fd(i,a,b) for(LL i=(a);i>(LL)(b);--i)
#define setp tuple<LL,LL,LL>
#define setl pair<int,int>
#define micro 0.000001

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }

#ifdef OHSOLUTION
#define ce(t) cerr<<t
#define AT cerr << "\n=================ANS=================\n"
#define AE cerr << "\n=====================================\n"
#define DB(a) cerr << __LINE__ << ": " << #a << " = " << (a) << endl;
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#else
#define AT
#define AE
#define ce(t)
#endif

pair <int, int> vu[9] = { {0,1},{1,0},{0,1} ,{-1,0},{1,1},{1,-1}, {-1,1} , {-1,-1},{-1,-1} }; //RDLU EWSN

template<typename T, typename U> void ckmax(T& a, U b) { a = a < b ? b : a; }
template<typename T, typename U> void ckmin(T& a, U b) { a = a > b ? b : a; }
struct gcmp { bool operator()(LL a, LL b) { return a < b; } bool operator()(setl& a, setl& b) { return a.second < b.second; } };
struct lcmp { bool operator()(LL a, LL b) { return a > b; } bool operator()(setl& a, setl& b) { return a.second > b.second; } };

const int max_v = 2e5 + 7;
const int max_k = 5e2 + 7;
const int bsz = (1ll << 10) + 7;
const int INF = 1e9 + 7;
const LL LNF = (LL)5e18 + 7ll;
LL mod = 1e9 + 7;
template<typename T, typename U> void MOD(T& a, U b) { a += b; if (a >= mod) a -= mod; }

vector<int> adj[max_v];
vector<int> edge[max_v];
int t=-1;
setl in[max_v];

void dfs(int u,int d=0)
{
	in[u].first = ++t;
	edge[d].push_back(in[u].first);
	for (auto& v : adj[u]) dfs(v,d+1);
	in[u].second = t;
}

int main()
{
#ifdef OHSOLUTION
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int v; ci(v);

	fa(i, 1, v)
	{
		int x; ci(x); --x;
		adj[x].push_back(i);
	}

	dfs(0);

	fa(i, 0, v) sort(edge[i].begin(), edge[i].end());

	int q; ci(q);
	while (q--)
	{
		int x, y; ci(x >> y); --x;

		int ret = upper_bound(edge[y].begin(), edge[y].end(), in[x].second) - lower_bound(edge[y].begin(), edge[y].end(), in[x].first);
		co(ret << "\n");
	}

	return 0;
}


#include "bits/stdc++.h"
#pragma region header
using i32 = int;
using i64 = long long int;
using u32 = unsigned int;
using u64 = unsigned long long int;
using isize = ptrdiff_t;
using usize = size_t;

constexpr size_t operator"" _uz(unsigned long long v) { return size_t(v); }

inline u64 popcount(const u64 v) {
#ifdef _MSC_VER
  return u64(__popcnt64(v));
#else
  return u64(__builtin_popcount(v));
#endif
}

class range {
  struct range_iterator {
    usize itr;
    constexpr range_iterator(const usize pos) noexcept : itr(pos) {}
    constexpr void operator++() noexcept { ++itr; }
    constexpr bool operator!=(const range_iterator& other) const noexcept {
      return itr != other.itr;
    }
    constexpr usize operator*() const noexcept { return itr; }
  };
  const range_iterator first, last;

 public:
  constexpr range(const usize first_, const usize last_) noexcept
      : first(first_), last(last_) {}
  constexpr range_iterator begin() const noexcept { return first; }
  constexpr range_iterator end() const noexcept { return last; }
};

template <class F>
class rec_lambda {
  F f;

 public:
  constexpr rec_lambda(F&& f_) : f(std::forward<F>(f_)) {}
  template <class... Args>
  constexpr auto operator()(Args&&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};

namespace cs_helper {
void zip_sort_renumber([[maybe_unused]] std::vector<usize>& order) {}
template <class T, class... Args>
void zip_sort_renumber(std::vector<usize>& order, std::vector<T>& head,
                       Args&... args) {
  usize n = order.size();
  assert(n == head.size());
  std::vector<T> sorted_head(n);
  for (usize i = 0; i < n; ++i) sorted_head[i] = head[order[i]];
  head = std::move(sorted_head);
  zip_sort_renumber(order, args...);
}
}  // namespace cs_helper

template <class T, class... Args>
std::vector<usize> zip_sort(std::vector<T>& head, Args&... args) {
  usize n = head.size();
  std::vector<std::pair<T, usize>> tmp(n);
  for (usize i = 0; i < n; ++i) tmp[i] = std::make_pair(head[i], i);
  std::sort(tmp.begin(), tmp.end());
  std::vector<usize> order(n);
  for (usize i = 0; i < n; ++i) order[i] = tmp[i].second;
  cs_helper::zip_sort_renumber(order, head, args...);
  return order;
}
#pragma endregion

void main_() {
  /*u64 K, N, M;
  std::cin >> K >> N >> M;
  std::vector<u64> A(K);
  for (auto& el : A) std::cin >> el;
  if ((N > M and N % M == 0) or (N < M and M % N == 0)) {
    std::cout << 0 << '\n';
    return;
  }

  long double ok = 10000000000.0, ng = 0.;
  while (ok - ng > 0.000001) {
    const auto mid = (ok + ng) / 2;
    i64 left = 0, right = 0;
    for (usize i : range(0, K)) {

    }
  }*/

  usize N;
  std::cin >> N;

  std::vector<u64> T1, T2, T3, T4;
  for (u64 i : range(1, 10001)) {
    if (i % 2 == 0 and i % 3 == 0 and i % 5 == 0)
      T4.emplace_back(i);
    else if (i % 2 == 0 and i % 3 == 0)
      T1.emplace_back(i);
    else if (i % 2 == 0 and i % 5 == 0)
      T2.emplace_back(i);
    else if (i % 3 == 0 and i % 5 == 0)
      T3.emplace_back(i);
  }

  std::vector<u64> ans;
  ans.emplace_back(T1[0]);
  ans.emplace_back(T2[0]);
  ans.emplace_back(T3[0]);
  for (usize i : range(1, T1.size())) ans.emplace_back(T1[i]);
  for (usize i : range(1, T2.size())) ans.emplace_back(T2[i]);
  for (usize i : range(1, T3.size())) ans.emplace_back(T3[i]);
  for (usize i : range(1, T4.size())) ans.emplace_back(T4[i]);

  for (usize i : range(0, N)) {
    std::cout << ans[i] << ' ';
  }
  // AtCoder Regular Contest 118
}

int main() { main_(); }

#include <bits/stdc++.h>
using namespace std;
int last[120000],a[120000];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=2*i;j<=n;j+=i){
			last[j]=i;
		}
	}
	for(int i=1;i<=n;i++) {
		a[i]=a[last[i]]+1;
		printf("%d ",a[i]);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 20;
bool visited[MAX];
int adj[MAX];
int n, m;

vector<int> bfs(int source) {
    queue<int> q;
    q.push(source);
    visited[source] = true;
    vector<int> touched;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        touched.push_back(cur);
        fori (i, 0, n) {
            if (adj[cur] & (1 << i)) {
                if (!visited[i]) {
                    visited[i] = true;
                    q.push(i);
                }
            }
        }
    }
    return touched;
}

int cant[3];
void roll(const vector<int> &v, int idx, ll &total) {
    if (idx == (int) v.size()) {
        total++;
        return;
    }
    int k = v[idx];
    fori (i, 0, 3) {
        if (cant[i] & (1 << k)) continue;
        int prv_cant = cant[i];
        cant[i] |= adj[k];
        roll(v, idx + 1, total);
        cant[i] = prv_cant;
    }
}

ll calc(const vector<int> &v) {
    ll total = 0;
    roll(v, 0, total);
    return total;
}

void solve() {
    cin >> n >> m;
    fori (i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x] |= 1 << y;
        adj[y] |= 1 << x;
    }
    ll ans = 1;
    fori (i, 0, n) {
        if (!visited[i]) {
            vector<int> v = bfs(i);
            ans *= calc(v);
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define precision     \
  cout.precision(30); \
  cerr.precision(10);
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define forn(n) for (int i = 1; i <= n; i++)
#define forlr(l, r) for (int i = l; i != r; (l > r ? i-- : i++))
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x, y) make_pair(x, y)
#define all(x) x.begin(), x.end()
#define pc(x) __builtin_popcount(x)
#define pcll(x) __builtin_popcountll(x)
#define F first
#define S second
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void ioi(string name) {
  freopen((name + ".in").c_str(), "r", stdin);
  freopen((name + ".out").c_str(), "w", stdout);
}
ll n, m, e, k = 1, a[25];
vector<ll> t, g[25];
bitset<25> w;
void dfs(ll v) {
  t.pb(v);
  w[v] = 1;
  for (auto to : g[v])
    if (!w[to]) dfs(to);
}
void kek(ll v = 0) {
  if (sz(t) <= v) {
    e++;
    return;
  }
  ll x = t[v];
  for (int i = 1; i <= 3; i++) {
    ll ok = 1;
    for (auto j : g[x])
      if (a[j] == i) goto bruh;
    a[x] = i;
    kek(v + 1);
    a[x] = 0;
  bruh:;
  }
}
int main() {
  speed;
  precision;
  // code
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    ll u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  for (int i = 1; i <= n; i++) {
    if (w[i]) continue;
    t.clear();
    dfs(i);
    e = 0;
    kek();
    k *= e;
  }
  cout << k;
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


#include <cstdio>
#include <algorithm>
#include <cmath>

const int N = 100 + 5;
const double eps = 1e-8;

struct Vertice {
	double x, y;
	void set_point(double x_, double y_) { x = x_, y = y_; }
	void set_line(int y_) { x = 205, y = y_; }
	bool line() const { return x > 204; }
};
double distance(const Vertice &lhs, const Vertice &rhs) {
	if(!lhs.line() && !rhs.line())
		#define sq(x) ((x) * (x))
		return std::sqrt(sq(lhs.x - rhs.x) + sq(lhs.y - rhs.y));
		#undef sq
	else if(lhs.line() && rhs.line()) return std::abs(lhs.y - rhs.y);
	else return std::abs(lhs.y - rhs.y);
}

Vertice a[N];
int n;

int fa[N];
void init() { for(int i = 1; i <= n + 2; i++) fa[i] = i; }
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

bool check(double x) {
	init();
	for(int i = 1; i <= n + 2; i++)
		for(int j = 1; j <= n + 2; j++)
			if(i != j && x - distance(a[i], a[j]) > eps) {
				int x = find(i), y = find(j);
				if(x != y) fa[x] = y;
			}
	// std::printf("check %lf\n", x);
	if(find(1) == find(2)) return false;
	else return true;
}

int main() {
	std::scanf("%d", &n);
	a[1].set_line(100);
	a[2].set_line(-100);
	for(int i = 3; i <= n + 2; i++) {
		double x, y;
		std::scanf("%lf%lf", &x, &y);
		a[i].set_point(x, y);
	}
	// for(int i = 1; i <= n + 2; i++)
	// 	for(int j = 1; j <= n + 2; j++) {
	// 		if(i < 3) std::printf("Line[%d]\t<-->\t", (int)a[i].y);
	// 		else std::printf("(%.0lf, %.0lf) \t<-->\t", a[i].x, a[i].y);
	// 		if(j < 3) std::printf("Line[%d]\t= ", (int)a[j].y);
	// 		else std::printf("(%.0lf, %.0lf)  \t= ", a[j].x, a[j].y);
	// 		std::printf("%.3lf\n", distance(a[i], a[j]));
	// 	}
	double l = 0, r = 200;
	while(r - l > eps) {
		double mid = (l + r) / 2;
		if(check(mid * 2)) l = mid;
		else r = mid;
	}
	std::printf("%.5lf", l);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<double, ll> pdl;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N;
pll A[105];

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

double len(pll a, pll b) {
    double x = a.first - b.first;
    double y = a.second - b.second;
    return sqrt(x * x + y * y);
}

bool check(double r) {
    UnionFind uf(N + 2);

    REP(i, N) {
        FOR(j, N, i + 1) {
            if (len(A[i], A[j]) < 2 * r)
                uf.unit(i, j);
        }
    }

    REP(i, N) {
        if (100 - A[i].second < 2 * r)
            uf.unit(N, i);
        if (A[i].second + 100 < 2 * r)
            uf.unit(N + 1, i);
    }

    return !uf.same(N, N + 1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }

    double ok = 0, ng = 101;
    REP(_, 100) {
        double mid = (ok + ng) * 0.5;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }

    cout << OF64 << ok << endl;
}