#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 1e5 + 5;
int n, Q, a[N], q[N], id[N], ans[N];
bool cmp (int a, int b) {
	return q[a] < q[b];
}
signed main () {
	cin >> n >> Q;
	rep(i, 1, n) cin >> a[i];
	a[++n] = 3e18;
	rep(i, 1, Q) cin >> q[i], id[i] = i;
	sort(id + 1, id + Q + 1, cmp);
	for (int i = 1, j = 1, cnt = 0; i <= Q; ++i) {
		for (; cnt < q[id[i]] && j <= n; ++j) cnt += a[j] - a[j - 1] - 1;
		ans[id[i]] = a[j - 1] - (cnt - q[id[i]]) - 1;
	}
	rep(i, 1, Q) cout << ans[i] << endl;
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n = 4;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int sum = accumulate(ALL(a), 0);
  rep(i, n){
    if(a.at(i) == sum - a.at(i)){
      cout << "Yes" << endl;
      return 0;
    }
    rep2(j, i+1, n){
      if(a.at(i) + a.at(j) == sum - a.at(i)-a.at(j)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
#define INF 1999999999
#define MODA 1000000007
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define rep1(i,n) for (long long i = 1; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define errvn1(x) cerr << #x <<" "<< x << endl;
#define errvn2(x, y) cerr << #x <<" "<< x <<" "<< #y <<" "<< y << endl;
#define errvn3(x, y, z) cerr << #x <<":"<< x <<" "<< #y <<":"<< y <<" "<< #z <<":"<< z << endl;
#define errvn4(x, y, z, a) cerr << #x <<":"<< x <<" "<< #y <<":"<< y <<" "<< #z <<":"<< z <<" "<< #a <<":"<< a << endl;
#define errop2(x, y) cerr << x <<" "<< y << endl;
#define errop3(x, y, z) cerr << x <<" "<< y <<" "<< z << endl;
#define errop4(x, y, z, a) cerr << x <<" "<< y <<" "<< z <<" "<< a << endl;

int main() {
  ll N, X;
  cin >> N >> X;
  string S;
  cin >> S;

  ll ans = X;
  for(ll i=0; i<S.size(); ++i) {
    if(S[i] == 'o') {
      ans++;
    }
    else if (ans > 0) {
      ans--;
    }
  }
  cout << ans << endl;

  return 0;
}

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=4e5+10;
const ll MOD=998244353;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
template <int _MOD> struct Mint
{
    //一个好的软件包应该是封闭的，例如，mint的所有操作都可以在软件包内部实现的
    long long v = 0;
    Mint() {}
    Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
    Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
    Mint operator = (const int &_v) { return *this = Mint(_v); }
    Mint operator = (const long long &_v) { return *this = Mint(_v); }
    bool operator ! () const { return !this->v; }
    bool operator < (const Mint &b) const { return v < b.v; }
    bool operator > (const Mint &b) const { return v > b.v; }
    bool operator == (const Mint &b) const { return v == b.v; }
    bool operator != (const Mint &b) const { return v != b.v; }
    bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
    bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
    Mint operator + (const Mint &b) const { return Mint(v+b.v); }
    Mint operator - (const Mint &b) const { return Mint(v-b.v); }
    Mint operator * (const Mint &b) const { return Mint(1ll*v*b.v); }
    Mint operator / (const Mint &b) const { return Mint(b.inv()*v); }
    Mint& operator += (const Mint &b) { return *this = *this+b; }
    Mint& operator -= (const Mint &b) { return *this = *this-b; }
    Mint& operator *= (const Mint &b) { return *this = *this*b; }
    Mint& operator /= (const Mint &b) { return *this = *this/b; }
    Mint operator - () const { return Mint(-v); }
    Mint& operator ++ () { return *this += 1; }
    Mint& operator -- () { return *this -= 1; }
    Mint operator ++ (int) { Mint tmp = *this; *this += 1; return tmp; }
    Mint operator -- (int) { Mint tmp = *this; *this -= 1; return tmp; }
    Mint pow(int p) const {
        Mint res(1), x(*this);
        while (p) {
            if (p&1) res = res*x;
            x *= x;
            p >>= 1;
        }
        return res;
    }
    Mint inv() const {
        if(v==0)return Mint(1);
        return pow(_MOD-2);
    }
    friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v;mt.v=mt.v%_MOD; }
    friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;
mint factor[MAXN];
mint inv[MAXN];
void cal_factor(){factor[0]=mint(1);for(int u=1;u<MAXN;u++){factor[u]=factor[u-1]*mint(u);}}
void cal_factor_inv(){inv[0]=mint(1);inv[MAXN-1]=factor[MAXN-1].inv();for(int u=MAXN-2;u>=1;u--){inv[u]=inv[u+1]*mint(u+1);}}
void init_factor(){cal_factor();cal_factor_inv();}
mint C(ll n,ll k){if(n<k)return mint(0);return factor[n]*inv[n-k]*inv[k];}
void solve(){
    int n,m;
    cin>>n>>m;
    init_factor();
    mint ans=mint(0);
    for(ll t=1;t<=m;t++){
        ll x=t;
        mint tmp=mint(1);
        for(ll q=2;q*q<=x;q++){
            int cnt=0;
            while(x%q==0){
                x/=q;
                cnt++;
            }
            tmp*=C(cnt+n-1,cnt);
        }
        if(x>1)tmp*=mint(n);
        ans+=tmp;
    }
    cout<<ans<<"\n";
}
// #define LOCAL
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}


// clang-format off
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcountll
#define ffs __builtin_ffsll
#define ctz __builtin_ctzll
#define clz __builtin_clz
#define clzll __builtin_clzll
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;
    vec<vi> skill(n, vi(5));
    forn(i, n) {
        forn(j, 5) cin >> skill[i][j];
    }

    vec<vi> p(3);

    int ans = 0;
    int c = 0;
    function<void(int)> dfs = [&](int x) {
        if (x == 5) {
            c++;
            int v = TEN(9) + 10;
            forn(i, 3) { // スキル分担
                int u = 0;
                forn(j, n) {
                    int temp = TEN(9) + 10;
                    for (auto k : p[i]) {
                        chmin(temp, skill[j][k]);
                    }
                    chmax(u, temp);
                }
                chmin(v, u);
            }

            chmax(ans, v);

            return;
        }

        forn(i, 3) {
            p[i].push_back(x);
            dfs(x + 1);
            p[i].pop_back();
        }
    };

    dfs(0);

    cerr << c << endl;

    cout << ans << endl;

    return 0;
}

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

using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
#define fout() fflush(stdout)
//debugger

#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger

bool comp(const int &a, const int &b)
{
    return a>b;
}
bool comp2(const pair<int,set<int>> &a, pair<int,set<int>> &b)
{
    if(a.ss.size()!=b.ss.size()) return a.ss.size()>b.ss.size();
    else return a.ff<b.ff;
}

int main()
{
    FASTIO;
    int n;
    string s;
    cin>>n>>s;
    string p;
    for(auto it: s)
    {
        p.push_back(it);
        {
            if(p.size()>=3)
            {
                if(p[p.size()-1]=='x'&&p[p.size()-2]=='o'&&p[p.size()-3]=='f')
                {
                    loop(i,3) p.pop_back();
                }
            }
        }
    }
    cout<<p.size()<<endl;
}


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

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

  vector<int> A(100001),B(100001),C(100001);
  vector<int> count(100001);

  for(int i=0;i<N;i++){
  	cin>>A.at(i);
  }

  for(int i=0;i<N;i++){
  	cin>>B.at(i);
  }

  for(int i=0;i<N;i++){
  	cin>>C.at(i);
  }

  for(int j=0;j<N;j++){
  	count.at(B.at(C.at(j)-1))+=1;
  }

  long long ans=0;
  for(int i=0;i<N;i++){
  	ans+=count.at(A.at(i));
  }
  cout<<ans<<endl;

  return 0;
}

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

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

#define int long long
#define reset(x) memset(x,0,sizeof(x))
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
#define PI 3.1415926535897932384626433832795
#define INF 1000000000
#define MOD 1000000007
#define MOD2 1000000009
#define EPS 1e-6
#define pb push_back
#define fi first
#define se second
#define mp make_pair

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

const int MAXN = 100005;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    int n; cin >> n;
    int arr[n + 1], brr[n + 1], crr[n + 1];

    vector<vector<int>> equal(n + 1, vector<int>());
    int exist[n + 1];
    reset(exist);
    for (int i = 0; i < n; i++)
    {
    	cin >> arr[i + 1];
    	exist[arr[i + 1]]++;
    }
    for (int i = 0; i < n; i++)
    {
    	cin >> brr[i + 1];
    	equal[brr[i + 1]].pb(i + 1);
    }
    int num_time[n + 1];
    reset(num_time);
    for (int i = 0; i < n; i++)
    {
    	cin >> crr[i + 1];
    	num_time[crr[i + 1]]++;
    }
    int sum = 0;
    bool used[n + 1]; reset(used);
    for (int i = 1; i <= n; i++)
    {
    	int tmp = 0;
    	if (used[arr[i]] == true)
    	{
    		continue;
    	}
    	for (int x : equal[arr[i]])
    	{
    		tmp += num_time[x];
    	}
    	sum += (tmp * exist[arr[i]]);
    	used[arr[i]] = true;
    }
    cout << sum;
}


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

bool solve(string s){
    if(s.size() == 1) return s == "8";
    if(s.size() == 2){
        if(stoi(s) % 8 == 0) return 1;
        swap(s[0], s[1]);
        return stoi(s) % 8 == 0;
    }
    vector<int> cnt(10);
    for(char x : s) cnt[x - '0']++;
    for(int i = 104; i < 1000; i += 8){
        auto c = cnt;
        for(char x : to_string(i)) c[x - '0']--;
        if(all_of(c.begin(), c.end(), [](int x){ return x >= 0; })) return 1;
    }
    return 0;
}
int main(){
    string s;
    cin >> s;
    puts(solve(s) ? "Yes" : "No");
}

#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(), c.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, a, b) for (int i = a; i <= b; ++i)
#define rep3(i, a, b) for (int i = a; i >= b; --i)
#define endl '\n'
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void yes(bool t = 1) { cout << yesno[t] << endl; }

template <class T, class S>
inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S>
inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
#define INT(...)     \
    int __VA_ARGS__; \
    IN(__VA_ARGS__)
#define LL(...)     \
    ll __VA_ARGS__; \
    IN(__VA_ARGS__)
#define VEC(type, name, size) \
    vector<type> name(size);  \
    IN(name)
#define DBL(...)    \
    ld __VA_ARGS__; \
    IN(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define VV(type, name, h, w)                       \
    vector<vector<type>> name(h, vector<type>(w)); \
    IN(name)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S>
void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T>
void scan(vector<T> &);
template <class T>
void scan(vector<T> &a) {
    for (auto &i : a)
        scan(i);
}
template <class T>
void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail>
void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
}
template <class T>
vector<T> divisor(T x) {
    vector<T> ans;
    for (T i = 1; i * i <= x; i++)
        if (x % i == 0) {
            ans.pb(i);
            if (i * i != x)
                ans.pb(x / i);
        }
    return ans;
}
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int inf = 1e9;
// constexpr i64 inf = 1e18;
// const int N = 500 * 1000 + 5; // use for N <= 5 * 10^5
// const int MX = 1e9 + 7; // For convenience, find the answer modulo 10^9+7
// cout << rng();
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    INT(n, m);
    vector<vector<pair<int, int>>> g(n);
    rep(i, m) {
        INT(a, b, c);
        --a, --b;
        g[a].emplace_back(b, c);
    }
    auto dijkstra = [&](int u) {
        vi d(n, inf);
        priority_queue<pair<int, int>> pq;
        // variation.
        for (auto [v, w] : g[u]) {
            if (w < d[v]) {
                d[v] = w;
                pq.emplace(-d[v], v);
            }
        } // push과정에서 시작노드만이아니라 시작노드에서 모든방향 넣기.
        // pq.push({s,0});
        // d[s] = 0; /
        while (!pq.empty()) {
            auto [dist, c] = pq.top();
            dist = -dist;
            pq.pop();
            if (c == u)
                return dist;
            for (auto [v, w] : g[c]) {
                if (w + d[c] < d[v]) {
                    d[v] = w + d[c];
                    pq.emplace(-d[v], v);
                }
            }
        }
        return -1;
    };
    rep(i, n) {
        cout << (dijkstra(i)) << endl;
    }
    return 0;
}


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

int main() {
    __int128_t X;
    ll x, y, a, b;
    cin >> x >> y >> a >> b;
    ll v = 0;
    while (true) {
        if (x < y) {
            X = (__int128) x * (__int128) a;
            if (X > b || X >= y - 1) break;
            v++;
            x = x * a;
        } else {
            break;
        }
    }
    ll t = (y - 1 - x) / b;
    v += t;
    cout << v << "\n";
    return 0;
}

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

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


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

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

ll N;
ll A[3030][5];
ll cnt[1<<5];

ll getmsk(ll i, ll x) {
    ll res = 0;
    rep(j,5) if (x<=A[i][j]) res |= (1<<j);
    return res;
}

bool OK(ll x) {
    rep(i,1<<5) cnt[i] = 0;
    rep(i,N) cnt[getmsk(i,x)]++;
    rep(i,1<<5) rep(j,1<<5) rep(k,1<<5) {
        ll bit = i | j | k;
        if (bit!=(1<<5)-1) continue;
        if (cnt[i]==0 || cnt[j]==0 || cnt[k]==0) continue;
        return true;
    }
    return false;
}

int main() {
    cin >> N;
    rep(i,N) rep(j,5) cin >> A[i][j];

    ll l = 0, r = 1e9+1;
    while (r-l>1) {
        ll m = (l+r)/2;
        bool flag = OK(m);
        if (flag) l = m;
        else r = m;
    }

    cout << l << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

    while (X < LONG_MAX / A && X * A < X + B && X * A < Y) {
        X *= A;
        ans++;
    }

    cout << (ans + (Y - X - 1) / B) << endl;
}


/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 61;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[201][12];

void cmemoInit(){
    rep(i, 201){
        rep(j, 12){
            conbinationMemo[i][j] = -1;
        }
    }
}

ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll h, w, k;
vector<string> s;
#define MOD 998244353
ll inv3;
ll memo[5100][5100];
ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}

	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll modpow(ll a, ll b){
    ll res = 1;
    while(b > 0){
        if(b & 1){
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}
ll getinv(ll n){
    ll x, y;
    ll g = extGCD(n, MOD, x, y);
    while(x < 0) x += MOD;
    return x % MOD;
}
ll rec(ll i, ll j){
    if(i == 0 && j == 0){
        ll res = modpow(3, h * w - k);
        if(s[i][j] == '.'){
            return res * inv3 * 2 % MOD;
        } else {
            return res;
        }
    }

    if(memo[i][j] != -1) return memo[i][j];

    ll res = 0;
    if(i - 1 >= 0){
        if(s[i - 1][j] != 'R') {
            res += rec(i - 1, j);
            res %= MOD;
        }
    }
    if(j - 1 >= 0){
        if(s[i][j - 1] != 'D') {
            res += rec(i, j - 1);
            res %= MOD;
        }
    }

    if(s[i][j] == '.' && !(i == h - 1 && j == w - 1)){
        res *= 2;
        res %= MOD;
        res *= inv3;
        res %= MOD;
    }
    return memo[i][j] = res;
}
int main(void){
    cin >> h >> w >> k;
    s.resize(h);
    rep(i, h) s[i].resize(w, '.');
    rep(i, k){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        char c;
        cin >> c;
        s[a][b] = c;
    }
    inv3 = getinv(3);
    rep(i, 5100) rep(j, 5100) memo[i][j] = -1;
    cout << rec(h - 1, w - 1) << endl;
}

#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[110][110];
ll fac[110];
int par[110];
int rnk[110];

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

bool mymerge(int x,int y)
{
    x = root(x);
    y = root(y);

    if(x==y)return false;

    rnk[x]+=rnk[y];
    par[y] = x;

    return true;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

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

    fac[0] = 1;

    for(int i=1;i<=n;i++){
        fac[i] = fac[i-1]*(ll)i;
        fac[i] %= PMOD;
    }

    for(int i=1;i<=n;i++){
        par[i] = i;
        rnk[i] = 1;
    }

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            cnt = 0;
            for(int t=1;t<=n;t++){
                if(A[i][t]+A[j][t]<=k){
                    cnt++;
                }
            }
            if(cnt==n)mymerge(i,j);
        }
    }

    ll res = 1;

    for(int i=1;i<=n;i++){
        if(par[i]==i){
            res*=fac[rnk[i]];
            res%=PMOD;
        }
    }

    for(int i=1;i<=n;i++){
        par[i] = i;
        rnk[i] = 1;
    }

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            cnt = 0;
            for(int t=1;t<=n;t++){
                if(A[t][i]+A[t][j]<=k){
                    cnt++;
                }
            }
            if(cnt==n)mymerge(i,j);
        }
    }

    for(int i=1;i<=n;i++){
        if(par[i]==i){
            res*=fac[rnk[i]];
            res%=PMOD;
        }
    }

    cout<<res<<"\n";

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;
using pairint = pair<int, int>;

template <typename T>
struct SegmentTree{
    SegmentTree(unsigned int n, function<T(T, T)> AssociativeFunction, T ZeroElement=0){
        length = 1;
        fn = AssociativeFunction;
        z = ZeroElement;
        while(length < n*2){
            length <<= 1;
        }
        Nodes.assign(length, z);
    }
    void assign(unsigned int index, T value){
        unsigned int initindex = (length>>1) + index;
        Nodes[initindex] = value;
        for(unsigned int i=initindex>>1; i>0; i>>=1){
            Nodes[i] = fn(Nodes[i*2], Nodes[i*2+1]);
        }
    }
    T element(unsigned int index){
        return Nodes[(length>>1) + index];
    }
    T query(unsigned int lindex, unsigned int rindex){
        int l = (length>>1) + lindex;
        int r = (length>>1) + rindex;
        T res = z;
        while(l <= r){
            if(r==l){
                if(res==z){
                    res = Nodes[l];
                }else res = fn(res, Nodes[l]);
                break;
            }
            if(l%2==1){
                if(res==z){
                    res = Nodes[l];
                }else res = fn(res, Nodes[l]);
                l += 2;
            }
            if(r%2==0){
                if(res==z){
                    res = Nodes[r];
                }else res = fn(res, Nodes[r]);
                r -= 2;
            }
            l>>=1;
            r>>=1;
        }
        return res;
    }

private:
    T z;
    unsigned int length;
    vector<T> Nodes;
    function<T(T, T)> fn;
};

int main(void){
    int H, W, M, Xbuf, Ybuf;
    long long res = 0;
    vector<int> leftmost, uppermost;
    priority_queue<pairint, vector<pairint>, greater<pairint>> que;
    cin >> H >> W >> M;
    leftmost.assign(H, W);
    uppermost.assign(W, H);
    for(int i=0; i<M; i++){
        cin >> Xbuf >> Ybuf;
        Xbuf--;
        Ybuf--;
        leftmost[Xbuf] = min(leftmost[Xbuf], Ybuf);
        uppermost[Ybuf] = min(uppermost[Ybuf], Xbuf);
        que.push(pairint(Ybuf, Xbuf));
    }
    for(int i=0; i<uppermost[0]; i++)res += leftmost[i];
    SegmentTree<int> st(H, plus<int>());
    for(int i=uppermost[0]; i<H; i++)st.assign(i, 1);
    for(int i=0; i<leftmost[0]; i++){
        if(!que.empty()){
        pairint nxtObstruction = que.top();
            while(nxtObstruction.first < i){
                que.pop();
                if(nxtObstruction.second < uppermost[0])st.assign(nxtObstruction.second, 1);
                if(que.empty())break;
                nxtObstruction = que.top();
            }
        }
        res += st.query(0, uppermost[i]-1);
    }
    cout << res << endl;
    return 0;
}

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

int main(){

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

  cout << fixed << setprecision(10);

  double maxi=0;
  for(int i=0; i<N; i++){
  double a=d[i]-D;
  double b=H*d[i]-D*h[i];
  double n = b/a;
    maxi=max(maxi,n);
  }

  cout << maxi<<endl;

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint

#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)

namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace

::std::map<::std::int64_t, ::std::int32_t> primeFactors(::std::int64_t x) {
  ::std::map<::std::int64_t, ::std::int32_t> res;
  for (::std::int64_t i = 2; i*i <= x; ++i) {
    if (x % i == 0) {
      while (x % i == 0) x /= i, res[i]++;
    }
  }
  if (x != 1) res[x]++;
  return res;
}

bool valid(const vector<int64>& v) {
  int64 g = v[0];
  REP(i, v.size()) {
    if (v[i] > 10000) return false;
    g = __gcd(g, v[i]);
  }
  if (g != 1) return false;
  REP(i, v.size()) {
    FOR(j, i + 1, v.size()) {
      if (__gcd(v[i], v[j]) == 1) {
        return false;
      }
    }
  }
  return true;
}

void solve(int64 N) {
  vector<int64> res(N);
  int64 now = 2;
//	set<int64> st;
  REP(i, N - 1) {
    while (__builtin_popcount(now) == 1 ||
           (now % 3 != 0 && now % 5 != 0 && now % 7 != 0 && now % 11 != 0)) now += 2;
    res[i] = now;
    now += 2;
  }
  res.back() = 3 * 5 * 7 * 11;
  int64 g = res[0];
  assert(valid(res));
  REP(i, N) {
    cout << res[i] << " ";
  }
  cout << endl;
}

void check() {
  for (int64 i = 3; i <= 2500; i += 100) {
    solve(i);
  }
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	solve(N);
}

#include<bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long int ll;
#define all(x) (x).begin(),(x).end()
#define print(x) if(x)cout<<"YES\n";else cout<<"NO\n";
#define f(i,x,y) for(ll i=x;i<=y;i++)
#define rf(i,x,y) for(ll i=x;i>=y;i--)
#define pb push_back
#define F first
#define S second
#define mod 1e9
#define N 1000001
void solve()
{
}

int main()
{

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  speed;
  string s;
  cin>>s;
  vector<char>v;
  for(auto x:s)
    v.pb(x);
  for(int i=v.size()-1;i>=0;i--)
  {
    if(v[i]=='0')
      v.pop_back();
    else
    {
      break;
    }
  }
  string a;
  for(auto x:v)
    a+=x;
  string b=a;
  reverse(b.begin(),b.end());
  if(a==b)
    cout<<"Yes";
  else
    cout<<"No";
 }


// Containers
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F
#define all(v) v.begin(), v.end()
#define f first
#define s second
#define MOD 1000000007
#define vt(T) vector<T>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORUP(i, a, b) for (int i = a; i < b; i++)
#define FORDOWN(i, a, b) for (int i = a; i > b; --i)
#define EACH(e, C) for (auto &e : C)
#define len(v) (int)v.size()
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>
#define US unordered_set
#define UM unordered_map

typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef vector<pii> vpii;

template <class T> bool in(const T e, unordered_set<T> s) {
  return s.count(e) > 0;
}
template <class T> bool in(const T e, set<T> s) { return s.count(e) > 0; }
template <class K, class V> bool in(const K e, unordered_map<K, V> s) {
  return s.count(e) > 0;
}
template <class K, class V> bool in(const K e, map<K, V> s) {
  return s.count(e) > 0;
}
template <class T> void print(T t) { cout << t << endl; }
int dirs[5] = {-1, 0, 1, 0, -1};

// fast IO
static auto __2333__ = []() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return 0;
}();
// --------------------------------------------------------

int main() {
  int N;
  cin >> N;
  vt(pii) ps;
  FOR(i, N) {
    int x, y;
    cin >> x >> y;
    ps.pb(mp(x, y));
  }
  sort(all(ps));
  FOR(i, N) FORUP(j, i + 1, N) FORUP(k, j + 1, N) {
    int a = ps[i].f, b = ps[i].s, c = ps[j].f, d = ps[j].s, e = ps[k].f,
        f = ps[k].s;
    if (a == c && c == e) {
      print("Yes");
      return 0;
    };
    if (b == d && b == f) {
      print("Yes");
      return 0;
    };
    if (a == c || c == e)
      continue;
    if (b == d || b == f)
      continue;
    if ((d - b) * (e - a) == (f - b) * (c - a)) {
      print("Yes");
      return 0;
    }
  }
  print("No");
}

//NAME-DEEPESH BHATT
//Institute-IIT Dhanbad
//MOTTO-THINK FIRST,CODE LATER

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 998244353  ;
/*#define endl '\n'*/

//Check for signed int overflow
// use __builtin_popcountll(num) to calculate no.of setbits in num
//__builtin_clz() -> leading zeroes
//bitset<365>->bin no. with 365 bits avail.
// cout<<bitset<8>(x) prints x after converting it into bits
//s.lower_bound() works in O(logn) whereas lower_bound(s.begin(),s.end(),x) works in O(n)

//Euclid's Algo
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
//Extended Euclid's Algo
ll gcd_ex(ll a,ll b,ll&x,ll&y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll g=gcd_ex(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}
//Multiplicative Modulo Inv
ll multi_mod_inv(ll a,ll m){
    ll x,y;
    ll g=gcd_ex(a,m,x,y);
    if(g!=1){
        return -1;
    }
    x=(x%m+m)%m;
    return x;
}
//Mod division
ll mod_div(ll a,ll b,ll m){
    //(a/b)mod m?
    if(multi_mod_inv(b,m)!=-1){
        return (a%m*multi_mod_inv(b,m)%m)%m;
    }
    else{
        return -1;
    }
}
//lcm
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
//Binary Exponentiation
ll power(ll a,ll n){
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p)%MOD;
    if (n % 2)
        return (p * a)%MOD;
    else
        return p%MOD;
}
/*//Euler Totient Function
ll phi[1000001]={0};
void euler_totient(ll n){
    for(ll i=0;i<=n;i++){
        phi[i]=i;
    }
    phi[1]=1;
    for(ll i=2;i<=n;i++){
        if(i==phi[i]){
            phi[i]=i-1;//For a prime number phi(p)=p-1
            for(ll j=2*i;j<=n;j+=i){
                phi[j]=phi[j]*(i-1)/i;
            }
        }
    }
}*/

/*void sieve(vector<ll>&is_prime){
    is_prime[0]=is_prime[1]=0;
    for(ll i=2;i*i<=100000;i++){
        if(is_prime[i]){
            for(ll j=i*i;j<=100000;j+=i){
                is_prime[j]=0;
            }
        }
    }
}*/
int32_t main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(nullptr);
    ll test=1;
    /*cin>>test;*/
    while(test--){
        string s;
        cin>>s;
        bool flag=true;
        for(ll i=0;i<s.length();i++){
            if(i%2==0){
                if(s[i]>='a'&&s[i]<='z'){
                    continue;
                }
                else{
                    flag=false;
                }
            }
            else{
                if(s[i]>='A'&&s[i]<='Z'){
                    continue;
                }
                else{
                    flag=false;
                }
            }
        }
        if(flag){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=205;
int n,a[N],b[N],len[N];
bool pd[N],vis[N],in[N],out[N];
signed main(){
	memset(len,-1,sizeof(len));
	rd(n);
	auto pusha=[&](int i){
		if(a[i]!=-1){
			if(pd[a[i]]){
				puts("No");
				exit(0);
			}
			pd[a[i]]=1;
		}
	};
	auto pushb=[&](int i){
		if(b[i]!=-1){
			if(pd[b[i]]){
				puts("No");
				exit(0);
			}
			pd[b[i]]=1;
		}
	};
	auto paint=[&](int i){
		rep(j,a[i],b[i]){
			if(len[j]!=-1&&len[j]!=b[i]-a[i]-1){
				puts("No");
				exit(0);
			}
			len[j]=b[i]-a[i]-1;
		}
	};
	rep(i,1,n){
		rd(a[i]),rd(b[i]);
		if((a[i]!=-1&&b[i]!=-1&&a[i]>=b[i])||a[i]==n*2||b[i]==1){
			puts("No");
			exit(0);
		}
		if(a[i]!=-1&&b[i]!=-1)paint(i);
		pusha(i),pushb(i);
	}
	bool flag=1;
	while(flag){
		flag=0;
		rep(i,1,n){
			if(a[i]==-1&&b[i]!=-1&&len[b[i]]!=-1){
				a[i]=b[i]-len[b[i]]-1;
				pusha(i);
				paint(i);
				flag=1;
				break;
			}
			if(b[i]==-1&&a[i]!=-1&&len[a[i]]!=-1){
				b[i]=a[i]+len[a[i]]+1;
				pushb(i);
				paint(i);
				flag=1;
				break;
			}
		}
		break;
	}
	rep(i,1,n){
		if(a[i]!=-1&&b[i]!=-1){
			vis[a[i]]=1;
			vis[b[i]]=1;
		}
		if(a[i]!=-1&&b[i]==-1){
			in[a[i]]=1;
		}
		if(a[i]==-1&&b[i]!=-1){
			out[b[i]]=1;
		}
	}
	int l=0,r=0;
	rep(i,1,n){
		if(pd[i]){
			if(l>0||r<0){
				puts("No");
				exit(0);
			}
			l=r=0;
		}else{
			if(in[i]){
				++l,++r;
			}else if(out[i]){
				--l,--r;
				if(r<0){
					puts("No");
					exit(0);
				}
			}else{
				--l,++r;
			}
		}
	}
	puts("Yes");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int N=205;
int vis[N];//-2表示前面有人,-1表示后面有人.
bool f[N];
int main()
{
    int n;
    scanf("%d",&n);
    bool flag=1;
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if (a>0&&vis[a]) flag=0;
        if (b>0&&vis[b]) flag=0;
        if(a!=-1&&b!=-1)
        {
            vis[a]=b;//假如这个点有权值记录这个点关联的权值在哪.
            vis[b]=a;
        }
        else if(a==-1&&b==-1)
        {
            continue;//假如两个都是不确定的就意味着可以随便填.
        }
        else if(a==-1)
        {
            vis[b]=-2;//假如是b是确定的,a是不确定的,那么我们标记下,b前面有数.
        }
        else
        {
            vis[a]=-1;//假如是a是确定的,b是不确定的,那么我们标记下,a后面有数.
        }
    }
    if (!flag) {printf("No"); return 0;}
    f[0]=true;
    for(int i=1;i<=2*n-1;i++)//枚举起点.
    {
        if(!f[i-1]) continue;
        for(int len=1;i+2*len-1<=2*n;len++)//枚举长度.
        {
            int t=1;//都合法才算合法.
            for(int j=i;j<=i+len-1;j++)//检测区间是否合法.
            {
                if(vis[j]>0)
                {
                    if(vis[j]-j==len&&vis[j+len]-j-len==-len)   continue;
                    else                t=0;
                }
                else if(vis[j]==-2) {  t=0; }//它前面有数必不能成为答案.
                else if(vis[j]==-1)
                {
                    if(vis[j+len]!=0)   t=0;//假如是已经确定/都是后面有数也不能成为答案.
                    else        continue;
                }
                else
                {
                    if(vis[j+len]>0||vis[j+len]==-1)   t=0;//假如是已经确定/都是后面有数也不能成为答案.
                    else        continue;
                }
            }
            if(t)   f[i+2*len-1]=t;
        }
    }
    f[2*n]==1?puts("Yes"):puts("No");
    return 0;
}


#include <bits/stdc++.h>

#define _GLIBCXX_DEBUG

using namespace std;

using ll = long long;
using ld = long double;
const int INF = (INT_MAX >> 1);
const ll LLINF = (LLONG_MAX >> 1);
#define all(x) x.begin(), x.end()

#define rep(i, s, e) for(ll i = s; i < e; ++i)
#define repr(i, s, e) for(ll i = s; i > e; --i)

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

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

    ll a, b, w; cin >> a >> b >> w;
    w *= 1000;
    ll cnt_min = LLINF, cnt_max = -LLINF;

    rep(cnt, 1, a * w + 1){
        if (a * cnt <= w && w <= b * cnt){
            chmax(cnt_max, cnt);
            chmin(cnt_min, cnt);
        }
    }

    if (cnt_max == -LLINF && cnt_min == LLINF) cout << "UNSATISFIABLE" << endl;
    else cout << cnt_min << " " << cnt_max << endl;

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sull(x) scanf("%llu",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf
#define clean fflush(stdout)

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};
///ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; /// 8 Direction
///ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; /// Knight Direction

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

ll bigmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=bigmod(a,b/2)%mod;
    x=(x*x)%mod;
    if(b%2)x=(x*a)%mod;
    return x;
}

ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
        ...ENDING OF TEMPLATE...
*/

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    /** Use "long double"(%Lf) instead of double for precision safety*/
    ll tst,a,b,c,k,n,d,m,res=0,ans=0,t=0;
    sl(a),sl(b),sl(n);
    res=-1,ans=-1;
    n*=1000;
    ll ok=0;
    for(ll k=a;k<=b;k++){
            if(ok)
                break;
            c=n/k;
            for(ll i=c;i>=0;i--)
            {
                m=n-i*k;
                vl v;
                for(ll j=1;j*j<=m;j++)
                {
                    if(m%j==0)
                    {
                        v.pb(j);
                        if(j==m/j)
                            continue;
                        v.pb(m/j);
                    }
                }
                d=inf;
                for(auto j:v)
                {
                    if(j>=a and j<=b)
                    {
                        d=min(d,j);
                    }
                }
                if(d!=inf)
                {
                    ok=1;
                    res=i+(m/d);
                    break;
                }
            }
    }

    if(res==-1)
    {
        cout<<"UNSATISFIABLE"<<endl;
        return 0;
    }

    ok=0;
    for(ll k=b;k>=a;k--){
            if(ok)
                break;
            c=n/k;
            for(ll i=c;i>=0;i--)
            {
                m=n-i*k;
                vl v;
                for(ll j=1;j*j<=m;j++)
                {
                    if(m%j==0)
                    {
                        v.pb(j);
                        if(j==m/j)
                            continue;
                        v.pb(m/j);
                    }
                }
                d=-inf;
                for(auto j:v)
                {
                    if(j>=a and j<=b)
                    {
                        d=max(d,j);
                    }
                }
                if(d!=-inf)
                {
                    ok=1;
                    ans=i+(m/d);
                    break;
                }
            }

    }

//    else
//    {
        swap(res,ans);
        cout<<res<<" "<<ans<<endl;
//    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

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

int main(void)
{
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);

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

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

    for (int i = 0; i < q; i++)
    {
        ll k;
        cin >> k;

        ll l = -1, r = INF;

        while (r - l > 1)
        {
            ll mid = (r + l) / 2;

            auto x = lower_bound(a.begin(), a.end(), mid) - a.begin();

            x = mid - x;

            if (x > k)
            {
                r = mid;
            }
            else
            {
                l = mid;
            }
        }

        cout << l << endl;
    }
}

#include <bits/stdc++.h>
#define MAXN 500005
#define ll long long
#define F first
#define S second
#define MOD 1000000007
#define ll long long

using namespace std;

int n, q;
ll a[MAXN], b[MAXN];

void solve()
{
    cin >> n >> q;
    for(int i = 1; i <= n; ++i) cin >> a[i], b[i] = a[i] - i;
    for(int i = 1; i <= q; ++i)
    {
        ll x;

        cin >> x;

        int pos = lower_bound(b + 1, b + n + 1, x) - b;

        if(pos == n + 1)
        {
            cout << a[n] + (x - b[n]) << '\n';
        }
        else
        {
            cout << a[pos] - (b[pos] - x + 1) << '\n';
        }

    }
}

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie();
    cout.tie();
    if(fopen(".inp", "r"))
    {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    int t;
    t = 1;
    //cin >> t;
    while(t--)
    {
        //cerr << t << '\n';
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define PI pair<int,int>
using namespace std;
const int maxm=2e5+5;
const int mod=1e9+7;
int d[maxm][17][2];
char s[maxm];
int n,k;
int dfs(int len,int st,bool limit,bool pre){
    int cnt=__builtin_popcount(st);
    if(!len)return cnt==k;
    if(d[len][cnt][limit]!=-1)return d[len][cnt][limit];
    int ans=0;
    int ma=(limit?s[len]:15);
    for(int i=0;i<=ma;i++){
        int stt=st;
        if(!pre||i!=0)stt|=(1<<i);
        ans=(ans+dfs(len-1,stt,limit&&i==ma,pre&&i==0))%mod;
    }
    return d[len][cnt][limit]=ans;
}
int solve(){
    return dfs(n,0,1,1);
}
signed main(){
    ios::sync_with_stdio(0);
    //
    memset(d,-1,sizeof d);
    //
    cin>>(s+1)>>k;
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        if(isdigit(s[i]))s[i]=s[i]-'0';
        else s[i]=s[i]-'A'+10;
    }
    reverse(s+1,s+1+n);
    int ans=solve();
    cout<<ans<<endl;
    return 0;
}
/*

*/

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

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  int r = r2 - r1, c = c2 - c1;
  int ans = 3;
  if (!r && !c)
    ans = 0;
  else if (r == c || r == -c || abs(r) + abs(c) <= 3)
    ans = 1;
  else if ((r ^ c ^ 1) & 1 || abs(r + c) <= 3 || abs(r - c) <= 3 ||
           abs(r) + abs(c) <= 6)
    ans = 2;
  cout << ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <cmath>
#include <map>

using ll=long long;
using namespace std;

int main(){
    int N;
    cin>>N;
    N*=2;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    vector<ll> B = A;
    sort(B.begin(), B.end());

    map<ll,int> cnt;
    for(int i=0;i<N/2;i++){
        cnt[B[i]]++;
    }

    vector<int> col(N,0);
    for(int i=0;i<N;i++){
        if(cnt[A[i]] > 0){
            col[i] = 1;
            cnt[A[i]]--;
        }
    }

    vector<int> ans(N,-1);
    vector<int> st;
    st.push_back(-1);
    for(int i=0;i<N;i++){
        if(*st.rbegin() == -1){
            ans[i] = 0;
            st.push_back(col[i]);
        }else if(*st.rbegin() == col[i]){
            ans[i] = 0;
            st.push_back(col[i]);
        }else{
            ans[i] = 1;
            st.pop_back();
        }
    }

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

    return 0;
}

#include <bits/stdc++.h>

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 5e5;
bool d[nsz + 5];
char s[nsz + 5];
int n, a[nsz + 5];
pair<int, int> b[nsz + 5];
num ans;

inline void init() {
	cont (i, n) b[i] = make_pair(a[i], i);
	sort(b + 1, b + n + 1);
	cont (i, n / 2) {
		d[b[i].second] = 1;
	}
}

inline void solve() {
	static int stk[nsz + 5];
	int ss = 0;
	cont (i, n) {
		if (d[i]) {
			if (ss && stk[ss] > 0) {
				s[+stk[ss]] = '(', s[i] = ')';
				--ss;
			} else stk[++ss] = -i;
		} else {
			if (ss && stk[ss] < 0) {
				s[-stk[ss]] = '(', s[i] = ')';
				--ss;
			} else stk[++ss] = +i;
		}
	}
}

int main() {
	scanf("%d", &n), n *= 2;
	cont (i, n) scanf("%d", &a[i]);
	init();
	solve();
	printf("%s\n", s + 1);
}


#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}

//union find
vector<vector<int>> g;
const int N = 200001;
int col[N];

int uf(int pid){
  if (col[pid]==pid){
    return pid;
  }else{
    col[pid]=uf(col[pid]);
    return col[pid];
  }
}

ll n,m,k;
int main() {

  ll ans=0;
  cin >> n >> m;

  vi a(n),b(n),va(n);
  REP(i,n) cin>>a[i];
  REP(i,n) cin>>b[i];
  //REP(i,m) cin>>c[i]>>d[i];

  for(ll i=0;i<N;i++){
    col[i]=i;
  }

  g.resize(n);
  //g2.resize(n);
  for(int i = 0; i < m; i++) {
    int c, d;
    cin >> c >> d ;
    c--; d--;
    if (c>d){
      int tmp=d;
      d=c;
      c=tmp;
    }
    g[c].emplace_back(d);
    g[d].emplace_back(c);

    if ( uf(c)<uf(d) ){
      col[uf(d)]=uf(c);
    }else{
      col[uf(c)]=uf(d);
    }
  }

  for(ll i=n-1;i>=0;i--){
    if (col[i]!=i){
      col[i]=uf(i);
    }
  }

  for(ll i=0;i<n;i++){
    va[col[i]]+=a[i]-b[i];
  }

  int flag=1;
  for(ll i=0;i<n;i++){
    if (va[i]!=0)flag=0;
  }

  if (flag==0){
    cout<<"No"<<endl;
    return 0;
  }else{
    cout<<"Yes"<<endl;
    return 0;
  }

}

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

#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

int main() {
    int n,m;
    ll suma=0,sumb=0;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> diffab(n);
    vector<int> root(n);
    vector<int> c(m);
    vector<int> d(m);
    UnionFind uf(n);
    rep(i,n){
        cin >> a[i];
        suma += a[i];
    }
    rep(i,n){
        cin >> b[i];
        sumb += b[i];
        diffab[i]=b[i]-a[i];
    }
    rep(i,m){
        cin >> c[i] >> d[i];
        int cc=c[i]-1;
        int dd=d[i]-1;
        uf.unite(cc,dd);
    }
    if(suma!=sumb){
        cout << "No" << endl;
        return 0;
    }
    rep(i,n){
        if(diffab[i]!=0){
            root[uf.root(i)]+=diffab[i];
        }
    }
    rep(i,n){

        if(root[i]!=0){
           cout << "No" << endl;
           return 0;
        };

    }
    cout << "Yes" << endl;

}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <vector>

#pragma region macros
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, n, 0)
#define _rrange(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)
#define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__)
#pragma endregion macros

using namespace std;

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

using ll    = long long;
using R     = long double;
const R EPS = 1e-9L;  // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R &r) {
    return (r > EPS) - (r < -EPS);
}
inline R sq(R x) {
    return sqrt(max(x, 0.0L));
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void) {
    ll k, n, m;
    cin >> k >> n >> m;
    vector<ll> a(k);

    rep(i, k) {
        cin >> a[i];
    }

    vector<ll> b(k);
    rep(i, k) {
        b[i] = 1LL * a[i] * m / n;
    }

    ll rest = m;
    rep(i, k) {
        rest -= b[i];
    }

    vector<ll> zero(k);
    vector<ll> one(k);

    rep(i, k) {
        zero[i] = abs(b[i] * n - a[i] * m);
        one[i]  = abs((b[i] + 1) * n - a[i] * m);
    }

    ll low = 0LL, high = n + 1;
    while (high - low > 1) {
        const ll mid = (low + high) / 2LL;
        int f = 0, t = 0;
        bool ok = true;
        rep(i, k) {
            if (zero[i] <= mid and one[i] <= mid) {
                f += 0, t += 1;
            } else if (zero[i] <= mid) {
                f += 0, t += 0;
            } else if (one[i] <= mid) {
                f += 1, t += 1;
            } else {
                ok = false;
            }
        }

        if (ok and f <= rest and rest <= t) {
            high = mid;
        } else {
            low = mid;
        }
    }

    const ll thr = high;
    rep(i, k) {
        if (zero[i] > thr and one[i] <= thr) {
            b[i]++, rest--;
        }
    }

    rep(i, k) {
        if (rest > 0) {
            if (zero[i] <= thr and one[i] <= thr) {
                b[i]++, rest--;
            }
        }
    }

    rep(i, k) {
        cout << (i ? " " : "") << b[i];
    }
    cout << endl;

    return 0;
}

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

#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <bitset>
#include <fstream>

#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

//using namespace __gnu_pbds;
//using namespace atcoder;
using namespace std;

const ll modd = (1000LL * 1000LL * 1000LL + 7LL);
//const ll modd = 998244353;

int main(int argc, char *argv[])   {

    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

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

    cout.precision(12);

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<ll> a;
        ll summ = 0;
        forr(i,0,2*n) {
            readint(aa); a.push_back(aa);
            summ += aa;
        }
        priority_queue<ll> todo;
        ll comp = 0;
        forr(i,0,n) {
            todo.push(-a[n+i]);
            todo.push(-a[n-i-1]);
            comp += todo.top();
            todo.pop();
        }
        cout << summ+comp << endl;
    }

    return 0;
}


#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <list>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
void ex_gcd(ll a,ll b, ll& d,ll& x,ll& y){
  if(!b) {d=a;x=1;y=0;}
  else   {	ex_gcd(b,a%b,d,y,x);	y-=a/b*x;}
}
ll inv(ll a,ll n)  {
  ll d,x,y;	ex_gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}
ll gcd(ll x, ll y){
  if(y==0)return x;
  return gcd(y, x%y);
}
const int maxn = 100005;
const int mod = 998244353;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll x;
  cin>>x;
  set<ll>st;
  for(int i=2;i*(ll)i<=x;i++){
    ll cur = i;
    for(;cur*i<=x;){
      cur*=i;
      st.insert(cur);
    }
  }
  cout<<x-st.size()<<endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long int64;

int main()
{
    int64 n;
    set<int64> S;
    cin >> n;
    int64 j=0;
    for(int64 i=2;i<=100000;i++)
    {
        //printf("%lld\n",i);
        j = i;
        while(j<=10000000000)
        {
            j*=i;
            //printf("%lld\n",j);
            if(j<=10000000000)S.insert(j);
        }
    }
    /*
    for(int64 x:S)
    {
        cout << x << " ";
    }*/
    auto iter = upper_bound(S.begin(), S.end(), n);
    int idx = distance(S.begin(), iter);
    if(n<=3)cout << n;
    else cout << n-idx;
    //cout << lower_bound(S.begin(),S.end(),n);
}


#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int log3(lli N){

  int a=-1;
  while(N>0){
  a++;
    N/=3;

  }
  return a;

}int log5(lli N){

  int a=-1;
  while(N>0){
  a++;
    N/=5;

  }
  return a;

}

int main() {
  lli N;
  cin >> N;
  int three, five;
  three=log3(N)+1;
  five=log5(N)+1;
  lli a=1, b=1;

  rep(i, three){
    a*=3;
  rep(j, five){
  b*=5;
  if(a+b==N){
  cout << i+1 <<" "<<j+1 << endl;
    return 0;
  }
  }
  b=1;

  }
  cout << -1 << endl;
}

#include<iostream>
#include<stack>
using namespace std;
const int maxsize = 1e5 + 5;
long long l3[maxsize];
long long l5[maxsize];
int main() {
	long long n;
	long long x = 1;
	long long i = 0,j = 0;
	cin >> n;
	while (x < n) {
		x *= 3;
		l3[++i] = x;
	}
	x = 1;
	while (x < n) {
		x *= 5;
		l5[++j] = x;
	}
	for (int m = 1; m <= i; m++) {
		for (int k = 1; k <= j; k++) {
			if (l3[m] + l5[k] == n) {
				cout << m << " " << k;
				return 0;
			}
			else if (l3[m] + l5[k] > n)
				break;
		}
	}
	cout << "-1";
	return 0;
}


#include "bits/stdc++.h"

using namespace std;
using namespace std::chrono;

using ll = long long;
using str = string;
using db = double;

#define tcT template <class T
#define tcTU tcT, class U

tcT> using V = vector<T>;
tcT> using VV = V<V<T>>;
tcTU> using PR = pair<T, U>;
tcT> using PQ = priority_queue<T>;

#define pf push_front
#define pb push_back
#define ef emplace_front
#define eb emplace_back

#define rsz resize
#define ist insert
#define ers erase
#define cnt count

#define ppf pop_front()
#define ppb pop_back()
#define ft front()
#define bk back()
#define bg begin()
#define ed end()
#define ety empty()
#define fs first
#define sd second

#define brk break
#define ctn continue
#define rtn return

#define sz(v) int((v).size())
#define all(v) (v).bg, (v).ed
#define srt(v) sort(all(v))
#define rev(v) reverse(all(v))
#define unq(v) unique(all(v))

#define ice(i, a, b) for (auto (i) = (a); (i) < (b); ++(i))
#define fire(i, a, b) for (auto (i) = (b) - 1; (i) >= (a); --(i))
#define dark(a, v) for (auto& (a) : (v))

const int MOD[] = {int(1e9 + 7), 998244353};
const ll MAX[] = {200005, (ll)1e18};

const int DX[] = {+1, 0, -1, 0, +1, -1, -1, +1};
const int DY[] = {0, +1, 0, -1, +1, +1, -1, -1};
// D --> R --> U --> L --> DR --> UR --> UL --> DL

constexpr int pct(int a) { rtn __builtin_popcount(a); }
constexpr int bts(int a) { rtn (a ? 31 - __builtin_clz(a) : 0); }
constexpr int mx2(int a) { rtn bts(a); }
constexpr int mn2(int a) { rtn bts(a) + ((a & (a - 1)) > 0); }

constexpr ll pct(ll a) { rtn __builtin_popcountll(a); }
constexpr ll bts(ll a) { rtn (a ? 63 - __builtin_clzll(a) : 0); }
constexpr ll mx2(ll a) { rtn bts(a); }
constexpr ll mn2(ll a) { rtn bts(a) + ((a & (a - 1)) > 0); }
constexpr ll pw2(ll a) { rtn 1LL << a; }

tcT> bool setMin(T& a, const T& b) { rtn (a > b ? a = b, 1 : 0); }
tcT> bool setMax(T& a, const T& b) { rtn (a < b ? a = b, 1 : 0); }

tcT> T fDiv(const T& a, const T& b) { rtn a / b - ((a ^ b) < 0 && (a % b)); }
tcT> T cDiv(const T& a, const T& b) { rtn a / b + ((a ^ b) > 0 && (a % b)); }

tcT> int lwb(const V<T>& v, const T& a) { rtn int(lower_bound(all(v), a) - v.bg); }
tcT> int upb(const V<T>& v, const T& a) { rtn int(upper_bound(all(v), a) - v.bg); }

tcTU> T binSearch(T a, const T& jump, const U& f) { for (T x = jump; x; x /= 2) while (f(a + x)) a += x; rtn a; }

tcT> void squish(V<T>& v) { v.ers(unq(v), v.ed); }

void space(int sp) { if (sp) cout << ' '; }
void line(int ln) { if (ln) cout << '\n'; }
tcT> void show(T var, int gd = 0, int sp = 1, int ln = 0) { cout << var; space(sp); line(ln);}
tcTU> void show(PR<T, U> p, int gd = 0, int sp = 1, int ln = 0) { cout << '{' << p.fs << ", " << p.sd << '}'; space(sp); line(ln); }
tcT> void show(V<T> v, int gd = 0, int sp = 1, int ln = 0) { dark(a, v) show(a, 0, sp, ln); line(1 - gd); }

VV<int> adj(200005);
V<bool> vis(200005);
int num;

void dfs(int cur) {
  if (vis[cur]) {
    rtn;
  }
  vis[cur] = true;
  ++num;
  dark (nxt, adj[cur]) {
    dfs(nxt);
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(17);
  ofstream outfile;
  outfile.open("../test_output.txt");
  int tc = 1;
  // cin >> tc;
  ice (test, 1, tc + 1) {
    int n;
    cin >> n;
    // ^
    auto hajime = high_resolution_clock::now();
    /* */
    V<int> v(n);
    dark (a, v) {
      cin >> a;
    }
    ice (i, 0, n / 2) {
      if (v[i] != v[(n - 1) - i]) {
        adj[v[i]].pb(v[(n - 1) - i]);
        adj[v[(n - 1) - i]].pb(v[i]);
      }
    }
    int ans = 0;
    ice (i, 0, 200005) {
      if (!vis[i]) {
        num = 0;
        dfs(i);
        ans += (num - 1);
      }
    }
    cout << ans;
    // ^
    auto finish = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(finish - hajime);
    outfile << "test " << test << ": " << duration.cnt() << " ms\n";
  }
  outfile.close();
}

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

int exchange(int i,map<int,int> &dic){
  if(dic.find(i) == dic.end()) return i;
  else {
    dic[i] = exchange(dic[i],dic);
    return dic[i];
  }
}

template <typename T,typename S> void print_map(map<T,S> &a){
  for(auto& i:a){
    cout << i.first << " * " << i.second << endl;
  }
}

int main(){

  int n;
  cin >> n;
  vector<int> a(n);
  for(auto& i : a) cin >> i;

  map<int,int> dic;

  int ans =0;
  for(int i=0; i<n/2; ++i) {
    if(exchange(a[i],dic)==exchange(a[n-i-1],dic)) continue;
    else{
      ans ++;
      dic[exchange(a[i],dic)] = exchange(a[n-1-i],dic);
    }
    //print_map(dic);
    //cout << "--------------" << endl;
  }

  cout << ans << endl;

}


#include<bits/stdc++.h>
using namespace std;
int a[65540];
int main(){
	int n,i;
	cin>>n;
	int maxn=-100,maxn1=-100,temp,temp1;
	for(i=1;i<=pow(2,n);i++){
		cin>>a[i];
		if(i<=pow(2,n)/2){
			if(a[i]>maxn){
				temp=i;
				maxn=a[i];
			}
		}
		else{
			if(a[i]>maxn1){
				temp1=i;
				maxn1=a[i];
			}
		}
	}
	if(maxn>maxn1)cout<<temp1<<endl;
	else cout<<temp<<endl;
	return 0;
}

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

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

    vector<pair<ll,ll>> v, v1;

    ll po=1;

    for(ll i=1; i<n; i++){
        po*=2;
    }

    for(ll i=1; i<=po; i++){
        int a;
        cin>>a;
        v.push_back({a,i});
    }

    for(ll i=1; i<=po; i++){
        int a;
        cin>>a;
        v1.push_back({a,i+po});
    }

    sort(v.rbegin(), v.rend());
    sort(v1.rbegin(), v1.rend());

    if(v[0].first > v1[0].first){
        cout<<v1[0].second;
    }
    else{
        cout<<v[0].second;
    }

}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, l;
    cin >> n >> l;
    vec<ll> a(n), b(n);
    REP(i, n) {
        cin >> a[i];
    }
    REP(i, n) {
        cin >> b[i];
    }

    vec<ll> can(n, false);

    map<ll, ll> mp;
    mp[1] = -1; //ai-i=0-(-1)=1
    ll ans = 0;
    REP(i, n) {
        if(a[i] < b[i]) {
            mp.clear();
            mp[a[i] - i] = i;
            continue;
        }
        if(a[i] == b[i]) {
            can[i] = true;
            mp.clear();
            mp[a[i] - i] = i;
        } else if(i > 0 and b[i - 1] + 1 == b[i]) {
            can[i] = true;
            ans++;
            mp[a[i] - i] = i;
        } else if(mp.count(b[i] - i)) {
            can[i] = true;
            ans += i - mp[b[i] - i];
            mp[a[i] - i] = i;
        }
    }
    mp.clear();
    mp[l + 1 - n] = n; //l+1-n
    REP2(i, n) {
        if(can[i]) {
            //cout << "can" << i << en;
            mp.clear();
            mp[a[i] - i] = i;
            continue;
        }

        if(i + 1 < n and b[i + 1] - 1 == b[i]) {
            can[i] = true;
            ans++;
            mp[a[i] - i] = i;
        } else if(mp.count(b[i] - i)) {
            can[i] = true;
            ans += mp[b[i] - i] - i;
            mp[a[i] - i] = i;
        } else {
            //cout << i << " " << b[i] - i << en;
            cout << -1 << en;
            return;
        }
        //cout << a[i] - i << en;
    }
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}

#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int N=200005;
int n,l,a[N],b[N],goal[N],p[N];
ll ans;
vector<int> vec;
map<int,vector<int>> mp;
void mandown(){
	puts("-1");
	exit(0);
}
ll solve(int l,int r){
	if(l+1==r){
		return 0;
	}
	ll res=0;
	int mid=l,pos;
	while(mid+1<r&&b[mid+1]<a[mid+1]){
		mid++;
	}
	for(int i=mid,j=i;i>l;i--,j=min(j,i)){
		vector<int> &tmp=mp[b[i]-i];
		if(tmp.size()==0){
			mandown();
		}
		auto it=lower_bound(tmp.begin(),tmp.end(),j);
		it--;
		if(*it<l){
			mandown();
		}
		goal[i]=*it;
		j=min(j,*it+1);
	}
	for(int i=mid+1,j=i;i<r;i++,j=max(j,i)){
		vector<int> &tmp=mp[b[i]-i];
		auto it=upper_bound(tmp.begin(),tmp.end(),j);
		if(it==tmp.end()||*it>r){
			mandown();
		}
		goal[i]=*it;
		j=max(j,*it-1);
	}
	for(int i=l;i<=r;i++){
		p[i]=1;
	}
	pos=mid;
	for(int i=mid;i>l;i--){
		if(pos!=goal[i]){
			res+=p[pos]+pos-goal[i]-1;
			p[goal[i]]+=p[pos]+pos-goal[i]-2;
			pos=goal[i];
		}else{
			p[pos]--;
		}
	}
	pos=mid+1;
	for(int i=mid+1;i<r;i++){
		if(pos!=goal[i]){
			res+=p[pos]+goal[i]-pos-1;
			p[goal[i]]+=p[pos]+goal[i]-pos-2;
			pos=goal[i];
		}else{
			p[pos]--;
		}
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&l);
	n+=2;
	a[1]=b[1]=0;
	a[n]=b[n]=l+1;
	for(int i=2;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=2;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++){
		if(a[i]==b[i]){
			vec.push_back(i);
		}
		mp[a[i]-i].push_back(i);
	}
	for(int i=0;i<(int)vec.size()-1;i++){
		ans+=solve(vec[i],vec[i+1]);
	}
	printf("%lld\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprrev(i, a, b) for (int i = b - 1; i >= a; i--) // [a, b)
#define reprev(i, n) reprrev(i, 0, n)
using ll = long long;
using ull = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
const ll mod = 1e9 + 7;

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

int getl(int i, int N) { return i == 0 ? N - 1 : i - 1; };
int getr(int i, int N) { return i == N - 1 ? 0 : i + 1; };
long long GCD(long long a, long long b)
{
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
using namespace std;

int main() {
  int n; cin >> n;
  ll sum = 0, sum_squ = 0;
  rep(i, n) {
    ll a; cin >> a;
    sum += a;
    a *= a;
    sum_squ += a;
  }
  ll res = n*sum_squ - sum*sum;
  cout << res << endl;
}

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

#define dbg(x)      cout << #x << " is " << x << endl
#define all(x)      x.begin(), x.end()
#define pb          push_back
#define sz(x)       (int)(x.size())
#define ll          long long
#define fi          first
#define se          second

const int MOD = 1e9 + 7;
const double eps = 1e-10;
const long long INF = 1e18;
const int N = 2e5 + 10;

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	ll ans = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		sum += v[i];
		ans += v[i] * v[i];
	}

	ans *= n;
	ans -= (sum * sum);
	cout << ans;
}

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

	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long i64;

const int MAX_N = 200000 + 5;
const int A = 1e8;

int n[2], N, Q;
int a[2][MAX_N];
i64 ans;

int Root[2], total_node;
struct SegmentNode {
    i64 cnt, sum;
    int ls, rs;
} node[MAX_N * 50];

inline void segment_update(int i) {
    node[i].cnt = node[node[i].ls].cnt + node[node[i].rs].cnt;
    node[i].sum = node[node[i].ls].sum + node[node[i].rs].sum;
}
void segment_modify(int &i, int l, int r, int mp, int mv) {
    i = i ? i : ++ total_node;
    if (l == r) {
        node[i].cnt += mv;
        node[i].sum += 1ll * mv * l;
        return;
    }
    int mid = l + r >> 1;
    if (mp <= mid) {
        segment_modify(node[i].ls, l, mid, mp, mv);
    } else {
        segment_modify(node[i].rs, mid + 1, r, mp, mv);
    }
    segment_update(i);
}
i64 qcnt, qsum;
void segment_query(int i, int l, int r, int ql, int qr) {
    if (!i || ql <= l && r <= qr) {
        qcnt += node[i].cnt;
        qsum += node[i].sum;
        return;
    }
    int mid = l + r >> 1;
    if (ql <= mid) {
        segment_query(node[i].ls, l, mid, ql, qr);
    }
    if (mid + 1 <= qr) {
        segment_query(node[i].rs, mid + 1, r, ql, qr);
    }
}

int main() {
    scanf("%d%d%d", &n[0], &n[1], &Q);
    segment_modify(Root[0], 0, A, 0, n[0]);
    segment_modify(Root[1], 0, A, 0, n[1]);
    for (int i = 1; i <= Q; i ++) {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y), t --;
        qcnt = qsum = 0;
        segment_query(Root[t ^ 1], 0, A, a[t][x], A);
        ans -= 1ll * (n[t ^ 1] - qcnt) * a[t][x] + qsum;
        segment_modify(Root[t], 0, A, a[t][x], -1);
        a[t][x] = y;
        segment_modify(Root[t], 0, A, a[t][x], 1);
        qcnt = qsum = 0;
        segment_query(Root[t ^ 1], 0, A, a[t][x], A);
        ans += 1ll * (n[t ^ 1] - qcnt) * a[t][x] + qsum;
        printf("%lld\n", ans);
    }
    return 0;
}


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

#define rep2(i,k,n) for(i64 i=(i64)(k);i<(i64)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) begin(x),end(x)
#ifdef ENV_LOCAL
#define dump if (1) cerr
#else
#define dump if (0) cerr
#endif

using namespace std;
using namespace std::string_literals;

using i32 = int32_t;
using i64 = int64_t;
using f64 = double;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;

//using namespace harudake;

void dfs(const vector<vi32>& g, const vi32& clr, vi32& cnt, vi32& ans, i32 i, i32 p = -1) {
  if (cnt[clr[i]] == 0) ans.push_back(i+1);
  ++cnt[clr[i]];
  for (auto&& to : g[i]) {
    if (to == p) continue;
    dfs(g, clr, cnt, ans, to, i);
  }
  --cnt[clr[i]];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i32 n;
  cin>>n;
  vi32 clr(n);
  rep(i,n) cin>>clr[i];
  vector<vi32> g(n);
  rep(i,n-1) {
    i32 a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi32 cnt(100001, 0);
  vi32 ans;
  dfs(g, clr, cnt, ans, 0);
  sort(all(ans));
  for (auto&& idx : ans) {
    cout<<idx<<"\n";
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){ a=min(a,b); }
template<class T> inline void ckmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
using uint=unsigned int;
using int64=long long;
using uint64=unsigned long long;
using ipair=pair<int,int>;
using VI=vector<int>;
using VD=vector<double>;

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

int n;
unordered_map<int,int>  dp;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cin >> n;
    int minN = 1000000005,tmp;
    for(int i=0;i<n;++i){
        cin >> tmp;
        minN = min(minN, tmp);
        for(int i=1;i*i<=tmp;++i){
            if(tmp%i==0){
                if(dp[i]==0)dp[i] = tmp;
                else dp[i] = gcd(dp[i],tmp);
                int g = tmp/i;
                if(dp[g]==0)dp[g] = tmp;
                else dp[g] = gcd(dp[g],tmp);
            }
        }
    }

    int res = 0;
    dp[minN] = minN;
    for(auto bb = dp.begin();bb!=dp.end();++bb){
        if(bb->first<=minN&&bb->first == bb->second) ++res;
    }
    cout << res << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long //delete if causing problems
#define F first
#define dbg(x)  cout<<#x<<" "<<x<<endl;
#define S second
#define setbit(n) __builtin_popcount(n)
#define all(x) x.begin() , x.end()
#define clr(x) memset(x,0,sizeof(x))
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define endl "\n" //delete if interactive
#define MOD 1000000007
const int inf = 1e18;
int power(int a, int b);

signed   main()
{
	fast
	int t = 1;
	//cin >> t;
	while (t--)
	{
		int a,b,n;

		cin>>n>>a>>b;

		cout<<n-a+b<<endl;

	}
	return 0;
}

int power(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b % 2) b-- , res = res * a;
		else b = b / 2 , a *= a;
	}
	return res;
}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	cout << N - A + B << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define f(x,y,z) for(x=y;x<z;x++)
#define pb push_back
#define mp make_pair
#define ld long double
#define fb(x,y,z) for(x=y;x>z;x--)
#define ps(x,y) fixed << setprecision(y) << x
#define PI 3.1415926535
#define mod 1000000007
#define mods 998244353
#define setbits(x) __builtin_popcountll(x)
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a,b,sizeof(a))

// AUTHOR ALOK KUMAR
int lcm(int a,int b)
{
    return (a*b)/(__gcd(a,b));
}
int power(int a,int b)
{
    int c=1;
    while(b)
    {
        if(b&1)
        c*=a;
        a*=a;
        b>>=1;
    }
    return c;
}

void solve()
{
    int x;
    cin>>x;
    if(x>=0)
    cout<<x<<"\n";
    else
    cout<<"0\n";

}

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

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll mod=998244353;
const ll MAX=140010;

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

signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    unordered_map<ll,ll>ma;
    ll ans=0;
    rep(i,n){
        REP(j,1,sqrt(a[i]+1)){
            if(a[i]%j==0){
                if(j<=a[0]){
                    ma[j]=gcd(ma[j],a[i]);
                }
                if(a[i]/j<=a[0]){
                    ma[a[i]/j]=gcd(ma[a[i]/j],a[i]);
                }
            }
        }
    }
    for(auto e:ma){
        if(e.fi==e.se){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

const int MOD = 1000000007;
const int INF = 1e9;
const long long INFLL = 1e18;
using ll = long long;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> f(h);
  for(int i = 0; i < h; i++) cin >> f[i];

  int ans = 0;
  for(int i = 1; i < h; i++){
    for(int j = 1; j < w; j++){
      int cnt = 0;
      cnt += (f[i][j] == '#');
      cnt += (f[i-1][j] == '#');
      cnt += (f[i][j-1] == '#');
      cnt += (f[i-1][j-1] == '#');
      if(cnt % 2 == 1) ans ++;
    }
  }
  cout << ans << endl;

  return 0;
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h); REP(i, h) cin >> s[i];
  auto f = [&](int y, int x, const vector<int> &check) {
    FOR(k, 4, 7) {
      int ny = y + dy8[k], nx = x + dx8[k];
      if (s[ny][nx] != (count(ALL(check), k) == 1 ? '#' : '.')) return false;
    }
    return true;
  };
  int ans = 0;
  FOR(i, 1, h) REP(j, w - 1) {
    if (s[i][j] == '#') {
      ans += f(i, j, {}) || f(i, j, {4, 5}) || f(i, j, {5, 6}) || f(i, j, {6, 4});
    } else {
      ans += f(i, j, {4}) || f(i, j, {5}) || f(i, j, {6}) || f(i, j, {4, 5, 6});
    }
  }
  cout << ans << '\n';
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define fornext(x, i) for(int i = head[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define mset(a, b) memset(a, b, sizeof(a))
#define Rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define dRep(i, a, b) for(int i = (a); i >= (b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define endl '\n'
#define int ll
#define un unsigned
#define ll long long
#define db double
#define rept cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
#define dbg cout<<"c "

template<typename _T>
inline void rd(_T &_d) {
	int _f; char _c;
	_f=_d=0;
	while(_c=getchar(),!isdigit(_c)) if (_c=='-') _f=1;
	while(isdigit(_c)) _d=_d*10+_c-'0',_c=getchar();
	if (_f) _d=-_d;
}

template <typename _T,typename ...Args>
inline void rd(_T &_d,Args &..._a) {
	rd(_d);
	rd(_a...);
}

#define mod(x) (x=(x>=M?x-M:x))
const int N=2e5+5,M=998244353;
int n,k,c[305][305],a[N],p[N][305],s[305];

signed main() {
	rd(n,k);
	Rep(i,1,n) rd(a[i]);
	Rep(i,0,k) c[i][0]=1;
	Rep(i,1,k) Rep(j,1,k) c[i][j]=c[i-1][j]+c[i-1][j-1],mod(c[i][j]);
	int tmp;
	Rep(i,1,n) {
		tmp=1;
		Rep(j,1,k) tmp=tmp*a[i]%M,s[j]+=tmp,mod(s[j]),p[i][j]=tmp;
	}
	Rep(i,1,n) p[i][0]=1;
	s[0]=n;
	int ans,inv=499122177;
	Rep(i,1,k) {
		ans=0;
		Rep(j,0,i) {
			ans=(ans+c[i][j]*s[j]%M*s[i-j]%M+M-s[i]*c[i][j]%M)%M;
		}
		cout<<ans*inv%M<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
// @title mod int
#include <iostream>
using ll = long long;

#ifdef MUTABLE
int mod;
#else
template<int mod>
#endif
struct ModInt {
  int val;
  ModInt inv() const{
    int tmp,a=val,b=mod,x=1,y=0;
    while(b)tmp=a/b,a-=tmp*b,std::swap(a,b),x-=tmp*y,std::swap(x,y);
    return ModInt(x);
  }
  ModInt():val(0){}
  ModInt(ll x){if((val=x%mod)<0)val+=mod;}
  ModInt pow(ll t){ModInt res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
  ModInt& operator+=(const ModInt& x){if((val+=x.val)>=mod)val-=mod;return *this;}
  ModInt& operator-=(const ModInt& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
  ModInt& operator*=(const ModInt& x){val=(ll)val*x.val%mod; return *this;}
  ModInt& operator/=(const ModInt& x){return *this*=x.inv();}
  bool operator==(const ModInt& x) const{return val==x.val;}
  bool operator!=(const ModInt& x) const{return val!=x.val;}
  bool operator<(const ModInt& x) const{return val<x.val;}
  bool operator<=(const ModInt& x) const{return val<=x.val;}
  bool operator>(const ModInt& x) const{return val>x.val;}
  bool operator>=(const ModInt& x) const{return val>=x.val;}
  ModInt operator+(const ModInt& x) const{return ModInt(*this)+=x;}
  ModInt operator-(const ModInt& x) const{return ModInt(*this)-=x;}
  ModInt operator*(const ModInt& x) const{return ModInt(*this)*=x;}
  ModInt operator/(const ModInt& x) const{return ModInt(*this)/=x;}
  friend std::ostream& operator<<(std::ostream& os, const ModInt& mi) { os << mi.val; return os; }
  static int get_mod() { return mod; }
};

#ifndef MUTABLE
using modint = ModInt<998244353>;
#endif

// @title 階乗、nPr、nCr
#include <vector>

template <int mod>
struct Factorial {
  using mint = ModInt<mod>;
  std::vector<modint> Fact, Finv;
public:
  Factorial(int _n): Fact(_n+1), Finv(_n+1) {
      Fact[0]=mint(1); for (int i = 0; i < _n; ++i) Fact[i+1]=Fact[i]*(i+1);
      Finv[_n]=mint(1)/Fact[_n]; for (int i = _n; i > 0; --i) Finv[i-1]=Finv[i]*i;
  }
  mint fact(int n,bool inv=0) { if (inv) return Finv[n]; else return Fact[n]; }
  mint nPr(int n,int r){ if (n<0||n<r||r<0) return mint(0); else return Fact[n]*Finv[n-r]; }
  mint nCr(int n,int r){ if (n<0||n<r||r<0) return mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

using factorial = Factorial<998244353>;

int main() {
    int n, k; cin >> n >> k;
    vector<int> la(n);
    for (int i = 0; i < n; ++i) {
        cin >> la[i];
    }
    vector<modint> lp(k+1);
    lp[0] = n;
    for (int i = 0; i < n; ++i) {
        modint a = la[i];
        for (int x = 1; x <= k; ++x) {
            lp[x] += a.pow(x);
        }
    }
    factorial fact(1000);
    for (int x = 1; x <= k; ++x) {
        modint sum = 0;
        for (int i = 0; i <= x; ++i) {
            modint c = fact.nCr(x,i);
            sum += c*lp[i]*lp[x-i];
        }
        sum -= modint(2).pow(x)*lp[x];
        sum /= 2;
        cout << sum << endl;
        // cerr << x << " " << lp[x] << endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};
vector<double> x(105),y(105);
double dis(int i,int j){
    return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    REP(i,n) cin >> x[i] >> y[i];
    vector<pair<double,pair<int,int>>> p;
    REP(i,n){
        FOR(j,i+1,n){
            p.push_back({dis(i,j),{i,j}});
        }
        p.push_back({y[i]+100.0,{i,n}});
        p.push_back({100.0-y[i],{i,n+1}});
    }
    double l=0,r=200;
    for(int t=0;t<100;t++){
        double mid=(l+r)/2.0;
        dsu uf(n+2);
        for(auto e:p){
            if(e.first<=mid){
                uf.merge(e.second.first,e.second.second);
            }
        }
        if(uf.same(n,n+1)) r=mid;
        else l=mid;
    }
    cout << fixed << setprecision(10) << l/2.0 << endl;
}

#include<iostream>
#include<utility>
#include <queue>
#include<vector>
#include <functional>
double h[30][29],v[29][30];

typedef std::pair<int, std::pair<int,int>> P;

char prev[30][30] = {0};
int d[30][30] = {0};
const int INF = 9000*30*30;

void dijkstra(int ti,int tj) {
    const int dir[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
    const char dirc[4] = {'D','U','R','L'};
    for(int i=0;i<30;i++){
        for(int j=0;j<30;j++){
            prev[i][j] = '\0';
            d[i][j] = INF;
        }
    }
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    d[ti][tj] = 0;
    que.push(P(0, std::pair<int,int>(ti,tj)));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        std::pair<int,int> point = p.second;
        int vi = point.first,vj = point.second;
        if (d[vi][vj] < p.first) {
            continue;
        }
        for (int i=0;i<4;i++) {
            int mvi = vi+dir[i][0],mvj = vj+dir[i][1];
            if(mvi>=30||mvi<0||mvj>=30||mvj<0){
                continue;
            }
            int cost;
            if(i<2){
                cost = d[vi][vj] + v[vi+(-1+dir[i][0])/2][vj];
            }else{
                cost = d[vi][vj] + h[vi][vj+(-1+dir[i][1])/2];
            }
            if (d[mvi][mvj] > cost) {
                d[mvi][mvj] = cost;
                prev[mvi][mvj] = dirc[i];
                que.push(P(cost,std::pair<int,int>(mvi,mvj)));
            }
        }
    }
}

int main(){
    for(int i=0;i<30;i++){
        for(int j=0;j<29;j++){
            h[i][j] = 1000;
            v[j][i] = 1000;
        }
    }

    for(int i=0;i<1000;i++){
        int si,sj,ti,tj;
        std::cin >> si>>sj>>ti>>tj;
        dijkstra(ti,tj);
        while(si!=ti||sj!=tj){
            char dir = prev[si][sj];
            std::cout<<dir;
            switch (dir)
            {
            case 'U':
                si--;
                break;
            case 'D':
                si++;
                break;
            case 'L':
                sj--;
                break;
            case 'R':
                sj++;
                break;
            default:
                break;
            }
        }
        std::cout<<std::endl;
        int cost;
        std::cin >> cost;
    }
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define F first
#define S second
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 60;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;

string s[110];

int main(int argc, char const* argv[])
{
  int h, w; cin >> h >> w;
  rep(i, h)cin >> s[i];
  int res = 0;
  rep(i, h){
    rep(j, w - 1){
      if(s[i][j] == '.' && s[i][j+1] == '.')++res;
    }
  }
  rep(i, h - 1){
    rep(j, w){
      if(s[i][j] == '.' && s[i+1][j] == '.')++res;
    }
  }
  cout << res << endl;
  return 0;
}