#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int Maxn=100000;
int n;
int a[Maxn+5],b[Maxn+5];
int c[Maxn+5],d[Maxn+5];
bool cmp(int p,int q){
	return p>q;
}
int main(){
	scanf("%d",&n);
	ll ans=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++){
		if(i&1){
			c[(i+1)>>1]=b[i]-a[i];
		}
		else{
			d[i>>1]=b[i]-a[i];
		}
	}
	sort(c+1,c+1+(n>>1),cmp);
	sort(d+1,d+1+(n>>1),cmp);
	for(int i=1;i<=(n>>1);i++){
		if(c[i]+d[i]>0){
			ans+=c[i]+d[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define Swap(a,b) (a+=b,b=a-b,a-=b)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline void AscRadix32(int *a,const int sz,const int minus)
{
  int x,shift=0,elem[0400],temp[sz];
  while(shift<040)
  {
    int bucket[0400]={0};
    rep(i,sz){x=(a[i]>>shift)&0377;bucket[x]++;temp[i]=a[i];}
    elem[0]=0;rep(i,0377)elem[i+1]=elem[i]+bucket[i];
    rep(i,sz){x=(temp[i]>>shift)&0377;a[elem[x]]=temp[i];elem[x]++;}
    shift+=010;
  }
  rep(i,minus>>1)Swap(a[sz-minus+i],a[sz-1-i]);
  rep(i,(sz-minus)>>1)Swap(a[i],a[sz-minus-1-i]);
  rep(i,sz>>1)Swap(a[i],a[sz-1-i]);
}
int main()
{
  int N=IN(),A[N],B[N],m1=0,m2=0,p1[N/2],p2[N/2];long score=0;
  rep(i,N){A[i]=IN(),score+=A[i];}rep(i,N){B[i]=IN();}
  rep(i,N)if(i&1){p1[i/2]=B[i]-A[i];if(B[i]-A[i]<0)m1++;}else{p2[i/2]=B[i]-A[i];if(B[i]-A[i]<0)m2++;}
  AscRadix32(p1,N/2,m1);AscRadix32(p2,N/2,m2);
  rep(i,N>>1)if(p1[(N>>1)-1-i]+p2[(N>>1)-1-i]>0)score+=p1[(N>>1)-1-i]+p2[(N>>1)-1-i];
  return OUT(score),0;
}


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

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

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    FOR(i, h) cin >> s[i];

    vector<vector<ll>> dp, a, b, c;
    init(dp, 0, h, w);
    init(a, 0, h, w);
    init(b, 0, h, w);
    init(c, 0, h, w);
    dp[0][0] = a[0][0] = b[0][0] = c[0][0] = 1;

    FOR(i, h){
        FOR(j, w){
            if (i == 0 && j == 0) continue;
            if (s[i][j] == '#') continue;
            if (i) a[i][j] = a[i-1][j];
            if (j) b[i][j] = b[i][j-1];
            if (i && j) c[i][j] = c[i-1][j-1];

            dp[i][j] = a[i][j] + b[i][j] + c[i][j];
            dp[i][j] %= MOD;

            a[i][j] += dp[i][j];
            a[i][j] %= MOD;
            b[i][j] += dp[i][j];
            b[i][j] %= MOD;
            c[i][j] += dp[i][j];
            c[i][j] %= MOD;
        }
    }

    cout << dp[h-1][w-1] << endl;

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

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    while(t--){
        ll n,x,ans=0;
        cin >> n >> x;
        vector<ll> arr(n,0);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        vector<map<ll,ll>> dp(n,map<ll,ll> ());
        ll factor= x/arr[n-1];
        dp[n-1][factor*arr[n-1]-x]=1;
        if(abs((factor+1)*arr[n-1]-x) < arr[n-1])
            dp[n-1][(factor+1)*arr[n-1]-x]=1;
        for(int i=n-2;i>=0;i--){
            for(auto j: dp[i+1]){
                ll diff= j.first;
                factor=diff/arr[i];
                dp[i][diff-factor*arr[i]]+=j.second;
                if(diff<0){
                    if(abs(factor-1) < arr[i+1]/arr[i] && abs(diff-(factor-1)*arr[i]) < arr[i]){
                        dp[i][diff-(factor-1)*arr[i]]+=j.second;
                    }
                }
                else{
                    if(factor+1 < arr[i+1]/arr[i] && abs(diff-(factor+1)*arr[i]) < arr[i]){
                        dp[i][diff-(factor+1)*arr[i]]+=j.second;
                    }
                }
            }
            // if(dp[i].size() > 2){
            //     cout << "Error" << endl;
            //     break;
            // }
        }
        cout << dp[0][0] << endl;
    }
    return 0;
}


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//#define ENVIRONMENT_LINKED_ACL

#ifdef ENVIRONMENT_LINKED_ACL
#include <atcoder/convolution>
#include <atcoder/lazysegtree>
#include <atcoder/segtree.hpp>
#endif

//#define ENVIRONMENT_LINKED_BOOST

#ifdef ENVIRONMENT_LINKED_BOOST
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#endif

using namespace std;
using uint = unsigned int;
using ll   = long long;
using ull  = unsigned long long;
#define REP(i, a, b)    for (ll i = a; i < b; ++i)
#define REPREV(i, a, b) for (ll i = a; i > b; --i)

const int _ = []() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    return 0;
}();

template <typename value_t>
void resize(value_t& v, const value_t& val) { v = val; }
template <typename vec_t, typename value_t, typename... arg_t>
void resize(std::vector<vec_t>& v, const value_t& val, int size, arg_t... arg) {
    v.resize(size);
    for (auto& c : v) resize(c, val, arg...);
}

template <typename A, typename B>
void chmin(A& a, const B& b) {
    a = min(a, static_cast<A>(b));
};
template <typename A, typename B>
void chmax(A& a, const B& b) {
    a = max(a, static_cast<A>(b));
};

template <typename T>
T modpow(T r, T n, T mod) {
    T ans = 1;
    T tmp = r % mod;
    while (n > 0) {
        if ((n & 1) > 0) {
            ans = ans * tmp % mod;
        }
        tmp = tmp * tmp % mod;
        n >>= 1;
    }
    return ans;
}
int main() {
    ll N, P;
    cin >> N >> P;
    constexpr ll mod = 1e9 + 7;
    ll ans           = (P - 1) * modpow<ll>(P - 2, N - 1, mod) % mod;
    cout << ans << endl;
    return 0;
}

#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
const int N = 200005, P = 1e9 + 7;

char s[N];
int n, k;
ll f[N][17];

int to_num(char c)
{
    if ('0' <= c && c <= '9')
        return c ^ '0';
    return 10 + c - 'A';
}

void init()
{
    f[0][k] = 1;
    for (int i = 1; i < n; ++i)
        for (int j = k; ~j; --j)
            f[i][j] = (j * f[i - 1][j] + (16 - j) * f[i - 1][j + 1]) % P;
}

ll dp(char s[])
{
    ll res = 0;
    int i = 0, cnt = 0;
    bool st[16];
    memset(st, 0, sizeof st);
    for (int j = 1; j < n; ++j)
        res = (res + f[j][0] - f[j - 1][1]) % P;
    while (i < n)
    {
        int c = to_num(s[i]), l = n - i - 1;
        for (int j = 0; j < c; ++j)
            if (st[j])
                res = (res + f[l][cnt]) % P;
            else if (i || j)
                res = (res + f[l][cnt + 1] % P);
        if (!st[c])
            ++cnt, st[c] = true;
        if (++i == n && k == cnt)
            ++res;
    }
    return res;
}

int main()
{
    scanf("%s%d", s, &k);
    n = strlen(s);
    init();
    cout << dp(s) << endl;
}


#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#include <cstring>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll>
#define pll pair <ll,ll>

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return 0;
    }
    ll md=b;
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        //res%=MAX, a%=MAX;
        b>>=1;
    }
    return res;
}

///target expert

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double x1, y1, x2, y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<fixed<<setprecision(20)<<(y1*x2+y2*x1)/(y1+y2);
}

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#pragma comment(linker, "/stack:200000000")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 2e5 + 5;

int i, n, a[N], b[N], mx[N], c[N];

void solve() {
    cin >> n;
    mx[0] = 0;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
        mx[i] = max(mx[i - 1], a[i]);
    }
    c[0] = 0;
    for (i = 1; i <= n; i++) {
        cin >> b[i];
        c[i] = max(c[i - 1], b[i] * mx[i]);
        cout << c[i] << endl;
    }
}

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


//Codeforcesで128bit整数を使いたいとき
//→__int128_tを使う&GNU C++17 (64)で提出する

//インクルードなど
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutall(x) {for(int i=0;i<sizeof(x)/sizeof(x[0]);i++){cout<<x[i]<<"|";};};cout<<endl;
//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

bool xOR(bool x,bool y){
    return ((x&&(!y))||((!x)&&y));
}
signed main(){
    ll v,t,s,d;cin>>v>>t>>s>>d;
    if(v*t<=d&&v*s>=d){cout<<"No";}else{cout<<"Yes";};

}

#include <cstdio>

int V, T, S, D;

int main() {
    scanf("%d %d %d %d", &V, &T, &S, &D);

    if(V*T<=D and D<=V*S) printf("No");
    else printf("Yes");
}


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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int H,W;
string S[2020];
int dp[2020][2020];

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>H>>W;
	FOR(y,H) cin>>S[y];

	for(y=H-1;y>=0;y--) {
		for(x=W-1;x>=0;x--) {
			if(x==W-1&&y==H-1) continue;
			if((x+y)%2==0) {
				dp[y][x]=-10000;

				if(y+1<H) dp[y][x]=max(dp[y][x],dp[y+1][x]+(S[y+1][x]=='+'?1:-1));
				if(x+1<W) dp[y][x]=max(dp[y][x],dp[y][x+1]+(S[y][x+1]=='+'?1:-1));

			}
			else {
				dp[y][x]=10000;

				if(y+1<H) dp[y][x]=min(dp[y][x],dp[y+1][x]+(S[y+1][x]=='+'?-1:1));
				if(x+1<W) dp[y][x]=min(dp[y][x],dp[y][x+1]+(S[y][x+1]=='+'?-1:1));
			}
		}
	}

	if(dp[0][0]>0) {
		cout<<"Takahashi"<<endl;
	}
	else if(dp[0][0]==0) {
		cout<<"Draw"<<endl;
	}
	else cout<<"Aoki"<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define ul unsigned long
#define rep(i,n) for (ll i = 0;i<(n);++i)
#define all(v) v.begin(),v.end()

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;}
vector<long long> divisor(long long n){vector<long long> res;long long i = 1;while (i*i<=n){if(n%i==0){res.push_back(i);}i++;}if(res.size()==0)return res;for(long long i = res.size()-1-(res.back()*res.back()==n);i>=0;--i){res.push_back(n/res[i]);}return res;}
long long safe_mod(long long x,long long m){x%=m;if(x<0){x+=m;}return x;}
long long modpow(long long x,long long n,long long mod){long long ans=1;while(n>0){if(n&1){ans*=x;ans%=mod;}n>>=1;x*=x;x%=mod;}return ans;}
long long intpow(long long x,long long n){long long ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
//template<typename T>T intpow(T x,T n){T ans=1;while(n>0){if(n&1){ans*=x;}n>>=1;x*=x;}return ans;}
vector<pair<long long,long long>> factor_lst(long long n){vector<pair<long long,long long>> factor_lst;long long d=2;while(d*d<=n){if(n%d==0){long long num=0;while(n%d==0){num+=1;n/=d;}factor_lst.push_back({d,num});}d+=1;}if(n!=1){factor_lst.push_back({n,1});}return factor_lst;}
#define Uniq(a) sort(all(a));a.erase(unique(all(a)),end(a))

int msb(int x){return x==0 ? -1:32-__builtin_clz(x);}//1-indexed
int lsb(int x){return x==0 ? 32:__builtin_ctz(x)+1;}//1-indexed
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(long long x){return __builtin_popcount(x);}

bool ingrid(int i,int j,int H,int W){
    return 0<=i&&i<H&&0<=j&&j<W;
}

const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
template<typename T> void print(vector<T> &v){for(int i=0;i<v.size();++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T> void print(T* v,int size){for(int i=0;i<size;++i){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
template<typename T,typename S>void print(pair<T,S>&p){cout<<p.first<<" "<<p.second<<endl;}
const ll LINF=4*1e18;
const ll MINF=5*1e15;
const int INF=1e9+5;
const ld PI=acosl(-1);
const ld DINF=INF;

void Main();
int main(){cout<<fixed<<setprecision(15);Main();}

void Main(){

int L,R;cin>>L>>R;
vector<ll> table(1000001);

ll ans=0;

for(ll g=1000000;g>=2;--g){
    table[g]=(ll)(R/g-(L-1)/g)*(R/g-(L-1)/g);
    for(ll h=2*g;h<=1000000;h+=g){
        table[g]-=table[h];
    }
    ans+=table[g];
}
for(ll x=L;x<=R;++x){
    ans-=(R/x-(L-1)/x)*2-1;
}
if(L==1)ans+=2*R-1;

cout<<ans<<endl;
}


#include<bits/stdc++.h>
#define f(i,n) for(long long int i = 0 ; i < n;  i++)
#define F first
#define S second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define all(s) s.begin(), s.end()
#define u_s unordered_set
#define u_m unordered_map
#define ll long long int
#define pb push_back
#define pll pair<ll,ll>
#define parr(arr) for(auto x: arr)cout<<x<<" ";cout<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define testcase ll tt; cin>>tt; while(tt--)
using namespace std;

vector<vvll> dp;

ll helper(vvll &v, ll i, ll j, ll took){
    if(i == (ll)v.size() || took == 31) return 0;
    if(dp[i][j][took]!=-1) return dp[i][j][took];
    ll rem = (~took) & 31;
    ll ans = 0;

    if(j == 2){
        ll cnt = 0;
        ans = INT_MAX;
        while(rem){
            if(rem&1) ans = min(ans,v[i][cnt]);
            rem >>= 1; cnt++;
        }
        return dp[i][j][took] = max(ans, helper(v,i+1,j,took));
    }

    for(ll s = rem; s ; s=(s-1)&rem){
        ll cnt = 0;
        ll mini = INT_MAX;
        ll tmp = s;
        while(tmp){
            if(tmp&1) mini = min(mini, v[i][cnt]);
            cnt++; tmp>>=1;
        }
        ans = max(ans, min(mini,helper(v, i+1, j+1, took|s)));
    }
    ans = max(ans, helper(v, i+1, j, took));
    return dp[i][j][took] = ans;
}

int main() {
    fast;
    ll n; cin>>n;
    vvll v(n, vll(5)); for(auto &x: v) for(auto &i: x) cin>>i;
    dp.resize(n, vvll(3, vll(32,-1)));
    cout<<helper(v, 0, 0, 0);
	return 0;
}

#pragma region templates
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using PQ = priority_queue<T>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for(ll i = a; i < (ll)(n); ++i)
#define repr(i, a, n) for(ll i = n - 1; (ll)a <= i; --i)
#define ENDL '\n'
typedef pair<int, int> Pi;
typedef pair<ll, ll> PL;
constexpr ll mod = 1000000007;  // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 + 99);
const ld PI = acos((ld)-1);
constexpr ll dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
template <typename T, typename U> inline bool chmin(T& t, const U& u) {
  if(t > u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T, typename U> inline bool chmax(T& t, const U& u) {
  if(t < u) {
    t = u;
    return 1;
  }
  return 0;
}
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template <typename T, typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(; n; n >>= 1) {
    if(n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i); }
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template <typename T> T rand(T l, T r) {
  static random_device rd;
  static mt19937 g(rd());
  return uniform_int_distribution<T>(l, r)(g);
}

template <typename T> istream& operator>>(istream& is, vector<T>& vec) {
  for(auto&& x : vec) is >> x;
  return is;
}

template <typename T, typename Y>
ostream& operator<<(ostream& os, const pair<T, Y>& p) {
  return os << "{" << p.fs << "," << p.sc << "}";
}

template <typename T> ostream& operator<<(ostream& os, const V<T>& v) {
  os << "{";
  for(auto e : v) os << e << ",";
  return os << "}";
}

template <typename... Args> void debug(Args&... args) {
  for(auto const& x : {args...}) { cerr << x << ' '; }
  cerr << ENDL;
}
#pragma endregion templates

signed main() {
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;

  VV<ll> v(n, V<ll>(5));
  cin >> v;

  ll ok = 0, ng = INF, md;
  while(abs(ok - ng) > 1) {
    md = (ok + ng) / 2;

    V<ll> a(n), dp(1 << 5, 0);
    rep(i, 0, n) {
      ll bit = 0;
      rep(j, 0, 5) {
        bit *= 2;
        if(v[i][j] >= md) bit++;
      }
      a[i] = bit;
      dp[bit]++;
    }

    repr(bit, 0, (1 << 5)) {
      rep(d, 0, 5) if(bit & (1 << d)) { dp[bit ^ (1 << d)] += dp[bit]; }
    }

    rep(i, 0, n) {
      rep(j, i + 1, n) {
        ll now = (a[i] | a[j]), need = 0;
        rep(k, 0, 5) if(!(now & (1 << k))) need += (1 << k);

        if(dp[need]) {
          ok = md;
          goto f;
        }
      }
    }
    ng = md;
  f:;
  }
  cout << ok << ENDL;
}
//(・_・)(・_・)(・_・)(・_・)
//CHECK overflow,what to output?
//any other simpler approach?


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T,class U>
inline bool chmax(T &a,U b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T,class U>
inline bool chmin(T &a,U b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll gcd(ll a,ll b){
    while(a%b){
        a%=b;
        swap(a,b);
    }
    return b;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>primes;
void init_prime(int n){
    primes.push_back(2);
    for(int i=3;i<=n;i+=2){
        bool f=true;
        for(int j:primes){
            if(j*j>i)break;
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f)primes.push_back(i);
    }
}
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res;
}
vector<ll>inv,fact,factinv;
void init_fact(int n){
    inv.resize(n+1);
    fact.resize(n+1);
    factinv.resize(n+1);
    inv[0]=0;
    inv[1]=1;
    fact[0]=1;
    factinv[0]=1;
    for(ll i=1;i<=n;i++){
        if(i>=2)inv[i]=mod-((mod/i)*inv[mod%i]%mod);
        fact[i]=(fact[i-1]*i)%mod;
        factinv[i]=factinv[i-1]*inv[i]%mod;
    }
}
ll _inv(ll a,ll m=mod){
    //gcd(a,m) must be 1
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
ll multicomb(int a,int b){
    return comb(a+b-1,b);
}
int n,c[100010],cnt[100010];
vector<int>g[100010];
vector<int>ans;
void dfs(int x,int p=-1){
    cnt[c[x]]++;
    if(cnt[c[x]]==1)ans.pb(x);
    for(int i:g[x]){
        if(i!=p){
            dfs(i,x);
        }
    }
    cnt[c[x]]--;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>c[i];
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0);
    sort(all(ans));
    for(int i:ans)cout<<i+1<<endl;
    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusive
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;

long long LLINF = 1e18;
int INF = 1e9+1e6;
#define MAXN (200006)
ll n, m, mod=998244353, dp[20][MAXN], f[MAXN], inv[MAXN];
ll qexp(ll x,ll e){
	ll sum=1;
	for(;e;e>>=1,x*=x,x%=mod) if(e&1) sum*=x, sum%=mod;
	return sum;
}
ll C(ll n,ll k) { return n < k ? 0ll : f[n] * inv[k] % mod * inv[n-k] % mod; }
vector<int> d[MAXN];
int main() {
	f[0]=1; FOR(i,1,MAXN-1) f[i]=f[i-1]*i%mod;
	inv[MAXN-1] = qexp(f[MAXN-1], mod-2); DEC(i,MAXN-2,0) inv[i]=inv[i+1]*(i+1)%mod;
	FAST
	cin>>n>>m;
	FOR(j,1,m) {
		for(ll k=2;k*k<=j;++k) if(j%k==0) {
			d[j].eb(k);
			if(j/k!=k) d[j].eb(j/k);
		}
	}
	FOR(i,1,m) dp[1][i] = 1;
	FOR(i,2,min(n, 19ll)) {
		FOR(j,1,m) {
			for(auto k:d[j]) {
				dp[i][j] += dp[i-1][k];
				if(dp[i][j] >= mod) dp[i][j] -= mod;
			}
			if(j != 1 && i == 2) {
				dp[i][j] += dp[i-1][1];
				if(dp[i][j] >= mod) dp[i][j] -= mod;
			}
		}
	}
	ll ans = 0;
	FOR(i,1,min(n,19ll)) FOR(j,1,m) {
		ans += dp[i][j] * C(n-1, i-1) % mod;
		if(ans >= mod) ans -= mod;
	}
	cout<<ans<<'\n';
}


#include <bits/stdc++.h>
#define SIZE 1005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	int t=1;
	while(t<n) t<<=1;
	for(int i=0;i<n;i++)
	{
		int a=i*2;
		int b=i*2+1;
		for(int j=11;j>=0;j--)
		{
			if(a>=n&&(a>>j&1)) a^=1<<j;
			if(b>=n&&(b>>j&1)) b^=1<<j;
		}
		printf("%d %d\n",a+1,b+1);
	}
}

#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

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

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

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 20;
long long GCD(long long a, long long b) { return (b == 0) ? a : GCD(b, a % b); }
inline long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }
inline long long normalize(long long x, long long mod) { x %= mod; if (x < 0) x += mod; return x; }
struct GCD_type { long long x, y, d; };
GCD_type ex_GCD(long long a, long long b)
{
    if (b == 0) return {1, 0, a};
    GCD_type pom = ex_GCD(b, a % b);
    return {pom.y, pom.x - a / b * pom.y, pom.d};
}
ll testCases;
ll fun(ll t, ll a[], ll n[])
{
    ll lcm, ans;
    for(ll i=1;i<=t;i++) normalize(a[i], n[i]);
    ans = a[1];
    lcm = n[1];
    for(ll i = 2; i <= t; i++)
    {
        auto pom = ex_GCD(lcm, n[i]);
        ll x1 = pom.x;
        ll d = pom.d;
        if((a[i] - ans) % d != 0) return LLONG_MAX;
        ans = normalize(ans + x1 * (a[i] - ans) / d % (n[i] / d) * lcm, lcm * n[i] / d);
        lcm = LCM(lcm, n[i]); // you can save time by replacing above lcm * n[i] /d by lcm = lcm * n[i] / d
    }
    return ans;
}

int main()
{
  FAST/**/

  ll t;
  cin>>t;

  while(t--)
  {
      ll x,y,p,q;
      cin>>x>>y>>p>>q;

      ll ans = LLONG_MAX;

      for(ll r1=p;r1<=p+q-1;r1++)
            for(ll r2=x;r2<=x+y-1;r2++)
            {
                ll r[3], m[3];
                r[1] = r1, m[1] = p+q;
                r[2] = r2, m[2] = 2*(x+y);
                ll temp = __gcd(m[1], m[2]);
                if(abs(r1-r2)%temp != 0)
                        continue;
                ans = min(ans, fun(2, r, m));
            }
       if(ans != LLONG_MAX)
            cout<<ans<<'\n';
       else cout<<"infinity\n";
  }

  return 0;
}


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

int n;
int ans;

signed main(){
    cin>>n;

    for(int i=2;i<=n;i++){
        ans+=n*1.0/(n-i+1);
    }

    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
using rr = long long;
using O = pair<int, int>;
#define rep(dsfgt, polkmnjh) for (int dsfgt = 0; dsfgt < (polkmnjh); dsfgt++)
int main()
{
    rr polkmnjh, satybnh = 0, dfgv = 1;
    cin >> polkmnjh;
    while (1)
    {
        string hikaku = to_string(dfgv) + to_string(dfgv);
        if (stoll(hikaku) <= polkmnjh)
        {
            satybnh++;
            dfgv++;
        }
        else
        {
            break;
        }
    }
    cout << satybnh << endl;
    return 0;
}


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

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

ll dp[220000][2][17];

ll to_num(char c) {
    ll x = c - '0';
    if (0<=x && x<10) return x;
    ll y = c - 'A';
    return 10 + y;
}

ll bitcnt(ll bit) {
    ll res = 0;
    rep(i,d) if ((bit>>i)&1) res++;
    return res;
}

void addmodp(ll &x, ll y) {x = (x + y) % mod;}

int main() {
    string str; cin >> str;
    ll N = str.size();
    ll K; cin >> K;
    vector<ll> S(N);
    rep(i,N) S[i] = to_num(str[i]);

    ll bit = 1<<S[0];
    dp[0][0][1] = 1LL;
    dp[0][1][1] = S[0] - 1;
    for (ll i=1; i<N; i++) {
        ll from = bitcnt(bit);
        bit |= 1<<S[i];
        ll now = bitcnt(bit);
        dp[i][0][now] = 1;
        for (ll j=1; j<=d; j++) {
            addmodp(dp[i][1][j], dp[i-1][1][j] * j % mod);
            addmodp(dp[i][1][j], dp[i-1][1][j-1] * (d-j+1) % mod);
        }
        rep(j,S[i]) {
            if ((bit>>j)&1) addmodp(dp[i][1][from],1LL);
            else addmodp(dp[i][1][from+1],1LL);
        }
        addmodp(dp[i][1][1],15);
    }

    ll ans = 0LL;
    rep(i,2) addmodp(ans,dp[N-1][i][K]);
    Cout(ans);
}

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
typedef long long ll;
const ll mod = 1e9 + 7;
string s;
int k, a[N], n;

int work(int x) {
    int ans = 0;
    while (x) {
        if (x & 1) ans++;
        x = x / 2;
    }
    return ans;
}

ll dp[N][20];

ll dfs(int p, int stat, int limit) {
    int cnt = work(stat);
   // cout << p << " " << cnt << " " << stat  << endl;
    if (cnt > k) return 0;
    if (p == n) {
        if (cnt == k) return 1;
        return 0;
    }
    if (!limit && dp[p][cnt] != -1) return dp[p][cnt];
    int maxn = 15;
    if (limit) {
        maxn = a[p];
    }
    ll ans = 0;
    for (int i = 0; i <= maxn; i++) {
        ans += dfs(p + 1, stat | (1 << i), limit && i == maxn);
        ans = ans % mod;
    }
    if (!limit) dp[p][cnt] = ans;
    return ans;

}

void solve() {
    ll ans = 0;
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; i++) {
        int maxn = 15;
        if (i == 0) {
            maxn = a[0];
        }
      //  cout << "Maxn " << maxn << endl;
        for (int j = 1; j <= maxn; j++) {

            ans += dfs(i + 1, (1 << j), i == 0 && j == maxn);
            ans = ans % mod;
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> s >> k;
    n = s.length();
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            a[i] = s[i] - '0';
        } else {
            a[i] = s[i] - 'A' + 10;
        }
    }
    solve();
}


#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
  x=0;char ch=getchar();bool f=0;
  for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') f=1;
  for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
  if(f) x=-x;
  return;
}
typedef long long ll;
typedef double db;
const int mod=998244353,G=3,phi=998244352;
int n;
const int N=5e5+10;
char s[N],t[N];
int main(){
  init(n);
  scanf("%s",s+1);
  scanf("%s",t+1);
  int h1=1,h2=1;
  int cnt=0;
  bool fl=0;
  while(h1<=n||h2<=n) {
    while(h1<=n&&s[h1]!='0') ++h1;
    while(h2<=n&&t[h2]!='0') ++h2;
    if(h1<=n&&h2<=n) {
      if(h1!=h2) ++cnt;
      ++h1,++h2;
    }else if(h1>n&&h2>n);
    else {fl=1;break;}
  }
  if(fl) puts("-1");
  else printf("%d\n",cnt);
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const int MAXN = 300005;
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;

vector<int> v[2];

inline void solve()
{
    int n;  cin >> n;
    string S,T; cin >> S >> T;
    S = " " + S,T = " " + T;

    for (int i=1;i<=n;i++)
        if (S[i] == '0')
            v[0].push_back(i);
    for (int i=1;i<=n;i++)
        if (T[i] == '0')
            v[1].push_back(i);

    if (v[0].size() != v[1].size())
        cout << "-1\n";
    else
    {
        int ed = v[0].size() - 1;
        int cnt = 0;
        for (int i=0;i<=ed;i++)
            if (v[0][i] != v[1][i])
                cnt++;
        cout << cnt << "\n";
    }
    return ;
}

int main()
{closeSync;
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
template <class T>
bool chmax(T& a, const T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (int i = (r)-1; (l) <= i; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define CIN(c) cin >> (c)
#define COUT(c) cout << (c) << '\n'
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<ll, ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = (1 << 30) - 1; // 1073741824 - 1
// static const ll INF = (1LL << 60) - 1;  // 4611686018427387904 - 1

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int n, w;
    cin >> n >> w;
    COUT(n / w);
}

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

int main()
{
  int64_t N, K;
  cin >> N >> K;
  if(K < 0) K = -K;

  int64_t X, Y;
  int64_t countx, county;
  int64_t count = 0;

  for(int i = 2 * N - K - 1; i > 0; i--)
  {
    X = 2 * N - (2 * N - K - 1 - i);
    Y = X - K;
    if(N < X - 1) countx = X - 1 - (2 * (X - 1) - 2 * N);
    else countx = X - 1;
    if(N < Y - 1) county = Y - 1 - (2 * (Y - 1) - 2 * N);
    else county = Y - 1;
    count += countx * county;
  }

  cout << count << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 250005
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define __ template<typename T, typename... Types>
void in() {rt;} __ void in(T &a, Types&... b){cin>>(a); in(b...);}
void o() {rt;}  __ void o(T a, Types... b){cout<<(a);sp; o(b...);}
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
int main()
{
    fast;
    in(n);
    fr(i,0,n-1)in(ar[i]);
    partial_sum(ar,ar+n,br);
    fr(i,0,n-1)
    {
        m=max(m,c+x);
        c+=br[i];
        x=max(x,br[i]);
        m=max(m,c);
    }
    o(m);
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n;
    cin >> n;
    vll psum(n);
    for(int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        if(i > 0)
            psum[i] = x + psum[i - 1];
        else
            psum[i] = x;
    }

    ll a = 0;
    ll curr = 0;
    ll pospref = 0;
    for(int i = 0; i < n; i++) {
        pospref = max(pospref, psum[i]);
        if(curr + pospref > a) a = curr + pospref;
        curr += psum[i];
    }
    cout << a << endl;
    return 0;
}


#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; using ld = long double; using ll = long long;
using ull = unsigned long long;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define QUERY int num_query;cin>>num_query; while(num_query--)
int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1};
constexpr int INF=1<<30;
constexpr ll LINF=1LL<<60;
constexpr ll mod=1e9+7;
void flush() {cout<<flush;}
template<class T>vector<T> vec(int len, T elem) { return vector<T>(len, elem); } // auto dp = vec(52, vec(103, vec(103, INF)));
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcountll(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
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) {os << '\n'; for (auto v : vec) os << v << ' '; os << '\n'; return os;}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
struct MyIO {
    MyIO(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} IO_OI;
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
//-------------------
int main() {
    int a,b;cin>>a>>b;
    cout << (a+b)/2 << " " << (a-b)/2 << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int x = (a + b) / 2;
  int y = (a - b) / 2;

  cout << x << " " << y << endl;
  return 0;
}


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

int a, b, c, d, minim, maxim;

int main(){
    cin >> a >> b >> c >> d;
    minim = min(min(min(a , b), c), d);
    maxim = max(max(max(a , b), c), d);
    if((minim + maxim == a + b + c + d - minim - maxim) || (maxim == a + b + c + d - maxim))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

/**
 * Author: Daniel
 * Created Time: 2021-02-25 22:16:47
**/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define ER erase
#define IS insert
#define PI acos(-1)
#define PB pop_back
#define EB emplace_back
#define lowbit(x) (x & -x)
#define SZ(x) ((int)x.size())
#define MP(x, y) make_pair(x, y)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define SOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10)

typedef long long LL;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

template <typename A> using VE = vector<A>;
template <typename A> using USET = unordered_set<A>;
template <typename A> using HEAP = priority_queue<A>;
template <typename A, typename B> using PA = pair<A, B>;
template <typename A, typename B> using UMAP = unordered_map<A, B>;
template <typename A> using RHEAP = priority_queue<A, vector<A>, greater<A> >;

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

// check the limitation!!!
const int N = 100010, M = 1010;

int a[4];

// read the question carefully!!!
int main()
{
    SOS;

    int tot = 0;
    for (int i = 0; i < 4; i ++ )
    {
        cin >> a[i];
        tot += a[i];
    }
    sort(a, a + 4);
    do
    {
        int t = tot;
        int sum = 0;
        for (int i = 0; i < 4; i ++ )
        {
            sum += a[i];
            tot -= a[i];
            if (sum == tot)
            {
                cout << "Yes\n";
                return 0;
            }
        }
        tot = t;
    } while (next_permutation(a, a + 4));
    cout << "No\n";
    return 0;
}

// GOOD LUCK!!!


#define ll long long
#define dd long double
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define tll tuple<ll ,ll , ll >
#define pll pair<int ,int>
#include<bits/stdc++.h>
/*#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>*/
dd pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 10000;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n
ll seed;
mt19937 rnd(seed=chrono::steady_clock::now().time_since_epoch().count()); // include bits

void solve()
{
    ll n ;
    cin >> n ;
    ll arr[n+1] , ans = 1 ;
    arr[0] = 0 ;
    fo(i , n)
    {
        cin >> arr[i+1] ;
    }
    sort(arr , arr+n+1) ;
    for(ll i = 1 ; i <= n ; i++)
    {
        ans *= (arr[i] - arr[i-1] + 1) ;
        ans %= z ;
    }
    cout << ans << '\n' ;
    return ;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/

    ll t ;
    //cin >> t ;
    t = 1 ;

    //cout << arr[12] << ' ' << arr[32] << endl ;
    while(t--)
    {
        solve() ;
    }
   // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll mod = 1e9 + 7;
int n;
ll a[MAXN];
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sort(a + 1, a + 1 + n);
	ll ans = 1;
	for(int i = 1; i <= n; i++) ans = ans *(a[i] - a[i - 1] + 1) % mod;
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n), c(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < n;i++) cin >> b[i];
    for(int i = 0;i < n;i++){
        cin >> c[i];
        c[i]--;
    }
    long long bas[100001] = {0};
    for(int i = 0;i < n;i++) bas[a[i]]++;
    long long cnt = 0;
    for(int i = 0;i < n;i++)    cnt += bas[b[c[i]]];
    cout << cnt << endl;

}

// jay swaminarayan //
// UTSAV VASOYA //
#include <iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<cmath>
#include<string.h>
using namespace std;
#define int long long
#define pi (3.141592653589)
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
// All func
int fastpower(long a,long b,int n=1000000007){ long res=1; while(b>0){ if((b&1)!=0){ res = (res%n * a%n)%n ;} a = (a%n * a%n)%n; b=b>>1;} return res;}
int checkPrime(int n) { bool prime[n+1]; memset(prime, true, sizeof(prime)); for(int p=2; p*p<=n; p++) { if (prime[p] == true) { for (int i=p*p; i<=n; i += p) prime[i] = false; } } int cprime=0; for(int p=2; p<=n; p++) if(prime[p]) cprime++; return cprime;}
int gcd(int a, int b){  int c = a % b;  while(c != 0)  {    a = b;    b = c;    c = a % b;  }  return b;}
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

int32_t main(){
fast
// just chill chill just chill
    int n; cin >> n;
    int a[n],b[n],c[n];
    rep(i,n) cin >>a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    map<int,int>mp1;
    map<int,int>mp2;
    vector<int>v;
    rep(i,n){
        mp1[a[i]]++;
        mp2[b[i]]++;
        v.push_back(b[i]);
    }
    int ans=0;
    for(int i=0; i<n; i++){
        int m = b[c[i]-1];
        int p = mp1[m];
            int count = p;
            ans+=count;
        // mp1[m]=0;
        // mp2[m]=0;
    }
    cout << ans;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T,typename U>T & chmax(T &a,const U &b){if(a<b){a=b;} return a;}
template<typename T,typename U>T & chmin(T &a,const U &b){if(b<a){a=b;} return a;}

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

  ll H,W;
  cin>>H>>W;
  vector<vector<ll>> A(H,vector<ll>(W));
  cin>>A;
  ll mi=1e9;
  for(auto &I:A){for(auto &J:I){chmin(mi,J);}}
  ll sum=0;
  for(auto &I:A){for(auto &J:I){sum+=J-mi;}}
  cout<<sum<<endl;

  return 0;
}

#include <bits/stdc++.h>

using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
const ll mod = 1e9+7;
const ll MOD = 998244353;
const double PI=3.14159265358979323846;
const int INF = 1001001001;
//Write From this Line

// now += mint(2).pow(s) - 1; こんな感じで、2のs乗を求められrう
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main()
{
	int n, m;
	cin >>  n >> m;
	vector<int> a(n);
	rep(i,n) cin >>  a[i];
	ll sum = 0;
	rep(i,n){
		sum += a[i];
	}
	mint ans = 1;
	for(ll i = 0; i < sum+n; i++){
		ans *= (m+n-i);
		ans /= (i+1);
	}
	cout << ans << endl;

}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int res=0;
    char c;
    bool zf=0;
    while(((c=getchar())<'0'||c>'9')&&c!= '-');
    if(c=='-')zf=1;
    else res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
    if(zf)return -res;
    return res;
}
const int maxn=505;
int c[maxn][maxn];
int a[maxn],b[maxn];
signed main(){
	int n=read();
	for(register int i=1;i<=n;++i){
		for(register int j=1;j<=n;++j){
			c[i][j]=read();
		}
	}
	int p=0;
	for(register int i=1;i<=n;++i){
		if(!p||c[i][1]<c[p][1]){
			p=i;
		}
	}
	for(register int i=1;i<=n;++i){
		a[i]=c[i][1]-c[p][1];
	}
	for(register int i=1;i<=n;++i){
		b[i]=c[i][i]-a[i];
	}
	for(register int i=1;i<=n;++i){
		if(a[i]<0||b[i]<0){
			puts("No");
			return 0;
		}
	}
	for(register int i=1;i<=n;++i){
		for(register int j=1;j<=n;++j){
			if(a[i]+b[j]!=c[i][j]){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	for(register int i=1;i<=n;++i){
		printf("%d ",a[i]);
	}
	puts("");
	for(register int i=1;i<=n;++i){
		printf("%d ",b[i]);
	}
	puts("");
	return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include<map>
#define ll                   long long
#define skip                 cin>>ws;
#define vll                  vector<ll>
#define vb                   vector<bool>
#define vpll                 vector<pair<ll,ll>>
#define vi                   vector<int>
#define vpi                  vector<pair<int, int>>
#define vvll                 vector<vector<ll>>
#define vvi                  vector<vector<int>>
#define vvvll                vector<vector<vector<ll>>>
#define pll                  pair<ll,ll>
#define vs                   vector<string>
#define vvpll                vector<vector<pair<ll, ll>>>
#define vvpi                 vector<vector<pair<int, int>>>
#define pb                   push_back
#define pob                  pop_back()
#define MOD                  (ll)(1e9 + 7)
#define MOD2                 (ll)(998244353)
#define INF                  (ll)(1e18 + 5)
#define count1(n)            __builtin_popcountll(n)
#define test                 ll t; cin>>t; while(t--)
#define all(x)               begin(x), end(x)

using namespace std;

void inline show(vll &a){for(ll e: a){if(e == INF) cout<<"INF ";else cout<<e<<" ";}cout<<"\n";}
void inline show(vi &a){for(int e: a){if(e == MOD) cout<<"MOD ";else cout<<e<<" ";}cout<<"\n";}

template<typename T> void enter(vector<T> &a){ for(T &e: a) cin>>e; }

ll inline mo(ll a){ return a%MOD;}

ll inline po(ll x, ll y, ll p)
{
    ll res = 1; x = x % p;
    while (y > 0) { if (y & 1) res = (res * x) % p; y >>= 1; x = (x * x) % p; }
    return res%p;
}

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

    vll a(3);
    enter(a);

    sort(all(a));
    if(a[0] == a[1]) cout<<a[2]<<"\n";
    else if(a[2] == a[1]) cout<<a[0]<<"\n";
    else cout<<0<<"\n";

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll mod = 1e9+7;
const ll N = 1e5+2;

//My tools
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,s,e)  for(ll i=s;i<e;i++)
#define repe(i,s,e) for(ll i=s;i<=e;i++)
#define all(v)  (v).begin(),(v).end()

ll merge(int a[],int l,int r,int mid){
    int p,q,k=0;
    ll inv = 0;
    p = l,q = mid+1;
    int temp[r-l+1];
    for(int i=l;i<=r;i++){
        if(p>mid) temp[k++] = a[q++];
        else if(q>r) temp[k++] = a[p++];
        else if(a[p]<=a[q]) temp[k++] = a[p++];
        else if(a[p]>a[q]){
            inv+= (mid - p +1);
            temp[k++] = a[q++];
        }
    }

    for(int i=0;i<k;i++){
        a[l++] = temp[i];
    }
    return inv;
}

ll mergesort(int a[],int l,int r){
    ll inv = 0;
    if(r>l){
        int mid = (l + r)/2;
        inv+= mergesort(a,l,mid);
        inv+= mergesort(a,mid+1,r);
        inv+= merge(a,l,r,mid);
    }
    return inv;
}

main(){
    int n;cin>>n;
    int a[n],b[n];
    rep(i,0,n){
        cin>>a[i];
        b[i] = a[i];
    }
    ll inv = mergesort(a,0,n-1);
    cout<<inv<<"\n";
    rep(i,0,n-1){
        inv+= (n - 2*b[i] - 1);
        cout<<inv<<"\n";
    }
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> B(N+1,0);
    rep(i,N) B[i+1] = B[i] + A[i];

    ll ans = 0;
    ll ret = 0;
    ll bfmax = 0;
    rep(i,N) {
        bfmax = max(bfmax,B[i+1]);
        ans = max(ans,ret + bfmax);
        ret += B[i+1];
    }
    cout << ans << '\n';
    return 0;
}


#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<time.h>
#include<deque>
#include<cstring>
#define ll long long
#define DB double
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define pf push_front
#define MOD (ll)(998244353)
#define INF (ll)(1e9)
#define M 5000005
#define endl "\n"
#define AC ios::sync_with_stdio(0);cin.tie(0);
using namespace std;

template<class T> using PQ=priority_queue<T,vector<T>,greater<T> >;

int e[20],dp[(1<<19)];

signed main(){
    AC;
    int n,m;
    cin>>n>>m;
    FOR(i,0,m){
        int a,b;
        cin>>a>>b;
        a--; b--;
        e[a]|=(1<<b);
        e[b]|=(1<<a);
    }
    FOR(i,0,(1<<n)) dp[i]=INF;
    dp[0]=1;
    FOR(i,0,n)FOR(j,0,(1<<n)){
        if(dp[j]==1&&(e[i]&j)==j) dp[j|(1<<i)]=1;
    }
    FOR(i,1,(1<<n))for(int j=i-1;j&=i;j--){
        dp[i]=min(dp[i],dp[i^j]+dp[j]);
    }
    cout<<dp[(1<<n)-1]<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> A(K);
	REP(i, K) cin >> A[i];
	vector<bool> inA(N);
	for (int a : A) inA[a] = true;

	{
		int p = 0;
		while (p < N) {
			bool update = false;
			for (int i = M; i >= 1; --i) {
				if (p + i < N && inA[p + i]) continue;
				update = true;
				p += i;
				break;
			}
			if (!update) { puts("-1"); return 0; }
		}
	}

	vector<double> dp0(N + 1), dp(N + 1);
	double s0 = 0, s = 0;
	for (int i = N - 1; i >= 0; --i) {
		if (i + M + 1 <= N) { s0 -= dp0[i + M + 1] / M; s -= dp[i + M + 1] / M; }

		if (inA[i]) { dp0[i] = 1; dp[i] = 0; }
		else { dp0[i] = s0; dp[i] = s + 1; }

		s0 += dp0[i] / M;
		s += dp[i] / M;
	}

	double ans = dp[0] / (1 - dp0[0]);
	printf("%.16f\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define fz(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define ffe(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define fill0(a) memset(a,0,sizeof(a))
#define fill1(a) memset(a,-1,sizeof(a))
#define fillbig(a) memset(a,63,sizeof(a))
#define pb push_back
#define ppb pop_back
#define mp make_pair
template<typename T1,typename T2> void chkmin(T1 &x,T2 y){if(x>y) x=y;}
template<typename T1,typename T2> void chkmax(T1 &x,T2 y){if(x<y) x=y;}
typedef pair<int,int> pii;
typedef long long ll;
template<typename T> void read(T &x){
	x=0;char c=getchar();T neg=1;
	while(!isdigit(c)){if(c=='-') neg=-1;c=getchar();}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	x*=neg;
}
const int MAXN=1e5;
int n,hd[MAXN+5],to[MAXN+5],nxt[MAXN+5],ec=0,dp[MAXN+5],siz[MAXN+5];
void adde(int u,int v){to[++ec]=v;nxt[ec]=hd[u];hd[u]=ec;}
void dfs(int x){
	dp[x]=siz[x]=1;int cnt=0;
	for(int e=hd[x];e;e=nxt[e]){
		int y=to[e];dfs(y);
		if(siz[y]&1) cnt++;
		siz[x]+=siz[y];
	} vector<int> v;
	for(int e=hd[x];e;e=nxt[e]){
		int y=to[e];
		if(!(siz[y]&1)&&dp[y]<=0) dp[x]+=dp[y];
		else if(!(siz[y]&1)){
			if(!(cnt&1)) dp[x]+=dp[y];
			else dp[x]-=dp[y];
		}
		else v.pb(dp[y]);
	}
	sort(v.begin(),v.end());
	for(int i=0,t=1;i<v.size();i++,t=-t) dp[x]+=t*v[i];
//	printf("%d %d\n",x,dp[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int f;scanf("%d",&f);adde(f,i);
	} dfs(1);printf("%d\n",(n+dp[1])/2);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
const char newl = '\n';

vl S;
vvl G;

void dfs(ll v) {
  S[v] = 1;
  for(ll u: G[v]) {
    dfs(u);
    S[v] += S[u];
  }
}

ll cnt(ll v) {
  ll income = -1;
  vvl vec(3);
  for(ll u: G[v]) {
    ll num = cnt(u);
    if(S[u] & 1) vec[0].push_back(num);
    else if(num >= 0) vec[1].push_back(num);
    else vec[2].push_back(num);
  }

  sort(all(vec[0]), greater<ll>());

  bool f = 0;
  for(ll num: vec[0]) income += ((f = 1-f) ? 1 : -1) * num;
  for(ll num: vec[1]) income += num;
  for(ll num: vec[2]) income += ((vec[0].size() & 1) ? -1 : 1) * num;

  return income;
}

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

  ll n, p;
  cin >> n;
  S = vl(n);
  G = vvl(n);
  rep2(i, 1, n-1) {
    cin >> p;
    p--;
    G[p].push_back(i);
  }

  dfs(0);

  cout << (n-cnt(0))/2 << newl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%2==1)cout<<"Black";
  else cout<<"White";
}

#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  if(n%2==0)cout<<"White"<<endl;
  else cout<<"Black"<<endl;
  return 0;
}


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

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

#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds;
		//order_of_key (k) : Number of items strictly smaller than k .
		//find_by_order(k) : K-th element in a set (counting from zero) (returns an iterator)

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

bool isPalindrome(string s)
{
  int i,j;
  for(i=0,j=s.length()-1;i<=j;i++,j--)
    if(s[i]!=s[j])
        return 0;
  return 1;
}

int32_t main()
{
	fastIO
	inp_out();
	int r, x, y;
	cin >> r >> x >> y;
	ld val = sqrt((ld)(x * x + y * y));

	if(val < r)
		val = 2;
	else
		val = ceil(val / r);

	cout << val;
	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(){
    ll r,x,y; cin >> r >> x >> y;
    ll l = x*x + y*y;
    int ans;
    for(ll ix=1;;ix++){
        if(l < r*r){
            ans = 2;
            break;
        }
        else if(l <= ix*ix*r*r){
            ans = ix;
            break;
        }
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int h[1000001];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b||c==0)
    {
        cout<<"=";
        return 0;
    }
    if(c%2)
    {
        if(a>b)
        {
            cout<<">";
            return 0;
        }
        else
        {
            cout<<"<";
            return 0;
        }
    }
    else
    {
        a=abs(a);
        b=abs(b);
        if(a==b)
        {
            cout<<"=";
            return 0;
        }
        if(a>b)
        {
            cout<<">";
            return 0;
        }
        else
        {
            cout<<"<";
            return 0;
        }
    }
}

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

const int N = 2000 + 5, mod = 1e9 + 7;

ll a, b, c, d;

bool check1(int a, int b, int c, int d){
    if(a + b == c + d) return 1;
    if(a - b == c - d) return 1;
    if(abs(a - c) + abs(b - d) <= 3) return 1;
    return 0;
}

bool check2(ll a, ll b, ll c, ll d){
    for(int i = a - 3; i <= a + 3; i++){
        for(int j = b - 3; j <= b + 3 ; j++){
            if(abs(i - a) + abs(j - b) > 3) continue;
            if(check1(i, j, c, d)) return 1;
        }
    }
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> a >> b >> c >> d;
    if(a == c && b == d) cout << 0;
    else if(check1(a, b, c, d)) cout << 1;
    else if(((a + b + c - d) & 1) == 0) cout << 2;
    else if(((c + d + a - b) & 1) == 0) cout << 2;
    else if(check2(a, b, c, d)) cout << 2;
    else cout << 3;

    return 0;

}


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

int main() {
  long N, A, m, b = 0, c = 0;
  cin >> N;
  m = N;

  while (m) {
    m--;
    cin >> A;
    b += A;
    c += A * A;
  }

  cout << N * c - b * b << endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define len(a) (int)a.size()
#define all(a) a.begin(), a.end()

const int INF32 = 1 << 30;
const long long INF64 = 1LL << 60;
const double PI = acos(-1);

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

    int n = len(N);
    int p = 2;
    ll ans = 0;
    while (1) {
        if (p > n) {
            break;
        }
        else if (p < n) {
            ans += pow(10, p / 2) - pow(10, p / 2 - 1);
        }
        else {
            ll i1 = stoll(N.substr(0, p / 2));
            ll i2 = stoll(N.substr(p / 2));
            ll i0 = pow(10, p / 2 - 1);
            ans += i1 - i0;
            if (i2 >= i1) ans++;
        }
        p += 2;
    }
    cout << ans << endl;

}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);cerr<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T> void verr(const set<T> &st) { repa(a, st) cerr << a << " "; cerr << endl; }
template <class S, class T> void verr(const map<S, T> &mp) { repa(a, mp) cerr << "{" << a.first << ", " << a.second << "} "; cerr << endl; }
template <class S, class T, class N> void verr(const vector<pair<S,T>>& a, const N& n) { rep(i, n) cerr << "{" << a[i].first << ", " << a[i].second << "} "; cerr << endl; }
template <class T, class N> void verr(const vector<T>& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << endl; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << endl; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-5;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    vc<complex<ld>> S(N), T(N);
    rep(i, N) {
        ld a, b;
        cin >> a >> b;
        S[i] = {a, b};
    }
    rep(i, N) {
        ld a, b;
        cin >> a >> b;
        T[i] = {a, b};
    }

    complex<ld> sc(0, 0), tc(0, 0);
    rep(i, N) sc += S[i], tc += T[i];
    sc /= N, tc /= N;

    rep(i, N){
        S[i] -= sc;
        T[i] -= tc;
    }
    rep(i, N) rep(j, N){
        vc<complex<ld>> ss(N), tt(N);
        rep(si, N) ss[si] = S[si] * polar(1.0L, -arg(S[i]));
        rep(ti, N) tt[ti] = T[ti] * polar(1.0L, -arg(T[j]));

        bool ok = true;
        rep(si, N) {
            bool isok = false;
            rep(ti, N){
                if (abs(ss[si] - tt[ti]) < EPS) isok = true;
            }
            if(!isok){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     vi          vector<int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

vi p;
ll mini=1e18;
int n,x[N];

void rec(int i,ll pr){
    if(i==p.size()){
        int ok=1;
        rep(j,1,n) if(__gcd(pr,1ll*x[j])==1){
            ok=0;
            break;
        }
        if(ok) mini=min(mini,pr);
        return;
    }
    rec(i+1,pr);
    rec(i+1,pr*p[i]);
}

signed main(){
    FastIO;
    rep(j,2,50){
        int ok=1;
        rep(i,2,j-1) if(j%i==0) ok=0;
        if(ok) p.pb(j);
    }
    cin>>n;
    rep(i,1,n) cin>>x[i];
    rec(0,1);
    cout<<mini;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define MS(a, b) memset(a, b, sizeof(a))
#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define EREP(a, b) for (register int a = head[b]; a; a = edge[a].nxt)
#define ll long long

inline int rd () {
    int x = 0; char c = getchar(); bool f = 0;
    while (c < '0' && c != '-') c = getchar();
    if (c == '-') f = 1, c = getchar();
    while (c >= '0') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    return f ? -x : x;
}

const int SIZE = 2e5 + 100;

int n;
int a[SIZE], b[SIZE];
int x[SIZE], y[SIZE];

struct cmp1 {
    bool operator () (const int& x1, const int& x2) const {
        if (a[x1] == a[x2]) return x1 < x2;
        return a[x1] < a[x2];
    }
};
struct cmp2 {
    bool operator () (const int& x1, const int& x2) const {
        if (b[x1] == b[x2]) return x1 < x2;
        return b[x1] < b[x2];
    }
};

int sum[SIZE];
void Add (int x) {
    while (x <= n) {
        ++sum[x];
        x += x & -x;
    }
}
int Sum (int x) {
    int res = 0;
    while (x) {
        res += sum[x];
        x -= x & -x;
    }
    return res;
}

void _main () {
    n = rd();
    REP (i, 1, n) a[i] = rd() + i, x[i] = i;
    REP (i, 1, n) b[i] = rd() + i, y[i] = i;
    sort(x + 1, x + n + 1, cmp1());
    sort(y + 1, y + n + 1, cmp2());

    bool flag = 1;
    ll ans = 0;
    REP (i, 1, n) {
        if (a[x[i]] != b[y[i]]) flag = 0;
        a[x[i]] = y[i];
    }
    DREP (i, n, 1) {
        ans += Sum(a[i]);
        Add(a[i]);
    }
    if (flag) printf ("%lld\n", ans);
    else puts("-1");
}

int main () {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    _main();
    return 0;
}

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-9;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

template<typename T> struct BIT{
    vector<T> dat;
    ll sz;
    //all 1-indexed
    BIT(ll sz) : sz(sz){
        dat.assign(++sz, 0);
    }

    T sum(ll k){
        T ret = 0;
        for(++k; k > 0; k -= k & -k) ret += dat[k];
        return (ret);
    }

    void add(ll k, T x){
        for(++k; k < dat.size(); k += k & -k) dat[k] += x;
    }

    ll get(T k){
        if(k <= 0) return 0;
        ll ret = 0;
        int n = 1; while(n < sz) n *= 2;
        for(int i=n/2; i>0; i/=2){
            if(ret+i < sz && dat[ret+i] < k){
                k -= dat[ret+i];
                ret += i;
            }
        }
        return ret;
    }
};

int main(){
    int n; cin >> n;
    map<int,vector<int>> mp;
    vl a(n);
    rep(i,n){
        int b; cin >> b;
        b += i;
        mp[b].push_back(i);
    }
    rep(i,n){
        cin >> a[i];
        a[i] += i;
    }
    for(auto &x : mp) reverse(all(x.second));
    ll ans = 0;
    BIT<ll> bit(n+1);
    //8 6 6 10 8 10
    //10 6 8 10 8 6
    rep(i,n){
        if(mp[a[i]].empty()){
            ans = -1;
            break;
        }
        ll ba = mp[a[i]].back();
        mp[a[i]].pop_back();
        ans += max(0LL, ba-i + bit.sum(n) - bit.sum(ba));
        //debug(ba,ans,a[i],i,bit.sum(n)-bit.sum(i));
        bit.add(ba,1);
    }
    cout << ans << endl;
    //4 6 8 6 5
    //5 8 6 6 4
    //5 4 6 8 6
    //5 8 4 6 6
    //5 8 6 4 6
    //5 8 6 6 4
}


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

int main() {
	// your code goes here
	int n;
	cin >> n;
	string s[n];
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin >> s[i] >> a[i];
		b[i]=a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(b[i]==a[n-2]){
			cout << s[i] << endl;
		}
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main() {
	int n;
	cin >> n;
	int mx = -1;
	int prev = -1;
	map<int, string> m;
	while(n--) {
		string s;
		int temp;
		cin >> s ;
		cin >> temp;
		m[temp] = s;
		if(mx<temp){
			prev = mx;
			mx = temp;
		}

		else if(temp < mx && temp > prev)
			prev = temp;
	}

	cout << m[prev];

	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	long long int n,d,h,i,j,k,a[200],b[200];
	double s=0;
	cin>>n>>d>>h;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	double	x=d-a[i];
	double	y=h-b[i];
	double m=y/x;
	double k=m*(-1)*d+h;
	s=max(s,k);
	}
	if(s==0)cout<<"0.0"<<endl;
	else
	printf("%.13lf\n",s);

}

#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
static long IN(void)
{
  long x=0,f=1,c=getchar();while(c<48||c>57){if(c==45){f=-f;}c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f*x;
}
static void OUT(int x){if(x<0){putchar('-'),x=-x;}if(x>=10){OUT(x/10);}putchar(x-x/10*10+48);}
int Nx[1000000],Ls[200001],To[1000000],pos=1;long pow2[61],b[61][2],dat[1000000];
static void Set(int x,int y,long z){Nx[++pos]=Ls[x];Ls[x]=pos;To[pos]=y;dat[pos]=z;}
static void DG(int x,int fa,long w)
{
  rep(i,61){b[i][(w&pow2[i])>0?1:0]++;}
  for(int i=Ls[x];i;i=Nx[i]){int y=To[i];if(y==fa){continue;}DG(y,x,w^dat[i]);}
}
int main(void)
{
  int N=IN(),x=0,y=0,a=0;long z=0;pow2[0]=1l;
  rep(i,60){pow2[i+1]=2*pow2[i];}N--;
  while(N--){x=IN(),y=IN(),z=IN();Set(x,y,z);Set(y,x,z);}
  DG(1,0,0);
  rep(i,61)
  {
    z=pow2[i]-pow2[i]/MOD*MOD;z=z*b[i][0]-z*b[i][0]/MOD*MOD;
    z=z*b[i][1]-z*b[i][1]/MOD*MOD;z+=a;if(z+1l>1l*MOD){z-=MOD;}a=z;
  }
  OUT(a);
}


#include <bits/stdc++.h>
#define clog(x) std::clog << (#x) << " is " << (x) << '\n';
using LL = long long;
constexpr int M = 1e9 + 7;

int main() {
	//freopen("in", "r", stdin);
	std::cin.tie(nullptr)->sync_with_stdio(false);
	int n;
	std::cin >> n;
	std::vector<LL> a(n + 1);
	for (int i = 1; i <= n; ++i) {
		std::cin >> a[i];
		a[i] += a[i - 1];
	}
	auto add = [&](int &x, int y) {
		x += y;
		if (x >= M) x -= M;
	};
	std::vector<std::vector<int>> dp(n + 1, std::vector<int>(n + 2));
	dp[0][1] = 1;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = n; j >= 1; --j) {
			add(dp[a[i] % (j + 1)][j + 1], dp[a[i] % j][j]);
			if (i == n) {
				add(ans, dp[a[n] % j][j]);
			}
		}
	}
	std::cout << ans << '\n';
	return 0;
}

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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
vector<ll> A[3];
string C[201010];

void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    FOR(i,2*N) {
        ll B;
        cin>>B>>s;
        if(s=="R") A[0].push_back(B);
        if(s=="G") A[1].push_back(B);
        if(s=="B") A[2].push_back(B);
    }
    sort(ALL(A[0]));
    sort(ALL(A[1]));
    sort(ALL(A[2]));

    if(A[0].size()%2) {
        if(A[1].size()%2==0) swap(A[0],A[1]);
        else swap(A[0],A[2]);
    }
    if(A[1].size()%2==0) {
        cout<<0<<endl;
        return;
    }
    ll mi=1LL<<60;
    FORR(a,A[1]) {
        x=lower_bound(ALL(A[2]),a)-A[2].begin();
        if(x<A[2].size()) mi=min(mi,abs(A[2][x]-a));
        x--;
        if(x>=0) mi=min(mi,abs(A[2][x]-a));
    }
    ll mia=1LL<<60,mib=1LL<<60;
    FORR(a,A[1]) {
        x=lower_bound(ALL(A[0]),a)-A[0].begin();
        if(x<A[0].size()) mia=min(mia,abs(A[0][x]-a));
        x--;
        if(x>=0) mia=min(mia,abs(A[0][x]-a));
    }
    FORR(a,A[2]) {
        x=lower_bound(ALL(A[0]),a)-A[0].begin();
        if(x<A[0].size()) mib=min(mib,abs(A[0][x]-a));
        x--;
        if(x>=0) mib=min(mib,abs(A[0][x]-a));
    }

    // cout<<mia<<" "<<mib<<"\n";

    cout<<min(mi,mia+mib)<<endl;

}

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
    FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    cout.tie(0); solve(); return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int a[400005];
int f[400005];
pair<int,int> p[400005];
int c[3];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=2*n;i++)
        p[i]=make_pair(a[i],i);
    sort(p+1,p+2*n+1);
    for(int i=1;i<=2*n;i++)
        if(i<=n)
            f[p[i].second]=1;
        else f[p[i].second]=2;
    for(int i=1;i<=2*n;i++)
        if(!c[3-f[i]])
        {
            printf("(");
            c[f[i]]++;
        }
        else
        {
            printf(")");
            c[3-f[i]]--;
        }
    printf("\n");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long int tab[200007];

int main()
{
    long long int i, n, k=0, w=0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> tab[i];
        tab[i]%=200;
    }
    sort(tab, tab+n);
    for(i=1; i<n; i++){
        if(tab[i]==tab[i-1]){
            k++;
        }
        else{
            k=0;
        }
        w+=k;
    }
    cout << w << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

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

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

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

struct vec3 {
    ll x;
    ll y;
    ll z;
};

ll S[20][1LL << 18];

ll cost(vec3 from, vec3 to) {
    ll ret = abs(to.x - from.x) + abs(to.y - from.y) + std::max(0LL, to.z - from.z);
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<vec3> v(N);
    REP(i, N) {
        cin >> v[i].x >> v[i].y >> v[i].z;
    }

    ll p = pow(2LL, N);
    REP(i, N) {
        REP(j, p) {
            S[i][j] = INF;
        }
    }

    S[0][1] = 0;
    REP(i, p) {
        REP(j, N) {
            if (((i >> j) & 1) == 0)
                continue;

            ll b = (i & (~(1LL << j)));
            REP(k, N) {
                if (((b >> k) & 1) == 0)
                    continue;
                ll cst = cost(v[k], v[j]) + S[k][b];
                S[j][i] = std::min(S[j][i], cst);
            }
        }
    }

    ll ans = INF;
    REP(i, N) {
        ans = std::min(ans, S[i][p - 1] + cost(v[i], v[0]));
    }
    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
using namespace std;

//#define DEBUG
#ifdef DEBUG
template<typename ...Args>
int debug(const Args &...args){
	return fprintf(stderr,args...);
}
#else
#define debug(...) void()
#endif

typedef unsigned long long ull;
typedef unsigned uint;
typedef long long ll;
#define G getchar()
int read()
{
	int x=0; bool flg=false; char ch=G;
	for (;!isdigit(ch);ch=G) if (ch=='-') flg=true;
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return flg?-x:x;
}
#undef G
#define fi first
#define se second

const int mod=998244353;
inline int upd(const int &x){return x+(x>>31&mod);}
inline void add(int &x,const int &y){x=upd(x+y-mod);}
inline void iadd(int &x,const int &y){x=upd(x-y);}
int qpow(int x,int y){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1) res=1LL*res*x%mod;
	return res;
}

//typedef pair<int,int> P;
#define rep(i,l,r) for (int i(l),_##i(r);i<=_##i;i++)
#define per(i,l,r) for (int i(r),_##i(l);i>=_##i;i--)
#define all(x) (x).begin(),(x).end()
#define forall(x,y) for (const int &y: e[x])

int n,w[110];
int dp[110][10010];

void solve(){
	n=read(); int S=0;
	rep(i,1,n) w[i]=read(),S+=w[i];
	if (S&1) return puts("0"),void();
	auto F=dp;
	F[0][0]=1;
	rep(_,1,n){
		const int &W=w[_];
		per(i,0,n){
			rep(j,0,n*100){
				if (i<n&&j+W<=n*100);
				else continue;
				add(F[i+1][j+W],F[i][j]);
			}
		}
	}
	static int fac[110];
	fac[0]=1; rep(i,1,n) fac[i]=1LL*fac[i-1]*i%mod;
	int z=0;
	rep(i,0,n) add(z,1LL*F[i][S>>1]*fac[i]%mod*fac[n-i]%mod);
	printf("%d\n",z);
}

int main()
{
	for (int T=1;T--;) solve();
	return 0;
}


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

const int N = 210, M = 810;

int h[N], e[M], ne[M], w[M], idx;
int a, b, x, y;
bool st[N];
int d[N];

void add(int a, int b, int c) {
    e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void spfa(int a) {
    memset(d, 0x3f, sizeof d);
    queue<int> q;
    q.push(a);
    st[a] = true;
    d[a] = 0;

    while (q.size()) {
        int t = q.front();
        q.pop();
        st[t] = false;

        for (int i = h[t]; ~i; i = ne[i]) {
            int j = e[i];
            if (d[j] > d[t] + w[i]) {
                d[j] = d[t] + w[i];
                if (!st[j]) {
                    q.push(j);
                    st[j] = true;
                }
            }
        }
    }
}

int main() {
    cin >> a >> b >> x >> y;
    memset(h, -1, sizeof h);
    int n = 100;
    for (int i = 1; i < n; i++) add(i, i + 1, y), add(i + 1, i, y);
    for (int i = 1 + n; i < n + n; i++) add(i, i + 1, y), add(i + 1, i, y);
    for (int i = 1; i <= n; i++) add(i, i + n, x), add(i + n, i, x);
    for (int i = 2; i <= n; i++) add(i, i + n - 1, x), add(i + n - 1, i, x);

    spfa(a);

    cout << d[b + n] << endl;

    return 0;
}

//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int>
#define all(v)          v.begin(),v.end()
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int a,b,c;
    cin>>a>>b>>c;
    if((a*a+b*b)<(c*c)) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}


#include <iostream>
using namespace std;

int main(void) {
    int x;
    cin >> x;
    if (x < 0) cout << 0 << endl;
    else cout << x << endl;
    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    n=floor(n*1.08);
    if(n<206)cout<<"Yay!";
    else if(n==206)cout<<"so-so";
    else cout<<":(";
    return 0;
}


#include <iostream>
using namespace std;
int main() {

int x ,y ;
cin >> x >> y ;

if (x != y){
  if (x < y){
    if (x+3 > y){
      cout<< "Yes"<<endl;
    } else if (x+3 <= y){
      cout << "No" <<endl;
    }
  }
  else if(y < x){
    if (y+3 > x){
      cout<< "Yes"<<endl;
    } else if (y+3 <= x){
      cout << "No" <<endl;
    }
  }
}

}

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

int main(){
  int X,Y; cin>>X>>Y;
  if(abs(X-Y)<=2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define Mp make_pair
#define e "\n"
#define fl(x,n) for(ll i=x;i<=n;i++)
#define fl2(x,n) for(ll i=x;i>=n;i--)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
template<class X>
void temfunc(const X a)
{
    for(auto it=a.begin();it!=a.end();it++)
        cout << *it << " ";
    cout << e;
}

int main()
{
    FIO;
    int a,b,c;
    cin  >> a >> b >> c;
    if(c-b==b-a||c-a==a-b||a-c==c-b||b-c==c-a||a-b==b-c||b-a==a-c)
        cout << "Yes\n";
    else
    {
        cout << "No\n";
    }
    return 0;
}

#include<bits/stdc++.h>
#include<unordered_map>
#define sz(s) (int)s.size()
#define all(s) s.begin(),s.end()
using namespace std;
typedef long long ll;
void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
void Men7a()
{
	double r, x, y,d;
	int ans;
	cin >> r >> x >> y;
	d = sqrt((x*x)+(y*y));
	if (d - int(d))
	    d++;
	ans = int(d) / int(r);
	if(int(d) % int(r))
		ans++;
	if(d!=r && ans==1)
	    ans++;
	cout << ans << "\n";
}
int main()
{
	fast();
	int test_case = 1;
	//freopen("","r",stdin);
	//cin >> test_case;
	while (test_case--)
		Men7a();
}