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

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

#define all(v) (v).begin(), (v).end()
#define ar array
#define PB push_back
#define sz(x) (int)(x).size()

template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v)
{
    os << '{';
    string sep;
    for (const T &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}
void dbg_out()
{
    cerr << endl;
}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

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

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

void solve()
{
	int n;
	cin >> n;
	vector<ll> v(n+1);
	for (int i=1;i<=n;i++)cin >> v[i];
	if (n==1){
		cout << v[1]<<"\n";
		return;
	}
	vector<ll> f(n+1);
	f[0] = 1;
	for (int i=1;i<=n;i++){
		if (i==1) f[i] = 2;
		else if (i==2) f[i] = 3;
		else f[i] = (f[i-1] + f[i-2])%MOD;
	}
	dbg(f[n], v[1]);
	ll ans = f[n-1]*v[1]%MOD;
	for (int i=2;i<=n;i++){
		ll curadd = 0, cursub = 0;
		curadd = f[n-i]*f[i-2]%MOD;
		if (n-i-1>=0&&i-3>=0) cursub = f[n-i-1]*f[i-3]%MOD;
		else if (n-i-1>=0) cursub = f[n-i-1]%MOD;
		else if (i-3>=0) cursub = f[i-3]%MOD;
		else cursub = 1;
		ans += (curadd-cursub+MOD)*v[i]%MOD;
		ans%=MOD;
	}
	cout << (ans+MOD)%MOD << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int testcase=1;
    //cin >> testcase;
    while (testcase--)
    {
        solve();
    }
}

// FIRST THINK THEN CODE.

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

using namespace std;

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

#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define cld complex<ld>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vld vector<ld>
#define vvld vector<vector<ld>>
#define vpll vector<pll>
#define vcld vector<cld>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define PI acos(-1)
#define endl "\n"
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define mset(a,val) memset(a,val,sizeof(a));
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
#define FOR(i,a,b)  for(ll i=a;i<=b;i++)
#define FORR(i,a,b)  for(ll i=a;i>=b;i--)
const ll M = 1000000007;
const ll MM = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define ordered_set tree<pll, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>

ll begtime = clock();
#define end_routine() cerr << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}

const ll N = 2e5 + 5;

void OJ() {

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif

}

int main() {

  IOS;

  OJ();

  ll n; cin >> n;
  map<ll, ll>dp;
  dp[-1] = dp[0] = 1;
  for (ll i = 1; i <= n; i++) {
    dp[i] = (dp[i - 1] + dp[i - 2]) % M;
  }

  ll ans = 0;

  for (ll i = 1; i <= n; i++) {
    ll x; cin >> x;
    ll temp = (dp[n - i] * dp[i - 2] - dp[n - i - 1] * dp[i - 3]) % M;
    if (temp < 0)temp += M;
    ans = (ans + temp * x) % M;
  }
  if(ans<0)ans+=M;
  cout << ans << endl;

  return 0;

}


#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
// #define INF (1<<9+9)
const int INF = 0x3fffffff;
// const long long INF = 1LL<<50;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)998244353;
// const int mod =(int)998244353;
const int mod =(int)1e9+7;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//int N, M, K, T, H, W, L, R;
// long long int N, M, K, T, H, W, L, R
ll RS(ll N,ll P){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2);
            return t*t;
        }else{
            return N*RS(N,P-1);
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-c<<endl;
    return 0;

}

#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if (a == b) ans = c;
    if (b == c) ans = a;
    if (a == c) ans = b;
    cout << ans << endl;
    return 0;
}


#include<stdio.h>
#include<stdlib.h>

int search(long *arr, int left,int right, long num){
  int mid = (left+right)/2;
  if(left == right){
    return left;
  }
  if(arr[mid] == num){
    return mid;
  }else if(num < arr[mid]){
    return search(arr,left,mid,num);
  }else{
    return search(arr,mid+1,right,num);
  }
}

int main(){
  int n,q,i,j;
  long *a,k,*sum;

  scanf("%d %d",&n,&q);
  a = (long*)malloc(sizeof(long)*n);
  sum = (long*)malloc(sizeof(long)*n);
  for(i=0;i<n;i++){
    scanf("%ld",a+i);
    sum[i] = a[i]-i-1;
  }
  for(i=0;i<q;i++){
    scanf("%ld",&k);
    j = search(sum,0,n-1,k);
    if(j == 0){
      printf("%ld\n",k);
    }else if(j == n-1 && sum[n-1] < k){
      printf("%ld\n",a[n-1]+k-sum[n-1]);
    }else{
      while(j > 0 && sum[j] == sum[j-1]) j--;
      printf("%ld\n",a[j-1]+k-sum[j-1]);
    }
  }
  return 0;
}

#include <set>
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int par[N], c[N];
set<pair<int, int>> s[N];

void make_set(int x) {
  par[x] = x;
  s[x].insert({c[x], 1});
}

int find_set(int x) {
  if (x == par[x]) {
    return x;
  }
  return par[x] = find_set(par[x]);
}

void union_sets(int x, int y) {
  x = find_set(x);
  y = find_set(y);
  if (x != y) {
    if (s[x].size() > s[y].size()) {
      swap(x, y);
    }
    par[x] = y;
    for (auto z : s[x]) {
      auto it = s[y].lower_bound({z.first, -1});
      int cur = z.second;
      if (!(it == s[y].end() || it->first != z.first)) {
        cur += it->second;
        s[y].erase(it);
      }
      s[y].insert({z.first, cur});
    }
  }
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
    make_set(i);
  }
  while (q--) {
    int x, y, z;
    cin >> x >> y >> z;
    if (x - 1) {
      int w = find_set(y);
      auto it = s[w].lower_bound({z, -1});
      if (it == s[w].end() || it->first != z) {
        cout << "0\n";
      } else {
        cout << it->second << '\n';
      }
    } else {
      union_sets(y, z);
    }
  }
  return 0;
}


//abc183_e.cpp
//Sun Nov 15 21:30:13 2020

#include <bits/stdc++.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w;
	cin >> h >> w;

	string s[h];
	rep(i,h)cin >> s[i];

	ll dptate[h][w];
	ll dpnana[h][w];
	ll dpyoko[h][w];
	rep(i,h)rep(j,w){
		dptate[i][j] = 0;
		dpnana[i][j] = 0;
		dpyoko[i][j] = 0;
	}

	rep(i,h)rep(j,w){
		ll tmp = 0;
		if (s[i][j]=='#')continue;
		if (i==0 && j==0){
			dptate[0][0] = 1;
			dpnana[0][0] = 1;
			dpyoko[0][0] = 1;
		}else {
			if (i-1>=0){
				tmp = (tmp+dptate[i-1][j])%MOD;
			}
			if (j-1>=0){
				tmp = (tmp+dpyoko[i][j-1])%MOD;
			}
			if (i-1>=0 && j-1>=0){
				tmp = (tmp+dpnana[i-1][j-1])%MOD;
			}
			if (i-1>=0){
				dptate[i][j] = (tmp+dptate[i-1][j])%MOD;
			}else {
				dptate[i][j] = tmp;
			}
			if (j-1>=0){
				dpyoko[i][j] = (tmp+dpyoko[i][j-1])%MOD;
			}else {
				dpyoko[i][j] = tmp;
			}
			if (i-1>=0 && j-1>=0){
				dpnana[i][j] = (tmp+dpnana[i-1][j-1])%MOD;
			}else {
				dpnana[i][j] = tmp;
			}
		}
		if (i==h-1 && j==w-1){
			cout << tmp << endl;
			return 0;
		}
	}

//	cout << << endl;
//	printf("%.4f\n",ans);
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
ll gcd(ll a, ll b){
    while (b>0){
        ll tempB = b;
        b = a % b;
        a = tempB;
    }
    return a;
}

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

void solve(ll n, ll s, ll k){
    // n and k is tagaini so
    ll x, y;
    // cout << "k, n = " << k << ", " << n << endl;
    extgcd(k, n, x, y);

    ll ans = ((x * s) % n + n )% n;
    // cout << "ans: " << ans << endl;
    ans = n - ans;
    // cout << x << ", " << y << endl;
    cout << ans << endl;
}

int main(){
    int t; cin >> t;
    vec<int> ni(t), si(t), ki(t);
    rep(i, t) cin >> ni[i] >> si[i] >> ki[i];
    rep(i, t) {
        int n, s, k;
        n = ni[i], s = si[i], k = ki[i];
        int g = gcd(n, k);
        if (g == 1) {
            solve(n, s, k);
        } else {
            if (s % g != 0) cout << -1 << endl;
            else solve(n/g, s/g, k/g);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     IOS             ios_base::sync_with_stdio(false);cin.tie(0);
#define     endl            "\n"
#define     deb(x)          cout<<#x<<" : "<<x
#define     mod             (int)1e9+7
#define     up              upper_bound
#define     lb              lower_bound
#define     fo(a,i,n)         for(i=a;i<n;i++)
#define     fi              first
#define     se              second
#define     mp              make_pair
#define     pb              push_back
#define     all(x)          x.begin(), x.end()
#define     clr(x)          memset(x, 0, sizeof(x))
#define     sortall(x)      sort(all(x))
#define     tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define     PI              3.1415926535897932384626

#define isOn                (S, j) (S & (1 << j))
#define setBit              (S, j) (S |= (1 << j))
#define clearBit            (S, j) (S &= ~(1 << j))
#define toggleBit           (S, j) (S ^= (1 << j))
#define lowBit              (S) (S & (-S))
#define setAll              (S, n) (S = (1 << n) - 1)
#define modulo              (S, N) ((S) & (N - 1))
#define isPowerOfTwo        (S) (!(S & (S - 1)))
#define nearestPowerOfTwo   (S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit      (S) ((S) & (S - 1))
#define turnOnLastZero      (S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits       (S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes      (S) ((S) | (S - 1))

typedef pair<ll, ll>    pii;
typedef pair<ll, ll>    pl;
typedef vector<ll>      vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

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

int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt","r",stdin);
//     freopen("output1.txt","w",stdout);
// #endif
    IOS;
    int t=1;
    // cin>>t;

    while(t--)
    {
        float n;
        cin>>n;
        cout<<ceil(n/100)<<endl;

    }
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define REPA(i,j) for(int i=1;i<=j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
const int INF=1<<30;
inline void read(int &x){
//	short neg=1;
	x=0;
	char c=getchar();
	/*while(c<'0'||c>'9'){
		if(c=='-')neg=-1;
		c=getchar();
	}*/
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+(c^48),c=getchar();
	}
//	x*=neg;
}
int a,b;
int main(void){
	cin>>a>>b;
	int cnta=(a/100)+(a/10%10)+(a%10),cntb= (b/100)+(b/10%10)+(b%10);
	cout<<max(cnta,cntb);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a>> b>> c;
    d = a - b + c;
    cout << d;
}

#include<bits/stdc++.h>
//Ctrl + B
using namespace std;
#define endl '\n'
#define nitro {std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);}
#define pi 3.141592653589793
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define dbg(x) cout << x << '\n';
#define case_g(x) cout<<"Case "<<x<<": ";
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned long ul;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, bool> pib;
typedef std::vector<pii> vii;
typedef std::vector<pll> vll;
typedef std::vector<pib> vib;
typedef std::unordered_map<int, int> umapii;
typedef std::unordered_map<ll, ll> umapll;
typedef std::unordered_map<int , bool> umapib;
typedef std::map<int, int> mapii;
typedef std::map<ll, ll> mapll;
typedef std::map<int, bool> mapib;

ll ncr(ll n, ll r){//ncr formula
    ll m=min(r,n-r);
    ll ans=1;
    for(int i=1;i<=m;i++){
        ans=ans*(n-i+1)/i;
    }
    return ans;
}

ll modpow(ll a, ll b) { //modulo power
    ll result = 1, M=mod;
    while(b!=0) {
        if(b&1) {
            result = ((result%M)*(a%M))%M;
        }
        a = ((a%M)*(a%M))%M;
        b >>= 1;
    }
    return result;
}

ll modinv(ll a) { //modulo inverse
    ll m = mod, y = 0, x = 1;
    while (a > 1) {
        ll q = a / m, t = m;
        m = a % m;
        a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    return x < 0 ? x + mod : x;
}

void solve()
{
    vi a(3);
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(all(a));
    cout<<a[1]+a[2];
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    nitro
    int tc;
    tc =1;
    //cin >> tc;
    for(int i=1; i<=tc; ++i)
    {
        //case_g(i);
        solve();
    }
}


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

int main() {
  int n; int D; int H;
  cin >> n >> D >> H;
  vector<int> d(n), h(n);
  for(int i=0; i<n; ++i) cin >> d[i] >> h[i];

  double ans = 0;
  for(int i=0; i<n; ++i) {
    double b = double(D * h[i] - d[i] * H) / (D - d[i]);
    ans = max(ans, b);
  }
  printf("%.10lf\n", ans);
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stack>
#include <iomanip>
#include <climits>
#define MOD 1000000007
#define ll long long int
#include <queue>
using namespace std;

vector <bool> is_prime(10007,true);

void seive()
{
    for (int i=2; i<=10007; i++)
        {
            if (is_prime[i]==true)
                {
                    for (int num=2*i; num<=10007; num+=i)
                        {
                            is_prime[num]=false;
                        }
                }
        }
}

ll GCD(ll x,ll y)
{
    ll mx=max(x,y),mn=min(x,y);

    while(mn!=0)
        {
            ll temp=mn;
            mn=mx%mn;
            mx=temp;
        }

    return mx;
}

vector <vector <ll>> vis;
vector <vector <ll>> a;
vector <vector <vector <char>>> dis;
//vector <ll> vis,counttime;

/*void dfs(ll v)
{
    vis[v]=1;

    for (int child:a[v])
        {
            if (vis[child]==0)
                dfs(child);

        }

}
*/
ll dx[4]= {1,0,-1,0};
ll dy[4]= {0,-1,0,1};
char dir[4]= {'D','L','U','R'};
ll n,m;
bool isValid(ll x,ll y)
{
    if (x<1||x>n||y<1||y>m)
        return false;

    if (vis[x][y]==1)
        return false;

    return true;
}
vector <pair<ll,ll>> ans_vec;
void DFS_grid(ll x,ll y)

{
    // cout<<x<<" "<<y<<" "<<vis[x][y]<<endl;
    vis[x][y]=1;
    ans_vec.push_back({x,y});

    for (int i=0; i<4; i++)
        {
            ll newX=x+dx[i],newY=y+dy[i];

            if (isValid(newX,newY))
                {
                    DFS_grid(newX,newY);
                }
        }

}

vector <vector<ll>> bin;
void binary_conv(ll x,ll ind)
{
    vector <ll> a(31,0);
    int k=-1;
    ll xs=x,val=1;
    for (int i=1; i<=x; i*=2)
        {
            k++;
            val=i;

        }
    cout<<val<<" "<<k<<endl;

    for (ll i=val; i>=1; i/=2)
        {
            if (i<=x)
                {
                    x-=i;
                    a[30-k]=1;

                }
            k--;
        }

    bin[ind]=a;

}

ll binpow(ll a,ll b)

{
    if (b==0)
        return 1;
    ll res=binpow(a,b/2);
    if (b%2==0)
        {

            return (res*res)%1000000007;
        }
    else return (a*res*res)%1000000007;

}

pair<ll,string> func(string s,char a[],ll n,ll k)
{
    ll ans =0;

    for (int i=1; i<n; i++)
        {
            if (i<n-1&&s[i]==s[i-1]&&s[i]==s[i+1])
                {
                    s[i]=a[(s[i]-'A'+1)%k];
                    ans++;
                }

            else if (s[i]==s[i-1])
                {
                    ll mid=(s[i-1]-'A'+1)%k;
                    s[i]=a[mid];
                    if(k>2)
                        {
                            if (i<n-1&&s[i]==s[i+1])
                                {
                                    s[i]=a[(mid+1)%k];

                                }
                        }

                    ans++;
                }

        }

    return {ans,s};

}

bool is_good(ll k,ll n,ll a,ll b,ll ele)
{
    if (ele<=n&&k-ele*a>0)
        {
            if ((k-ele*a)/b+ele>n||(k-ele*a)/b+ele==n&&(k-ele*a)%b!=0)
                return true;
        }

    return false;
}

ll mod(ll x,ll y)

{
    return max(x-y,y-x);

}
int main()

{

    ll t=1;

    //cin>>t;

    while(t--)
        {

        ll n;
        double d,h;
        cin>>n>>d>>h;
cout<<setprecision(20);
        double mx=d,my=0,m=h/d;
        while(n--)
        {
            double x,y;
            cin>>x>>y;

            if ((y-my)/x>m)
            {

               my+=((y-my)/x-m)/(1/x-1/d);
                m=(h-my)/d;
            }

        }

        //cout<<mx<<my<<endl;

//cout<<ans<<endl;

            cout<<my<<endl;

        }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define  int           long long
#define  ld            long double
#define  pii           pair<int,int>
#define  pf            push_front
#define  pb            push_back
#define  ub            upper_bound
#define  lb            lower_bound
#define  ppb           pop_back
#define  ppf           pop_front
#define  f(i,a,b)      for(int i = a; i <  b; ++i)
#define  R(i,a,b)      for(int i = a; i >= b; --i)
#define  rep(i,a,b)    for(int i = a; i <= b; ++i)
#define  fr            first
#define  sc            second
#define  sz(x)         (int)((x).size())
#define  all(x)        (x).begin(),(x).end()

string s;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> s;
    int n = s.length();
    int flag = 1;
    f(i,0,n){
        if((i&1)){
            if(islower(s[i])){
                flag = 0;
                break;
            }
        }else{
            if(isupper(s[i])){
                flag = 0;
                break;
            }
        }
    }
    if(flag) cout  << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

int main(){
  int cnt=0;
  string S;
  cin >>S;
  const char* cS=S.c_str();
  for(int i=0; i<S.size(); i++){
    if(i%2==0){
      if(cS[i]>=97){
        cnt++;
      }
    }
    else if(i%2==1){
      if(cS[i]<97){
        cnt++;
      }
    }
  }
  if(cnt==S.size()){
    cout << "Yes" <<endl;
  }
  else cout <<"No"<<endl;
}


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;
//using namespace atcoder;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/(b))
#define IPOW(x,y) (LL(pow(x,y)))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD_2 = int(998244353);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    LL N, M;
    cin >> N >> M;
    vector<LL> H (N);
    vector<LL> W (M);
    for(LL i = 0;i < N;i++){
        cin >> H[i];
    }
    SORT(H);
    for(LL i = 0;i < M;i++){
        cin >> W[i];
    }
    SORT(W);
//    cout << endl;
//    for(LL i = 0;i < N;i++){
//        cout << H[i] << " ";
//    }
//    cout << endl;
//    for(LL i = 0;i < M;i++){
//        cout << W[i] << " ";
//    }
//    cout << endl;
    vector<LL> sum_before (N/2+1,0);
    vector<LL> sum_after (N/2+1,0);
    for(LL i = 0;i < N/2;i++){
        sum_before[i+1] = sum_before[i]+abs(H[i*2]-H[i*2+1]);
        sum_after[i+1] = sum_after[i]+abs(H[N-1-i*2]-H[N-2-i*2]);
    }

    LL ans = LL_INF;
    LL now = 0;
    for(LL i = 0;i < N/2+1;i++){
        while(now != M-1 && abs(H[i*2]-W[now]) >= abs(H[i*2]-W[now+1])){
            now++;
        }
//        cout << "CHANGE " << i*2 << "(" << H[i*2] << ")" << endl;
//        cout << " before = " << sum_before[i] << endl;
//        cout << " after = " << sum_after[N/2-i] << endl;
//        cout << " teacher = " << abs(H[i*2]-W[now]) << "(" << now << "," << W[now] << ")" << endl;
        ans = min(ans,sum_before[i]+sum_after[N/2-i]+abs(H[i*2]-W[now]));
    }
    cout << ans << endl;
    return;
}

#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char mc[4]={'U','L','D','R'};
const int max_e = 9000;
const int inf = 1000000000;
int mh[29][29],mv[29][29];

int dijkstra(vector<vector<int> > &m, pair<int, int> s){
    priority_queue<pair<int,pair<int,int> >, vector<pair<int,pair<int,int> > >, greater<pair<int,pair<int,int> > > > next;
    next.push(make_pair(0,s));
    while (!next.empty()) {
        int x = next.top().second.first,y = next.top().second.second;
        int p = next.top().first;
        next.pop();
        if(x > 0){
            if(chmin(m[x - 1][y], p + mv[x - 1][y])){
                next.push(make_pair(p + mv[x - 1][y], make_pair(x - 1, y)));
            }
        }
        if(x < 29){
            if(chmin(m[x + 1][y], p + mv[x][y])){
                next.push(make_pair(p + mv[x][y], make_pair(x + 1, y)));
            }
        }
        if(y > 0){
            if(chmin(m[x][y - 1], p + mv[x][y - 1])){
                next.push(make_pair(p + mv[x][y - 1], make_pair(x, y - 1)));
            }
        }
        if(y < 29){
            if(chmin(m[x][y + 1], p + mv[x][y])){
                next.push(make_pair(p + mv[x][y], make_pair(x, y + 1)));
            }
        }
    }
    return 0;
}

string restore(vector<vector<int> > &m, int x, int y){
    string root = "";
    int s = 0;
    while (m[x][y] != 0) {
        ++s;
        int next_x = x,next_y = y,p = m[x][y];
        rep0(i, 4)if(chmin(p, m[min(max(0,x + dx[i]),29)][min(max(0,y + dy[i]),29)])){
            next_x = x + dx[i];
            next_y = y + dy[i];
            if(s != root.size())root.push_back(mc[i]);
            else root[s - 1] = mc[i];
        }
        x = next_x;
        y = next_y;
    }
    reverse(all(root));
    return root;
}

int update(string s, int p, int x, int y){
    rep0(i, s.size()){
        if(s[i] == 'U'){
            mv[x - 1][y] = (mv[x - 1][y] + p + 1) / 2;
            x--;
        }else if(s[i] == 'D'){
            mv[x][y] = (mv[x][y] + p + 1) / 2;
            x++;
        }else if(s[i] == 'R'){
            mh[x][y] = (mh[x][y] + p + 1) / 2;
            y++;
        }else{
            mh[x][y - 1] = (mh[x][y - 1] + p + 1) / 2;
            y--;
        }
    }
    return 0;
}

//modを確認すること
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    rep0(i, 30)rep0(j, 30){
        //mh[i][j] = max_e;
        //mv[i][j] = max_e;
        mh[i][j] = rand() % 8000 + 1000;
        mv[i][j] = rand() % 8000 + 1000;
    }

    rep0(i, 1000){
        vector<vector<int> > m(30,vector<int>(30,inf));
        int sx,sy,gx,gy,p;
        string s = "";
        cin >> sx >> sy >> gx >> gy;
        m[sx][sy] = 0;

        dijkstra(m, make_pair(sx, sy));
        string ans = restore(m, gx, gy);

        pf(ans);

        cin >> p;
        update(ans, int((p + ans.size() - 1) / ans.size()), sx, sy);
    }
    return 0;
}


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

using ll = long long;

ll n, fib[100];

int main() {
  fib[0] = fib[1] = 1;
  for (int i = 2; i < 100; i++) fib[i] = fib[i - 1] + fib[i - 2];

  cin >> n;
  int m = 86;
  vector<int> ans;
  for (int i = 0; i <= m; i++) {
    if (i % 2 == 0) {
      if (n >= fib[m - i]) {
        ans.push_back(1);
        n -= fib[m-i];
      }
      ans.push_back(4);
    }
    if (i % 2 == 1) {
      if (n >= fib[m - i]) {
        ans.push_back(2);
        n -= fib[m-i];
      }
      ans.push_back(3);
    }
  }

  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << "\n";
  return 0;
}
// 首先发现按如下操作序列[4->3->4->3->4->3]操作,结果会呈现fib数字.
// 如果这个序列长度是S,当我们在索引i=2k(i是偶数)之前执行操作1,将会增加fib(S-i)
// 当我们在索引i=2k+1(i是奇数)之前执行操作2,将会增加fib(S-i)

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll read(){
	ll sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
ll N=1e10*3-1;
bool a[3];
char s[3]={'1','1','0'};
int main(){
	int n=read();
//	while (n--)slove();
	string t;
	cin>>t;
	a[0]=a[1]=a[2]=0;
	for (int p=0;p<3;p++){
		int q=p;
		bool f=1;
		for (int i=0;i<n;i++){
			if (t[i]!=s[q]){
				f=0;
				break;
			}
			q++;
			q%=3;
		}
		a[p]=f;
	}
	ll ans=N-n+1;
	ll maxn=0;
	for (int i=0;i<3;i++){
		if (a[i]==0)continue;
		ll k=ans-i;
		k/=3;
		maxn+=k+1;
//		maxn=max(maxn,3*k+i);
	}
	cout<<maxn;
//	ll x=read();
//	if (x==maxn)cout<<"y";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  string N;
  int K;
  cin >> N >> K;
  long A = stoi(N);
  rep(i, K) {
    string J = to_string(A);
    string G, H;
    sort(J.begin(), J.end());
    H = J;
    reverse(J.begin(), J.end());
    G = J;
    A = stoi(G)-stoi(H);
  }
  cout << A << endl;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long

ll n,m,cnt,ans = -0x3f3f3f3f;
ll head[200005];
ll val[200005],maxx[200005],minn[200005];
int vis[200005];

struct K{
	ll val,num;
}p[200005];

struct P{
	ll to,next;
}e[400005];

void add(ll x,ll y){
	e[++cnt].to = y;
	e[cnt].next = head[x];
	head[x] = cnt;
}

void dfs(ll now){
	//std::cout<<now<<" "<<val[now]<<" "<<minn[now]<<std::endl;
	ans = std::max(val[now] - minn[now],ans);
	for(int i = head[now];i;i = e[i].next){
		if(!vis[e[i].to]){
		minn[e[i].to] = std::min(minn[now],val[now]);
		vis[e[i].to] ++ ;
		dfs(e[i].to);
		}
	}
}

bool operator < (K a,K b){
	return a.val < b.val;
}

int main(){
	memset(maxx,-0x3f,sizeof(maxx));
	memset(minn,0x3f,sizeof(minn));
	scanf("%lld%lld",&n,&m);
	for(int i = 1;i <= n;++i)
	scanf("%lld",&p[i].val),p[i].num = i,val[i] = p[i].val;
	for(int i = 1;i <= m;++i){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		add(x,y);
	}
	std::sort(p + 1,p + 1 + n);
	for(int i = 1; i<= n;++i)
	if(!vis[p[i].num])
	dfs(p[i].num);
	std::cout<<ans<<std::endl;
}


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

using namespace std;
#define int long long
#define ll long long
#define pii std::pair<int, int>
#define pdd std::pair<double, double>
#define INF (1LL << 33)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define SHOW(p) \
    if (test)   \
        cout << #p " : " << p << endl;
bool test = false;
int ans, N;
int hoge(int x)
{
    if (x < 1000) {
        return 0;
    } else if (x < 1000000) {
        return x - 999;
    }
    int len = std::to_string(x).length();
    int co = (len - 1) / 3;
    int tmp = 1;
    REP(i, len - 1)
    {
        tmp *= 10;
    }
    if (tmp == x) {
        return co + hoge(x - 1);
    }
    return (x - tmp) * co + hoge(tmp);
}
signed main()
{
    test = true;
    cin >> N;
    cout << hoge(N) << endl;
    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<tuple>
#include<cstring>
#include<bitset>

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define pb push_back
#define eb emplace_back

#define INF 1000000000
#define INFLL 1000000000000000000LL

using namespace std;

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

using ll = long long;
using P = pair<ll, ll>;

#define MAX_N 1000+10

ll N;
pair<int, string> p[MAX_N];

int main() {

	cin >> N;
	REP(i, N)cin >> p[i].second >> p[i].first;

	sort(p, p + N, greater<pair<int, string>>());

	cout << p[1].second << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 200010
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read()
{
	int d=0,flg=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-'){flg=-1;}ch=getchar();}
	while(ch<='9'&&ch>='0'){d=d*10-'0'+ch,ch=getchar();}
	return d*flg;
}
int n,q,C,opt,x,y,root[MAXN];
int tot;
struct node{
	int ls,rs,val;
}p[MAXN*50];
int Merge(int u,int v,int l,int r)
{
	if(!u||!v) return u|v;
	if(l==r)
	{
		p[++tot].val=p[u].val+p[v].val;
		return tot;
	}
	int mid=(l+r)>>1;
	int node=++tot;
	p[node].ls=Merge(p[u].ls,p[v].ls,l,mid);
	p[node].rs=Merge(p[u].rs,p[v].rs,mid+1,r);
	p[node].val=p[p[node].ls].val+p[p[node].rs].val;
	//printf("%d %d %d %d %d %d\n",node,u,v,p[node].ls,p[node].rs,p[node].val);
	return node;
}
int query(int u,int l,int r,int pos)
{
	if(l==r) return p[u].val;
	int mid=(l+r)>>1;
	if(pos<=mid)
	{
		if(!p[u].ls) return 0;
		return query(p[u].ls,l,mid,pos);
	}
	else
	{
		if(!p[u].rs) return 0;
		return query(p[u].rs,mid+1,r,pos);
	}
}
void update(int u,int l,int r,int x,int y)
{
	if(l==r) p[u].val+=y;
	else
	{
		int mid=(l+r)>>1;
		if(x<=mid)
		{
			if(!p[u].ls) p[u].ls=++tot;
			update(p[u].ls,l,mid,x,y);
		}
		else
		{
			if(!p[u].rs) p[u].rs=++tot;
			update(p[u].rs,mid+1,r,x,y);
		}
		p[u].val=p[p[u].ls].val+p[p[u].rs].val;
	}
}
int fa[MAXN];
int Find(int u){return fa[u]==0?u:fa[u]=Find(fa[u]);}
void Union(int u,int v)
{
	u=Find(u),v=Find(v);
	if(u==v) return;
	fa[u]=v;
	root[v]=Merge(root[u],root[v],1,n);
	//printf("%d\n",root[v]);
}
int main(){
	n=read(),q=read();
	FUP(i,1,n)
	{
		C=read(),root[i]=++tot;
		update(tot,1,n,C,1);
	}
	//printf("## %d\n",tot);
	FUP(i,1,q)
	{
		opt=read(),x=read(),y=read();
		if(opt==1) Union(x,y);
		else
		{
			x=root[Find(x)];
			printf("%d\n",query(x,1,n,y));
		}
	}
	return 0;
}

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

#include <bits/stdc++.h>

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
void YES(bool t=true) {cout<<(t?"YES":"NO")<<endl;}
void Yes(bool t=true) {cout<<(t?"Yes":"No")<<endl;}
void yes(bool t=true) {cout<<(t?"yes":"no")<<endl;}
void NO(bool t=true) {cout<<(t?"NO":"YES")<<endl;}
void No(bool t=true) {cout<<(t?"No":"Yes")<<endl;}
void no(bool t=true) {cout<<(t?"no":"yes")<<endl;}
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

vl a;
int n;
map<pll, ll> mp;

ll solve(ll x, int i) {
    if (i == 0) return 1;
    if (x % a[i] == 0) return 1;
    if (mp.count(pll(x, i))) return mp[pll(x, i)];

    ll needed;
    if (x % a[i] == 0) needed = x / a[i];
    else needed = x / a[i] + 1;
    DEBUG(pll(x, i));
    DEBUG(needed);
    ll ans = 0;
    if (i + 1 < n and needed >= a[i + 1] / a[i]) {}
    else {
        ll gyaku = needed * a[i] - x;
        ll ans1 = solve(gyaku, i - 1);
        ans += ans1;
    }
    ans += solve(x - a[i] * (needed - 1), i - 1);
    mp[pll(x, i)] = ans;
    return ans;
}

signed main() {
    fio();

    cin >> n;
    ll x;
    cin >> x;
    a.resize(n);
    rep (i, n) cin >> a[i];
    // a[0] = 1;
    // rep (i, n - 1) a[i + 1] = a[i] * 2;

    ll ans = solve(x, n - 1);

    // for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    //     DEBUG(*itr);
    // }
    cout << ans << endl;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;

#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dr8[] = {1,1,0,-1,-1,-1, 0, 1};
int dc8[] = {0,1,1, 1, 0,-1,-1,-1};
int dr4[] = {1,0,0,-1};
int dc4[] = {0,1,-1,0};
int gcd(int a, int b)
{
    if(a%b==0) return b;
    return gcd(b, a%b);
}
void inp(int &x)
{
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-')
    {
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
    x *=-1;
}
void solve();

int32_t main()
{
    FIO;
    int t=1;
    //cin >> t;
for(int i=1;i<=t;i++)
    {
        solve();
    }
}
void solve()
{
    int i, n, j, m, k, l, t;
    cin >> n >> m;
    rip(dp,n,m);
    f(i,n) f(j,m) cin >> dp[i][j];
    k=inf;
    f(i,n) f(j,m) k = min(k,dp[i][j]);
    l=0;
    f(i,n) f(j,m) l += dp[i][j]-k;
    cout << l;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=3e6+5;
int n;
int c[maxn],k,now;
signed main() {
//	freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
	cin>>n>>k;
	for(register int i=1; i<=3*n; i++)c[i]=i*(i-1)/2;
	for(register int t=3; t<=3*n; t++) {
		int w=c[t-1];
//		cout<<w<<endl;
		if(t>n+1)w-=c[t-n-1]*3;
		if(t>2*n)w+=c[t-2*n-1]*3;
//		cout<<t<<' '<<w<<endl;
		if(now+w>=k) {
//			cout<<t<<' '<<now<<' '<<k<<endl;
			for(register int i=1; i<=n; i++) {
				if(t-i<2||t-i>2*n)continue;
				int p=t-i,q=p-1;
				if(p>n)q-=(p-n-1)*2;
				if(now+q>=k) {
					if(p>n) {
						int cs=p-n;
						printf("%lld %lld %lld",i,k-now+cs-1,t-i-k+now-cs+1);
					} else printf("%lld %lld %lld",i,k-now,t-i-k+now);
					return 0;
				}
				now+=q;
			}
			return 0;
		}
		now+=w;
	}
	cout<<now<<' '<<k<<endl;
}


#pragma GCC optimization ("O3")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll M = 1e9 + 7;

int main()
{
    fast

    string s;
    deque<char> v;
    cin >> s;
    int c = 0;
    for(auto x : s)
    {
        if(x == 'R')c ^= 1;
        else
        {
            if(c == 1)v.push_front(x);
            else v.push_back(x);
        }
    }
    if(v.empty())return 0;
    if(c)reverse(v.begin(), v.end());
    vector<char> t;
    for(int i = 0; i < v.size(); i++)
    {
        int cnt = 0;
        char cc = v[i];
        while(i < v.size() && v[i] == cc)i++, cnt++;
        i--;
        if(cnt % 2)t.push_back(cc);
        while(t.size() > 1 && t.back() == t[t.size() - 2])t.pop_back(), t.pop_back();
    }

    for(auto x : t)cout << x;
}

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

template<typename T>
void view_1d(vector<T> V, string sep) {
    for (ll i=0; i<V.size(); i++) {
        cout << V[i];
        if (i == V.size() - 1) {
            cout << endl;
        } else {
            cout << sep;
        }
    }
}

template<typename T>
void view_2d(vector<vector<T>> V, string sep) {
    for (ll i=0; i<V.size(); i++) {
        for (ll j=0; j<V[i].size(); j++) {
            cout << V[i][j];
            if (j == V[i].size() - 1) {
                cout << endl;
            } else {
                cout << sep;
            }
        }
    }
}

//==============================//

int main() {
    string S;
    cin >> S;

    int i = 0;
    int ans = 0;
    while (i < 12) {
        if (S.substr(i,4) == "ZONe") {
            i += 4;
            ans++;
        } else {
            i++;
        }
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //約9.0*10^18
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;

using std::cout; using std::endl;
using std::string; using std::reverse;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string　　string str = to_string(num);
//string→int   int num = atoi(numStr.c_str());
//複数のvector管理→;vector<tuple<string, int, int>> SP(N);
//int max = *max_element(all(A));最大値
//int min = *min_element(all(B));最小値
int main() {
    ll x,y,z;cin>>x>>y>>z;
    ll ans =0;
    rep0(i,100000000){
        if(y*z>x*i){
            ans = i;
        }
        else{
            break;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int x, y, z, ans;
  cin >> x >> y >> z;
  ans = y * z / x;
  if (ans*x == z*y)
    ans -= 1;
  cout << ans << endl;
}


#include <bits/stdc++.h>

#define int long long

using namespace std;

#ifdef LOCAL
#include "/media/brayand/BrayanD/debugger.h"
#else
#define db(...) false
#define dbl(...) false
#define dbg(...) false
#define dbm(...) false
#define dbs(...) false
#define dbas(...) false
#endif

const int MAXN = 10000;

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

    vector<int> vect;

    for(int i = 2 ; 2*3*i <= MAXN ; i++)
    {
    	if(i%5)
    	{
    		vect.push_back(2*3*i);
    	}
    }
    for(int i = 2 ; 2*5*i <= MAXN ; i++)
    {
    	if(i%3)
    	{
    		vect.push_back(2*5*i);
    	}
    }

    for(int i = 2 ; 3*5*i <= MAXN ; i++)
    {
    	if(i%2)
    	{
    		vect.push_back(3*5*i);
    	}
    }

    for(int i = 1 ; 2*3*5*i <= MAXN ; i++)
    {
    	vect.push_back(2*3*5*i);
    }

    int N;
    cin >> N;

    vector<int> ans;

    ans.push_back(2*3);
    ans.push_back(2*5);
    ans.push_back(3*5);

    N-=3;

    while(N--)
    {
    	ans.push_back(vect.back());
    	vect.pop_back();
    }

    for(auto x : ans)
    {
    	cout << x << " ";
    }
    cout << '\n';

    return 0;
}

#include <iostream>

using namespace std;

int N;

int main()
{
	cin >> N;
	cout << "6 10 15"; N -= 3;
	for (int i = 16; N; i++)
	{
		if (i % 6 == 0 || i % 10 == 0 || i % 15 == 0) {N--; cout << " " << i;}
	}
	cout << "\n";
	return 0;
}


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

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

    cout << 100-(n%100) << endl;

}

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

int main() {
   int x;
   cin >> x;
   cout << 100 - x % 100;
}


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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

template <typename T>
void print(vector<T>& x) {
    int N = x.size();
    REP(i, N) {
        if (i > 0) cout << " ";
        cout << x[i];
    }
    cout << "\n";
}

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

    int n; cin >> n;
    vector<vll> v(n, vll(n));
    REP(i, n) REP(j, n) cin >> v[i][j];

    vll y;
    REP(i, n) {
        y.eb(*min_element(ALL(v[i])));
    }

    debug(y)

    vll x;
    FOR(i, 0, n) {
        ll tmp = v[0][i] - y[0];
        REP(j, n) {
            if (tmp != v[j][i] - y[j]) {
                print("No");
                return 0;
            }
        }
        x.eb(tmp);
    }

    print("Yes");
    print(y);
    print(x);
}

#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define MAXN 200005
#define max_num 1000000
#define LL long long
using namespace std;
int n, m;
int l[MAXN], r[MAXN];
int main()
{
    while(cin >> n >> m)
    {
        if(m < 0 || m == n || (m == n - 1 && n - 1 > 0))
        {
            puts("-1");
            continue;
        }
        if(n == 1)
        {
            puts("1 2");
            continue;
        }
        int num_w = n - m - 2;
        int now = max_num;
        for(int i = 0; i < num_w; i++)
        {
            r[i] = now;
            now--;
            l[i] = now;
            now--;
        }
        l[num_w] = 1;
        r[num_w] = (m + 2 + 1) * 2;
        now = (m + 2) * 2 - 1;
        for(int i = num_w + 1; i < n; i++)
        {
            r[i] = now;
            now--;
            l[i] = now;
            now--;
        }
        for(int i = 0; i < n; i++)
        {
            printf("%d %d\n", l[i], r[i]);
        }
    }
    return 0;
}


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

using ll = long long;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  ll d = modpow(b, c, 4);
  if (d == 0) d += 4;

  cout << modpow(a, d, 10) << '\n';
}

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

const long long inf = (long long)1e9 * (long long)1e9;

map<int, int>mods;

long long calculateMod(long long b, long long c, int mod) {
  // oblicz reszte z dzielenia b^c przez mod, mod <= 5
  if (c == 1) return b%mod;
  if (c == 0) return 1;
  b %= mod;
  long long half = calculateMod(b, c/2, mod);
  long long rest = 1;
  if (c % 2 == 1) rest = b;
  return (((half * half) % mod) * rest) % mod;
}

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  a %= 10;
  if (a == 0 || a == 1 || a == 5 || a == 6) {
    printf("%d\n", a);
    return 0;
  }

  mods[2] = 4;
  mods[3] = 4;
  mods[4] = 2;
  mods[7] = 4;
  mods[8] = 4;
  mods[9] = 2;

  int mod = calculateMod(b, c, mods[a]);
  // printf("%d\n", calculateMod(2, 20, 100000000));
  // return 0;
  // printf("%d\n", mod);

  if (a == 2) {
    int mods[] = {6, 2, 4, 8};
    printf("%d\n", mods[mod]);
  }
  if (a == 3) {
    int mods[] = {1, 3, 9, 7};
    printf("%d\n", mods[mod]);
  }
  if (a == 4) {
    int mods[] = {6, 4};
    printf("%d\n", mods[mod]);
  }
  if (a == 7) {
    int mods[] = {1, 7, 9, 3};
    printf("%d\n", mods[mod]);
  }
  if (a == 8) {
    int mods[] = {6, 8, 4, 2};
    printf("%d\n", mods[mod]);
  }
  if (a == 9) {
    int mods[] = {1, 9};
    printf("%d\n", mods[mod]);
  }

  return 0;
}


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

int main(){
  int a, b, c, ans;
  string ans1;
  cin >> a >> b >>c;
  if(a != b){
    ans = max(a,b);
    if(ans ==a){ans1 = "Takahashi";}
  else{ans1 = "Aoki";}}
  else{
    if(c==0){
      ans = 0;}
    else{ans = 1;}
        if(ans ==1){ans1 = "Takahashi";}
  else{ans1 = "Aoki";}
  }

cout <<ans1;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a>b)||(a==b&&c==1))
       printf("Takahashi");
     else printf("Aoki");
    return 0;
}


#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;

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

ll crt(ll a, ll m, ll b, ll n){
    if (n > m)
        swap(a, b), swap(m, n);
    if (n == 1)
        return a;
    ll x, y, g = euclid(m, n, x, y);
    if ((a - b) % g != 0)
        return LLONG_MAX;
    x = (b - a) % n * x % n / g * m + a;
    return x < 0 ? x + m * n / g : x;
}

pair<ll, ll> crt(const vector<ll> &r, const vector<ll> &m){
    ll r0 = 0, m0 = 1;
    assert(r.size() == m.size());
    for (size_t i = 0; i < r.size(); i++){
        auto rem = crt(r0, m0, r[i], m[i]);
        if (rem == LLONG_MAX)
            return {-1, -1};
        r0 = rem;
        m0 = m0 / __gcd(m0, m[i]) * m[i];
    }
    return {r0, m0};
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    ll t;
    cin>>t;
    while(t--){
        ll x,y,p,q;
        cin>>x>>y>>p>>q;
        ll ans=mod*mod;
        for(ll i=x;i<x+y;i++){
            for(ll j=p;j<p+q;j++){
                auto [r,lcm] = crt({i, j}, {2*x+2*y, p+q});
                if(lcm==-1) continue;
                ans=min(ans, r);
            }
        }
        if(ans==mod*mod)
            cout<<"infinity\n";
        else
            cout<<ans<<"\n";
    }

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

//Iamskk//
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define endl '\n'
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ai(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define ao(arr) for(auto asdfasdfasdf:arr) cout<<asdfasdfasdf<<" ";
#define mi(arr,m,n) for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cin>>arr[i][j];}
#define mo(arr,m,n) for(int i=0;i<m;i++){ for(int j=0;j<n;j++) cout<<arr[i][j]<<" "; cout<<endl;}
#define countsetbits(x) __builtin_popcount(x)
#define ll long long
#define debug cout<<"I AM EXECUTING"<<endl
#define testcases int asdf; cin>>asdf; while(asdf--)
#define vi vector<int>
#define vll vector<long long int>
#define vppo(prs) for(auto x:prs){cout<<x.first<<" "<<x.second<<endl;}
#define For(__,hajmola,adfdf) for(int __ = hajmola; __<adfdf;__++)
#define formax 1e18
#define formin -1e18
#define watch(x) cout << (#x) << " is " << (x) << endl

string sconvert(ll int n)
{
	stringstream ss;
	ss<<n;
	string str = ss.str();
	return str;
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second > b.second);
}

template<typename T>
void imax(T &x,T y){
	x = max(x,y);
}
template<typename T>
void imin(T &x,T y){
	x = min(x,y);
}

void  single()
{

	string str;
	cin>>str;
	int n=str.length();
	int count=0;
	for(int i=0;i<n-3+1;i++){
		if(str[i]=='Z' and str[i+1]=='O' and str[i+2]=='N'){
			count++;
		}
	}
	cout<<count<<endl;
	return;
}
void multiple()
{
	testcases
    {
		single();
	}
}

int main()
{
  IOS;
 // freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  single();
}


#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using ll = long long;
const ll INF = 1ll<<60;

struct Edge{
    int to;
    int weight;
    int k;
    Edge(int t, int w, int k): to(t), weight(w), k(k) {}
};

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    --x;
    --y;

    vector<vector<Edge>> g(n);

    for(int i = 0; i < m; ++i){
        int a, b, t, k;
        cin >> a >> b >> t >> k;
        --a;
        --b;
        g[a].push_back(Edge(b, t, k));
        g[b].push_back(Edge(a, t, k));
    }

    vector<ll> dist(n, INF);
    dist[x] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
    pq.push({0, x});

    while(!pq.empty()){
        pair<ll, int> p = pq.top();
        pq.pop();
        int v = p.second;

        if(dist[v] != p.first) continue;

        for(auto ne: g[v]){
            ll ndist = ((dist[v] + ne.k - 1) / ne.k) * ne.k;
            // if(ndist % ne.k != 0) ndist += ne.k - ndist%ne.k;
            ndist += ne.weight;

            if(ndist < dist[ne.to]){
                dist[ne.to] = ndist;
                pq.push({dist[ne.to], ne.to});
            }
        }
    }

    if(dist[y] == INF) cout << -1 << endl;
    else cout << dist[y] << endl;

//    cout << endl;

//    for(auto e: dist) cout << e << " ";
//    cout << endl;

    return 0;
}

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

#include <bits/stdc++.h>

// #include <atcoder/all>

using namespace std;
// using namespace atcoder;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
void YES(bool t=true) {cout<<(t?"YES":"NO")<<endl;}
void Yes(bool t=true) {cout<<(t?"Yes":"No")<<endl;}
void yes(bool t=true) {cout<<(t?"yes":"no")<<endl;}
void NO(bool t=true) {cout<<(t?"NO":"YES")<<endl;}
void No(bool t=true) {cout<<(t?"No":"Yes")<<endl;}
void no(bool t=true) {cout<<(t?"no":"yes")<<endl;}
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
int popcount(ll t) { return __builtin_popcountll(t); }
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
struct Setup_io {
    Setup_io() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        cout << fixed << setprecision(25);
    }
} setup_io;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

const int N = 100123;
using P = pair<int, pll>;
vector<vector<P>> G(N);

vl dijkstra(int s, int n){
	priority_queue<pll, vector<pll>, greater<pll> > pq;
	int i;
	vl d(n, INF);
	d[s]=0;
	pq.push(make_pair(0,s));

	while(!pq.empty()){
		pll f=pq.top();
		pq.pop();
		int u=f.second;
		if(d[u]<f.first){
			continue;
		}
        ll cost = f.first;
		for (i = 0; i < G[u].size(); i++) {
			int v=G[u][i].first;
            ll ncost;
            ll k = G[u][i].second.second;
            if (cost % k == 0) {
                ncost = cost;
            }
            else {
                ncost = cost / k * k + k;
            }
            ncost += G[u][i].second.first;
			if (d[v] > ncost) {
				d[v] = ncost;
				pq.push(make_pair(d[v], v));
			}
		}
	}
	return d;
}

signed main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    x--; y--;
    rep (i, m) {
        int u, v, t, k;
        cin >> u >> v >> t >> k;
        u--; v--;
        G[u].push_back(P(v, pll(t, k)));
        G[v].push_back(P(u, pll(t, k)));
    }

    vl d = dijkstra(x, n);
    if (d[y] == INF) {
        cout << -1 << endl;
    }
    else {
        cout << d[y] << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define f first
#define s second
#define S size()
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)1e5+10;
 int a,b,sa,sb;
int main()
{
    cin>>a>>b;
    while (a) {
        sa+=a%10;
        a/=10;
    }
    while (b) {
        sb+=b%10;
        b/=10;
    }
    cout<<max(sa,sb);

}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const int maxn = 1e6 + 5;

int S(int x) {
    if (x==0) return 0;
    return x%10 + S(x/10);
}

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

    int a,b;
    cin>>a>>b;
    out(max(S(a),S(b)));

    return 0;
}


#include <bits/stdc++.h>

using ull = unsigned long long int;
using ll = long long;
using ld = long double;
using pii = std::pair<int,int>;
using pll = std::pair<ll, ll>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using vpll = std::vector<pll>;
using namespace std;

#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define drep(i,j) for(int (i)=(j);(i) >= 0;(i)--)

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}
template<class T> inline void pri(T a){cout << a << endl;}
template<class Z> using vec = vector<Z>;
template<class T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
 cout << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
cout << first << " " ;
OUT(rest...);
   return;
}
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;

int n,m,k;
ll N;
int h,w;
string S;
int a,b,c;
vi v;
int ans;
double x,y,z;

void solve()
{
    int N; IN(N);
    vector<vector<int>> g(N);
    vector<pair<int,int>> edge(N-1);
    rep(i,N-1)
    {
        int a,b; IN(a,b); a--;b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        edge[i] = pii{a,b};
    }

    vll depth(N,-1);
    depth[0] = 0;
    queue<pair<int,int>> q;
    q.push({0,-1});
    while(!q.empty())
    {
        int curr = q.front().first;
        int from = q.front().second;
       // OUT(curr,from);
        q.pop();
        for(auto  &npt : g[curr])
        {
            if(npt == from) continue;
            depth[npt] = depth[curr] + 1;
            q.push({npt,curr});
            //cout << npt << " ";
        }
        //OUT();
    }
    vll s(N);
    int Q; IN(Q);
    rep(_,Q)
    {
        int t,e;
        ll x;
        IN(t,e,x);
        e--;
        int a = edge[e].first;
        int b = edge[e].second;
        if(depth[a] > depth[b])
        {
            swap(a,b);
            t ^= 3;
        }
        if(t == 1)
        {
            s[0] += x;
            s[b] -= x;
        }
        else s[b] += x;
    }

    q.push({0,-1});
    while(!q.empty())
    {
        int curr = q.front().first;
        int from = q.front().second;
        q.pop();
        for(auto & npt: g[curr])
        {
            if(depth[curr] > depth[npt])continue;
            s[npt] += s[curr];
            q.push({npt,curr});
        }
    }
    for(auto &e : s)cout << e << endl;

}

signed main (int argc, char* argv[]) {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int cases=1;
   //IN(cases);
   while(cases--)solve();
   //pri(ans);
   //for(auto c : ans){cout << c << endl;}
   //cout << fixed << setprecision(15) << ans << endl;
   return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i < i##end; ++i)
#define per(i, a, b) for (int i = (a) - 1, i##end = (b); i >= i##end; --i)
#define REP(i, a) rep(i, 0, a)
#define PER(i, a) rep(i, a, 0)

namespace IO {
	const int MAXIOSIZE = 1 << 24 | 1;
	unsigned char buf[MAXIOSIZE], *p1, *p2;
	#define gc (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2) ? EOF : *p1++)
	template <typename T> void read(T& x) {
		x = 0; char ch = gc; bool flg = false;
		for (; ch < '0' || '9' < ch; ch = gc) if (ch == '-') flg |= true;
		for (; '0' <= ch && ch <= '9'; ch = gc) x = x * 10 + ch - '0';
		flg ? x = -x : 0;
	}
	template <typename T> void out(const T& x) { if (x > 9) out(x / 10); putchar(x % 10 + '0'); }
	template <typename T> inline void write(const T& x, const char& ed = ' ') { if (x < 0) putchar('-'), out(-x); else out(x); putchar(ed); }
}

typedef long long ll;

const int MAXN = 100 + 10;

int n;
ll X, a[MAXN], f[MAXN][MAXN], ans = LONG_LONG_MAX;

void chkmax(ll& a, ll b) { a < b ? a = b : 0; }

int main() {
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif
	IO::read(n), IO::read(X);
	REP(i, n) IO::read(a[i]);
	rep(cnt, 1, n + 1) {
		memset(f, -1, sizeof f); f[0][0] = 0, f[1][a[0] % cnt] = a[0];
		REP(i, n - 1) per(j, cnt + 1, 1) REP(k, cnt) if (f[j][k] != -1) {
			chkmax(f[j + 1][(k + a[i + 1]) % cnt], f[j][k] + a[i + 1]);
		}
		if (f[cnt][X % cnt] != -1) ans = min(ans, (X - f[cnt][X % cnt]) / cnt);
	}
	IO::write(ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
    int n,m;
    int i,j,k;
    LL a,b,c;
    vector<LL> v1,v2;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        v1.push_back(a);
    }
    for(i=0;i<n;i++){
        cin>>a;
        v2.push_back(a);
    }
    a=0,b=0;
    for(i=0;i<n;i++){
        a=max(a,v1[i]);
        b=max(b,a*v2[i]);
        cout<<b<<endl;
    }
}

#include <iostream>
#include <vector>
#include <map>

using namespace std;
using lint = long long;

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

    lint ans = 0, sum = 0;
    map<lint, lint> cnt{{0, 1}};
    for (int i = 0; i < n; ++i) {
        lint x;
        cin >> x;
        if (i % 2) x = -x;
        sum += x;
        ans += cnt[sum];
        ++cnt[sum];
    }

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

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

    solve();

    return 0;
}


/*if ((double) ((double)(clock() - cl)/(double)CLOCKS_PER_SEC)>1.85) {break;}*/
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define double long double
#define ft first
#define sc second
#define pb push_back
#define booost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0);
#define all(x) (x).begin(),(x).end()
#define file(x) freopen(string(string((x)) + ".in").c_str(), "r", stdin); freopen(string(string((x)) + ".out").c_str(), "w", stdout);
#define GG cout << " OPA " << '\n';

using namespace std;
using namespace __gnu_pbds;
typedef pair <int, int> pi;
typedef tree <pair <int, pair <int, int> >, null_type, less<pair <int, pair <int, int> > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1e3 + 100;
const int K = 7 * 1e4;
const int P = 37;
const int INF = 1e15;
const double d_INF = 2000000000.0;
const double EPS = 1e-20;
const int MOD = 1e9 + 7;
const int LOG = 20;
const double PI = 3.14159265359;

void solve() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if ((a[0] != a[1] && a[1] != a[2])) cout << 0;
    else {
        if (a[0] == a[1]) cout << a[2];
        else cout << a[0];
    }
}

main () {
    int test = 1;
    booost;
//    cin >> test;
    while (test --) {
        solve();
    }
}

///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

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

using    namespace __gnu_pbds;
using    namespace std;

#define     FAST            ios::sync_with_stdio(0); cin.tie(0)
#define     int 	        long long
#define 	pb 	            push_back
#define     ppb             pop_back
#define 	mp 	            make_pair
#define 	pi 	            2*acos(0.0)
#define     scan(i)         scanf("%lld",&i)
#define     scann(i,j)      scanf("%lld%lld",&i,&j)
#define     print(i)        printf("%lld\n",i)
#define     printt(i,j)     printf("%lld %lld\n",i,j)
#define     loop(i,n) 	    for(int i = 0 ; i < n ; i++)
#define     loop1(i,n)      for(int i = 1 ; i <= n ; i++)
#define     rep(i,n)        for(int i=n-1;i>=0;i--)
#define     rev(v)          reverse(v.begin(),v.end())
#define     reset(a,b)      memset(a,b,sizeof(a))
#define 	vect 	        vector<int>
#define 	vec_it 	        vector<int>::reverse_iterator vi
#define     sorta(v)        sort(v.begin(),v.end())
#define     sortd(v)        sort(v.begin(),v.end(),greater<>())
#define     sorted(v)       is_sorted(v.begin(),v.end())
#define     mnv(v)          *min_element(v.begin(),v.end())
#define     mxv(v)          *max_element(v.begin(),v.end())
#define     countv(v,a)     count(v.begin(),v.end(),a)
#define     vplusa(v,a)     v.insert(v.end(),a.begin(),a.end())
#define 	mapp 	        map<int,int>
#define     rmap            map<int,int,greater<>>m
#define 	pairr 	        pair<int,int>
#define 	sett	        set<int>
#define     rset            set<int,greater<>>s
#define 	set_it 	        set<int>::reverse_iterator si
#define     map_it          map<int,int> :: reverse_iterator mi
#define     setp(x)         fixed<<setprecision(x)
#define     digit(n)        floor(log10(n)+1)
#define 	yes 	        cout<<"Yes"<<endl
#define 	no 	            cout<<"No"<<endl
#define 	ff 	            first
#define 	ss 	            second
#define     mx              INT_MAX
#define     lmx             LLONG_MAX
#define     mn              INT_MIN
#define     lmn             LLONG_MIN
#define     inf             0x3f3f3f3f
#define     inff            10e18
#define     GCD             __gcd(a,b)
#define     LCM             (a/GCD)*b
#define     ub              upper_bound
#define     lb              lower_bound
#define     mod             1000000007

inline void normal(int &a) { a %= mod; (a < 0) && (a += mod); }
inline int modMul(int a, int b) { a %= mod, b %= mod; normal(a), normal(b); return (a*b)%mod; }
inline int modAdd(int a, int b) { a %= mod, b %= mod; normal(a), normal(b); return (a+b)%mod; }
inline int modSub(int a, int b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline int modPow(int b, int p) { int r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline int modInverse(int a) { return modPow(a, mod-2); }
inline int modDiv(int a, int b) { return modMul(a, modInverse(b)); }

template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // 1 2 3
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> reverse_ordered_set; // 3 2 1

void solve()
{
   // freopen ("(input).txt" , "r",  stdin) ;
    string st,stt;
    int low=0,high=0;
    int l,r; char ch;
    int n,k,t,x,y,z,d=0,cnt=0,temp=0,sum=0,f=0,flag=0;
    cin>>n>>k>>t ; vect v ; sett s ; mapp m,mm ; pairr p ;
    if(n==k) cout<<t<<endl;
    else if(n==t) cout<<k<<endl;
    else if(k==t) cout<<n<<endl;
    else cout<<0<<endl;

}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


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

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

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    string s;
    cin >> s;

    if (s[0] != s[n-1]){
        cout << 1 << endl;
        return 0;
    }

    bool ok = 0;
    for(int i=1; i<n-1; i++){
        if (s[0] != s[i] && s[i+1] != s[n-1]){
            ok = 1;
            break;
        }
    }

    if (ok)
        cout << 2 << endl;
    else
        cout << -1 << endl;

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

#include <cstdio>
#include <cstring>
#define N 100010

using namespace std;

int n;
char s[N];

int main(){
//	freopen("funny.in", "r", stdin);
	scanf("%d", &n);
	scanf("%s", s+1);
	if (s[1]!=s[n]){
		printf("1\n");
	}
	else{
		bool pd=0;
		for (int i=2; i<=n; i++){
			if (s[i]!=s[1] && s[i-1]!=s[1]) pd=1;
		}
		if (pd) printf("2\n");
		else printf("-1\n");
	}
	return 0;
}


#include <bits/stdc++.h>

int main() {
    long long int S, P;
    std::cin >> S >> P;

    long long int max = std::sqrt(P) + 1;
    bool flag = false;
    for (long long int i = 1; i < max; i ++) {
        if (P % i == 0 && (S - i) * i == P) {
            flag = true;
            break;
        }
    }
    if (flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

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

#define fast			ios_base::sync_with_stdio(0);cin.tie(0)
#define f0(a,b,c) 		for(int a=b;a<c;a++)
#define re(a,b,c) 		for(int a=b;a>=c;a--)
#define trav(a,x)		for(auto &a:x)
#define ini(a,x)		memset(a,x,sizeof(a))
#define pb 				push_back
#define eb				emplace_back
#define fi 				first
#define se 				second
#define all(con) 		con.begin(),con.end()
#define rall(con)		con.rbegin(),con.rend()
#define ll 				long long
#define vi 				vector<int>
#define vll 			vector<ll>
#define MOD 			1000000007
#define pi 				pair<int,int>
#define pll 			pair<ll,ll>
#define mi 				map<int,int>
#define mll				map<ll,ll>
#define umi 			unordered_map<int,int>
#define umll 			unordered_map<ll,ll>
#define lb 				lower_bound
#define ub 				upper_bound
#define pq 				priority_queue<ll,ll>
#define st				stack<int>
#define qu				queue<int>
#define endl            "\n"
#define sz(a)			(int)a.size()
using ull = unsigned long long;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

ll powm(ll a , ll n)
{
	ll res = 1;

	while(n)
	{
		if(n & 1)
		res = (res * a);

		n >>= 1;
		a = (a * a);
	}

	return res;
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}
int main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll s,p;
		cin>>s>>p;
		ll x=p;
		vll v;
		v.pb(1);
		for(ll i=2;i*i<=p;i++)
		{
		    if(p%i==0)
		    {
		        v.pb(i);
		        v.pb(p/i);
		    }
		}

		v.pb(p);
		f0(i,0,sz(v))
		 {
		     f0(j,i,sz(v))
		     {
		         if(v[i]+v[j]==s and v[i]*v[j]==p)
		          {
		              cout<<"Yes";
		              return 0;
		          }
		     }
		 }
		 cout<<"No"<<endl;
	}
	return 0;
}


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

typedef long long ll;

ll merge_cnt(vector<int> &a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<int> b(a.begin(), a.begin()+n/2);
    vector<int> c(a.begin()+n/2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    // merge の処理
    while (ai < n) {
        if ( bi < b.size() && (ci == c.size() || b[bi] <= c[ci]) ) {
            a[ai++] = b[bi++];
        } else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

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

    vector<int> a(n);

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

    ll cnt = merge_cnt(a_cp);
    vector<ll> ans(n);
    ans[0] = cnt;
    for (int i = 0; i < n; i++) {
        // cout << cnt << endl;
        int p = a[n-i-1];
        // cout << cnt << endl;
        cnt = cnt + p - (n - 1 - p);
        if (i < n - 1) ans[n-i-1] = cnt;
    }

    for (auto an: ans) cout << an << endl;

    return 0;
}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 300005

ll first_N;
ll uniformity[6*NUM],partial[6*NUM];
ll N = 1;
ll A[NUM];
ll BIT[NUM];

void bitadd(ll loc,ll value){

	BIT[loc] += value;

	loc += loc & -loc; //最後の1ビットを足した場所が次の★更新★場所

	while(loc <= first_N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

ll BITSum(ll loc){

	ll sum = BIT[loc];

	loc -= loc & -loc; //最後の1ビットを引いた場所が次の★加算★場所

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

void init(){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return (node_right-node_left)*uniformity[node_id]+partial[node_id];

	}else{
		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		return sum;
	}
}

int main(){

	scanf("%lld",&first_N);

	for(ll i = 0; i < first_N; i++){

		scanf("%lld",&A[i]); //1～first_N
		A[i]++;
	}

	for(ll i = 0; i <= first_N; i++){

		BIT[i] = 0;
	}

	init();

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	ll ans = 0;

	for(ll i = 0; i < first_N; i++){

		ll tmp = i-BITSum(A[i]);
		ans += tmp;
		bitadd(A[i],1);
		add(A[i],A[i]+1,tmp,0,0,N);
	}

	printf("%lld\n",ans);

	int head = 0;

	for(ll loop = 0; loop < first_N-1; loop++){

		ll tmp = first_N-(A[head]); //A[head]より大きい数の個数
		ll minus = getSum(A[head],A[head]+1,0,0,N);

		//printf("A[head]:%lld loop:%lld tmp:%lld minus:%lld\n",A[head],loop,tmp,minus);
		add(A[head],A[head]+1,-minus+tmp,0,0,N); //
		if(A[head] >= 2){

			add(1,A[head],-1,0,0,N);
		}
		printf("%lld\n",getSum(1,first_N+1,0,0,N));

		head++;
	}

	return 0;
}


#define _GLIBCXX_DEBUG
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	ios::sync_with_stdio(false);

	vector<int> a(4); rep(i, 4) cin >> a[i];
	int Min=100;

	rep(i, 4) Min = min(Min, a[i]);

	cout << Min << "\n";

	return 0;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=min({a,b,c,d});
  cout<<x<<endl;
}


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

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

ll read(){
	ll a=0,b=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();}
	while(c>='0'&&c<='9')a=a*10+c-48,c=getchar();
	return a*b;
}

const long double eps=1e-14;

int main(){
	long double x,y,rr;
	cin>>x>>y>>rr;rr+=eps;
	ll anss=0;
	for(int i=x-rr-1;i<=x+rr+1;i++){
		long double p=rr*rr-(x-i)*(x-i);
		if(p<0.0)continue;
		long double dy=sqrt(p+eps);
		anss+=(floor(y+dy)-ceil(y-dy)+1);
	}
	cout<<anss<<'\n';
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define fore(i_in,a) for (auto& i_in: a)
#define forp(x,y,a) for(auto& [x, y]: a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pq(T) priority_queue<T, vector<T>, greater<T>>
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define ofst_FLR(a, b) (a-1)/b;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<(int)v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }

int main() {
    fio(); long double x,y,r; cin>>x>>y>>r;
    r+=1e-14;
    ll ans = 0;
    ll start = ceil(x-r), end = floor(x+r);
    for(ll i=start; i<=end; i++) {
        long double p = sqrt(pow(r,2)-pow(x-i,2));
        ll bottom = ceil(y-p), top = floor(y+p);
        ans += top - bottom + 1;
    }
    print(ans);
}


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

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

    for(int i = 0 ; i < N  ; i++) cout << (2*i + 1 )%N + 1<< " " << (2*i + 2)%N + 1 << endl;
}

///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

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

using    namespace __gnu_pbds;
using    namespace std;

#define     FAST            ios::sync_with_stdio(0); cin.tie(0)
#define     int 	        long long
#define 	pb 	            push_back
#define     ppb             pop_back
#define 	mp 	            make_pair
#define 	pi 	            2*acos(0.0)
#define     scan(i)         scanf("%lld",&i)
#define     scann(i,j)      scanf("%lld%lld",&i,&j)
#define     print(i)        printf("%lld\n",i)
#define     printt(i,j)     printf("%lld %lld\n",i,j)
#define     loop(i,n) 	    for(int i = 0 ; i < n ; i++)
#define     loop1(i,n)      for(int i = 1 ; i <= n ; i++)
#define     rep(i,n)        for(int i=n-1;i>=0;i--)
#define     rev(v)          reverse(v.begin(),v.end())
#define     reset(a,b)      memset(a,b,sizeof(a))
#define 	vect 	        vector<int>
#define 	vec_it 	        vector<int>::reverse_iterator vi
#define     sorta(v)        sort(v.begin(),v.end())
#define     sortd(v)        sort(v.begin(),v.end(),greater<>())
#define     sorted(v)       is_sorted(v.begin(),v.end())
#define     mnv(v)          *min_element(v.begin(),v.end())
#define     mxv(v)          *max_element(v.begin(),v.end())
#define     countv(v,a)     count(v.begin(),v.end(),a)
#define     vplusa(v,a)     v.insert(v.end(),a.begin(),a.end())
#define 	mapp 	        map<int,int>
#define     rmap            map<int,int,greater<>>m
#define 	pairr 	        pair<int,int>
#define 	sett	        set<int>
#define     rset            set<int,greater<>>s
#define 	set_it 	        set<int>::reverse_iterator si
#define     map_it          map<int,int> :: reverse_iterator mi
#define     setp(x)         fixed<<setprecision(x)
#define     digit(n)        floor(log10(n)+1)
#define 	yes 	        cout<<"Yes"<<endl
#define 	no 	            cout<<"No"<<endl
#define 	ff 	            first
#define 	ss 	            second
#define     mx              INT_MAX
#define     lmx             LLONG_MAX
#define     mn              INT_MIN
#define     lmn             LLONG_MIN
#define     inf             0x3f3f3f3f
#define     inff            10e18
#define     GCD             __gcd(a,b)
#define     LCM             (a/GCD)*b
#define     ub              upper_bound
#define     lb              lower_bound
#define     mod             1000000007

inline void normal(int &a) { a %= mod; (a < 0) && (a += mod); }
inline int modMul(int a, int b) { a %= mod, b %= mod; normal(a), normal(b); return (a*b)%mod; }
inline int modAdd(int a, int b) { a %= mod, b %= mod; normal(a), normal(b); return (a+b)%mod; }
inline int modSub(int a, int b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline int modPow(int b, int p) { int r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline int modInverse(int a) { return modPow(a, mod-2); }
inline int modDiv(int a, int b) { return modMul(a, modInverse(b)); }

template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // 1 2 3
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> reverse_ordered_set; // 3 2 1

void solve()
{
   // freopen ("(input).txt" , "r",  stdin) ;
    string st,stt;
    int low=0,high=0;
    int l,r; char ch;
    int n,k,t,x,y,z,d=0,cnt=0,temp=0,sum=0,f=0,flag=0;
    cin>>n ; vect v ; sett s ; mapp m,mm ; pairr p ;
    loop(i,n)
    {
        cin>>x;
        if(x>10) sum+=x-10;
    }
    cout<<sum<<endl;

}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


#line 1 "main_d.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

void solve(){
  i64 n;
  std::cin>>n;

  std::vector<i64> a(n);
  for(auto&& e:a)std::cin>>e;

  if(n%2==0){
    std::sort(all(a));
    bool firstwin=false;
    rep(i,0,n/2){
      if(a[2*i] < a[2*i+1])firstwin=true;
    }

    if(firstwin)std::cout<<"First\n";
    else std::cout<<"Second\n";

    return;
  }else{
    std::cout<<"Second\n";
    return;
  }
}

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

  i64 test;
  std::cin>>test;

  while(test--)solve();

  return 0;
}

#include<bits/stdc++.h>
#define int ll
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
using namespace std;
using ll = long long;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;

int A[100100];

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

    int n; cin>>n;
    for (int i=1; i<=n; i++) cin>>A[i];

    sort(A+1, A+n+1);
    int res = 1;
    const int mod = 1e9+7;
    for (int i=1; i<=n; i++) {
        res = res*(A[i]-A[i-1]+1)%mod;
    }
    cout<<res<<'\n';

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,n) for(ll i=0;i<n;i++)
#define loopn(i,j,n) for(ll i=j;i<n;i++)
#define m_arr(arr, n) vector<ll>arr(n)
#define m_arre(arr) vector<ll>arr
#define m_set(sat) set<ll>sat
#define ppn(name) pair<ll,ll>name
#define pp pair<ll,ll>
#define sort_all(arr) sort(arr.begin(), arr.end())
#define pi 3.141592653589793238
#define mod 1000000007
#define inf 1000000000000000007

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

ll power(ll a, ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b%2!=0)
            res = (res*1ll*a);
        b/=2;
        a=(a*1ll*a);
    }

    return res;
}

void solve()
{
    ll n;
    cin>>n;
    m_arr(arr, n+1);
    for(ll i=0;i<32;i++)
    {
        ll x = (1<<i);
        if(x<=n)
            arr[x]=1;
        else
            break;
    }

    loopn(i,1,n+1)
    {
        arr[i]=arr[i-1]+arr[i];
    }

    loopn(i, 1, n+1)cout<<arr[i]<<" ";cout<<endl;
    return;

}

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

#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << (x);
#define OUTL(x) cout << (x) << endl;
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 (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n, d, h);
    double ans = 0;
    rep(i, n) {
        IN(x, y);
        chmax(ans, (double)(y * d - x * h) / (d - x));
    }
    OUTL(ans);
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}