#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<cstdlib>
#include<utility>
using namespace std;
const int mod=1e9+7;
int a[100000+5];
int main()
{
    int n,i,ans=1;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for (i=n;i>=2;i--)
        a[i]-=a[i-1];
    for (i=1;i<=n;i++)
        ans=1ll*ans*(a[i]+1)%mod;
    printf("%d\n",ans);
}

#include <bits/stdc++.h>
#define pb push_back
#define sz size()
#define all(c) (c).begin(), (c).end()

using namespace std;

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

const int MOD = 1e9 + 7;
const int maxn = 2e5 + 7;
int cnt[200];
vector<int> g[200];
void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i < n; i++)a[i] %= 200;
    int s = min(8, n);
    for(int mask = 0; mask < (1 << s); mask++){
        int rem = 0;
        vector<int> e;
        for(int bit = 0; bit < s; bit++){
            if(mask & (1 << bit)){
                rem = (rem + a[bit]) % 200;
                e.pb(bit + 1);
            }
        }
        if(g[rem].sz != 0){
            cout << "YES\n";
            cout << e.sz << ' ';
            for(int i : e)cout << i << ' ';
            cout << '\n';
            cout << g[rem].sz << ' ';
            for(int i : g[rem])cout << i << ' ';
            return;
        } else{
            g[rem] = e;
        }
    }
    cout << "NO\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


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

int main(){
    string X;
    long long M;

    cin >> X >> M;
    int d = (*max_element(X.begin(), X.end())) - '0';

    if(X.size() == 1){
        if(atoi(X.c_str()) <= M)cout << "1\n";
        else cout << "0\n";

        return 0;
    }

    auto ok = [&](long long base){
        long long power = 1, total = 0;
        for(int i = (int)X.size() - 1; i >= 0; i--){
            long long cur;
            if((X[i] - '0') > M / power)cur = M + 1;
            else cur = (X[i] - '0') * power;

            total = min(M + 1, total + cur);

            if(power > M / base)power = M + 1;
            else power = power * base;
        }

        if(total <= M)return true;
        else return false;
    };

    if(!ok(d + 1)){
        cout << "0\n";
        return 0;
    }

    long long L = d + 1, R = M;
    while(L < R){
        long long mid = (L + R + 1) / 2;
        if(ok(mid))L = mid;
        else R = mid - 1;
    }
    cout << L - d << '\n';

    return 0;
}

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
char X[70];
long long M;
int main(){
  int i;
  long long res = 0;
  long long d;
  long long mx;
  long long b;
  __int128_t val;
  N = rd(X);
  rd(M);
  for(i=(0);i<(N);i++){
    X[i] -= '0';
  }
  int Q5VJL1cS;
  char e98WHCEY;
  if(N==0){
    e98WHCEY = 0;
  }
  else{
    e98WHCEY = X[0];
    for(Q5VJL1cS=(1);Q5VJL1cS<(N);Q5VJL1cS++){
      e98WHCEY = max_L(e98WHCEY, X[Q5VJL1cS]);
    }
  }
  d =e98WHCEY;
  if(N==1){
    if(X[0] <= M){
      res++;
    }
    wt_L(res);
    wt_L('\n');
    return 0;
  }
  long long FmcKpFmN;
  long long xr20shxY;
  long long WYIGIcGE;
  FmcKpFmN = d;
  xr20shxY = 1e18;
  while(FmcKpFmN < xr20shxY){
    if((FmcKpFmN + xr20shxY)%2==0){
      WYIGIcGE = (FmcKpFmN + xr20shxY) / 2;
    }
    else{
      WYIGIcGE = (FmcKpFmN + xr20shxY + 1) / 2;
    }
    val = 0;
    for(i=(0);i<(N);i++){
      val = val * WYIGIcGE + X[i];
      if(val > M){
        break;
      }
    }
    if(val <= M){
      FmcKpFmN = WYIGIcGE;
    }
    else{
      xr20shxY = WYIGIcGE - 1;
    }
  }
  b =xr20shxY;
  res = b - d;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay version 20210103-1 [bug fixed 4]

// --- original code ---
// int N; char X[70];
// ll M;
// {
//   ll res = 0, d, mx, b;
//   __int128_t val;
//   rd(X@N,M);
//   rep(i,N) X[i] -= '0';
//   d = max(X(N));
//
//   if(N==1){
//     if(X[0] <= M) res++;
//     wt(res);
//     return 0;
//   }
//   // if(N==2){
//   //   res = (M - X[1]) / X[0] - d;
//   //   res >?= 0;
//   //   wt(res);
//   //   return 0;
//   // }
//   b = bsearch_max[ll,b,d,1e18][
//     val = 0;
//     rep(i,N){
//       val = val * b + X[i];
//       if(val > M) break;
//     }
//   ](val <= M);
//   res = b - d;
//   wt(res);
// }


#include <bits/stdc++.h>

using namespace std;

#ifdef __local_leywar
#include <debug/debugger.h>
#endif

#define int long long
#define endl '\n'

const int INF = 2e9,
		  MOD = 1e9+7,
		  INFLL = 1e18;

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

	int n;
	cin >> n;

	int cnt = 3;
	cout << 6 << ' ' << 10 << ' ' << 15 << ' ' ;

	for(int i = 1 ; i <= 10000 and cnt < n ; i++)
	{
		if((i % 6 == 0 or i % 10 == 0 or i % 15 == 0) and (i != 6 and i != 10 and i != 15))
		{
			cout << i << ' ' ;
			cnt++;
		}
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
using ll = long long;
const ll INF = 1LL << 30;
using pll = pair<string, ll>;
using Graph = vector<vector<int>>;
int main() {
  int N;
  cin >> N;
  if(N == 3) {
    cout << 6 << " " << 10 << " " << 15 << endl;
    return 0;
  }
  vector<int> S(16);
  S = {6, 10, 12, 15, 18, 20, 24, 30, 36, 40, 42, 45, 48, 50, 54, 60};
  rep(i, N) {
    cout << S[i%16] << " ";
    S[i%16] += 60;
  }
  cout << endl;
}


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

#define int int64_t
#define MOD 998244353
#define inf 9e18
#define tikoo (int) (1e9 + 7)
#define amat(mat, n, m, val) mat.assign(n, vector<int>(m, val))
#define mmat(mat, n, m, val) vector<vector<int>> mat(n, vector<int>(m, val))
#define _mul(a, b) ((a % tikoo) * (b % tikoo)) % tikoo
#define _add(a, b) ((a % tikoo) + (b % tikoo)) % tikoo
#define _sub(a, b) (((a % tikoo) - (b % tikoo)) % tikoo + tikoo) % tikoo
#define _all(a) a.begin(), a.end()
#define print(a) for (auto i : a) cout << i << " "; cout << endl;
#define take(x) int x; cin >> x;

double logn(int n, int base) { return log2(n) / log2(base); }
template<typename T, typename T1> T max(T a, T1 b) { if (b > a) a = b; return a; }
template<typename T, typename T1> T min(T a, T1 b) { if (b < a) a = b; return a; }
int fastpow(int a, int b, int m = tikoo) { int res = 1; a %= m;
    while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res; }

void go() {
    ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

signed main() {
    go();
    int t = 1;
    // cin >> t;
    while (t--) {
        take(n);
        map<int, int> a;
        for (int i = 0; i < n; i++) {
            take(x); a[x]++;
        }
        vector<int> b(n);
        for (int i = 0; i < n; i++) {
            cin >> b[i];
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            take(x); x--;
            ans += a[b[x]];
        }
        cout << ans << "\n";
    }
    return 0;
}

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

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

#define all(x) x.begin(), x.end()

using namespace std;
//using namespace atcoder;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  rep(i, n) cin >> c.at(i);
  vector<int> bc(n, -1);
  rep(i, n) {
    bc.at(i) = b.at(c.at(i) - 1);
  }
  vector<int> cnt(n, 0);
  rep(i, n) {
    cnt.at(bc.at(i) - 1)++;
  }
  ll res = 0;
  rep(i, n) {
    res += cnt.at(a.at(i) - 1);
  }
  cout << res << endl;
  return 0;
}


// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
//

#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#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 ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;

    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
int binomialCoeff(int n,int k)
{
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=min(i,k);j>0;j--)
        dp[j]=(dp[j]+dp[j-1])%mod;
    }
    return dp[k]%mod;

}
void c_p_c()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void solve()
{
    int a,b;
    cin >> a >> b;
    cout << (a * b * 1.0) / (100 * 1.0) << endl;
}
signed main()
{
    crap;
    int t=1;;
    //cin>>t;
    for(int o=1;o<=t;o++)
    {
        solve();
    }
}

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

#define int             long long int
#define double          long double
#define endl            '\n'
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define si              set<int>
#define usi             unordered_set<int>
#define all(x)          x.begin(),x.end()
#define setbits(x)      __builtin_popcountll(x)
#define dig(x,y)        fixed<<setprecision(y)<<x
#define trace(x) 	cerr<<#x<<": "<<x<<" "<<endl;
#define fio             ios_base::sync_with_stdio(false);cin.tie(NULL);

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

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

void solve()
{
    int a,b;
    cin>>a>>b;
    double ans = a*b*1.0 / 100;
    cout<<ans;
}

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


#include <bits/stdc++.h>
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
typedef double DB;
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
// head
const int N=1e3+5;
VPII g[N];
int n,m;
bool st[N][N];
struct R {
    int u,v,d;
    R() {}
    R(int u,int v,int d):u(u),v(v),d(d) {}
    bool operator < (const R &T) const {
        return d>T.d;
    }
};
int bfs() {
    priority_queue<R> q;
    q.emplace(1,n,0);
    while(SZ(q)) {
        int u=q.top().u,v=q.top().v,d=q.top().d;
        q.pop();
        if(u==v) return d;
        if(st[u][v]) continue;
        st[u][v]=true;
        for(auto x:g[u]) if(x.FI==v) return d+1;
        for(auto x:g[u])
            for(auto y:g[v])
                if(!st[x.FI][y.FI]&&x.SE==y.SE) {
                    if(x.FI==y.FI) return d+2;
                    q.emplace(x.FI,y.FI,d+2);
                }
    }
    return -1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        int u,v,w;
        char c;
        cin>>u>>v>>c;
        w=c-'a';
        g[u].EB(v,w);
        if(u!=v) g[v].EB(u,w);
    }
    cout<<bfs()<<'\n';
    return 0;
}

#include<bits/stdc++.h>
//#include <atcoder/all>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
//using namespace atcoder;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e16;

struct Edge{
    int to;
    char col;
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<Edge>> G(n);
    vector<int> a(m), b(m);
    rep(i, m){
        char c;
        cin >> a[i] >> b[i] >> c;
        a[i]--;b[i]--;
        G[a[i]].pb(Edge{b[i], c});
        G[b[i]].pb(Edge{a[i], c});
    }

    vector<vector<int>> nG(n * n);
    //グラフを再構築する
    auto push = [&](int ua, int ub, int va, int vb){
        nG[ua * n + ub].pb(va * n + vb);
    };
    rep(a, n){
        rep(b, n){
            for(auto ea : G[a]){
                for(auto eb : G[b]){
                    if(ea.col == eb.col)push(a, b, ea.to, eb.to);
                }
            }
        }
    }

    vector<ll> d(n * n, INF);
    priority_queue<P, vector<P>, greater<P>> pq;
    d[n - 1] = 0;
    pq.push(P(0, n - 1));

    while(sz(pq)){
        auto [cost, v] = pq.top();
        pq.pop();
        if(d[v] < cost)continue;
        for(auto nv : nG[v]){
            if(d[nv] > d[v] + 1){
                d[nv] = d[v] + 1;
                // cout << nv << " " << d[nv] << endl;
                pq.push(P(d[nv], nv));
            }
        }
    }
    ll res = INF;
    // rep(i, n)cout << d[i * n + i] << endl;
    rep(i, n)chmin(res, 2 * d[i * n + i]);
    rep(i, m){
        chmin(res, 2 * d[a[i] * n + b[i]] + 1);
        chmin(res, 2 * d[b[i] * n + a[i]] + 1);
    }
    if(res == INF)res = -1;
    cout << res << endl;
}


#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> graph; // {nxt, eid}
vector<pair<int, int>> elist; // edges, in orientation in input
vector<bool> marked, exited;
vector<bool> toDirectForward;

void direct(int eid, int i, int j) {
//    printf("directing %d %d->%d\n", eid, i, j);
    toDirectForward[eid] = (elist[eid].first == i);
}

void directForSCC(int v, int p, vector<bool> &pwede) {
    if (!pwede[v] || marked[v]) return;
    marked[v] = true;
//    printf("submarking %d %d\n", v, p);
    for (auto [nxt, eid] : graph[v]) {
        if (!pwede[nxt]) continue;
        if (marked[nxt]) {
            if (nxt != p && !exited[nxt]) direct(eid, v, nxt);
        } else {
            direct(eid, v, nxt);
            directForSCC(nxt, v, pwede);
        }
    }
    exited[v] = true;
}

int main() {
    int n, m; scanf("%d %d", &n, &m);
    graph.assign(n, vector<pair<int, int>>());
    marked.assign(n, false);
    exited.assign(n, false);
    toDirectForward.assign(m, false);
    for (int i = 0; i < m; ++i) {
        int a, b; scanf("%d %d", &a, &b);
        elist.emplace_back(--a, --b);
        graph[a].emplace_back(b, i);
        graph[b].emplace_back(a, i);
    }
    vector<int> c(n);
    for (int i = 0; i < n; ++i) scanf("%d", &c[i]);

    // while i have edges i haven't figured out:
    while (!all_of(begin(marked), end(marked), [&] (bool b) {return b;})) {
//        printf("!NEW SET\n");
        // consider the set of vertices with the lowest c_i.
        int min_ci = n + 1;
        for (int i = 0; i < n; ++i) if (!marked[i]) min_ci = min(min_ci, c[i]);
        vector<int> toCheck;
        vector<bool> canVisit(n, false);
        for (int i = 0; i < n; ++i) if (!marked[i] && c[i] == min_ci) {
            toCheck.push_back(i);
            canVisit[i] = true;
        }
        // consider the connected components this set defines in G
        // for each CC:
            // direct all vertices internally to create an SCC
            // for (u, v) such that u hasn't been marked, and v is in this CC, u->v
            //
            // mark all vertices in the CC
        for (int v : toCheck) directForSCC(v, -1, canVisit);
        for (int i = 0; i < m; ++i) {
            auto [u, v] = elist[i];
            if (!marked[u] && canVisit[v]) direct(i, u, v);
            if (!marked[v] && canVisit[u]) direct(i, v, u);
        }
    }
    for (int i = 0; i < m; ++i) {
        if (toDirectForward[i]) printf("->\n");
        else printf("<-\n");
    }
}

#include <bits/stdc++.h>
//#include <chrono>
#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

struct edge{
        int to, id;
        bool rev;
        edge(){}
        edge(int a, int b, bool c) : to(a), id(b), rev(c){}
    };

vec a(10000), b(10000), c(100);
bitset<10000> res(0), used(0);
vector<vector<edge> > G(100);

void dfs(int v){
    for(edge &e : G[v]){
        if(!used[e.id]){
            used[e.id] = true;
            res[e.id] = e.rev;
            dfs(e.to);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N>>M;
    rep(i, M) {
        cin>>a[i]>>b[i];
        --a[i]; --b[i];
        G[a[i]].emplace_back(b[i], i, false);
        G[b[i]].emplace_back(a[i], i, true);
    }
    rep(i, N) cin>>c[i];
    rep(i, M) {
        if(c[a[i]] != c[b[i]]){
            used[i] = true;
            res[i] = (c[a[i]] < c[b[i]]);
        }
    }
    rep(i, N) dfs(i);
    rep(i, M) cout<<(res[i] ? "<-" : "->")<<endl;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 998244353;

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

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

void Main(){
    ll N,K; cin >> N >> K;
    VL A(N); REP(i,N) cin >> A[i];

    mint kai[K+1]; kai[0]=1; REP(i,K) kai[i+1] = kai[i]*(i+1);
    mint p[N], sum[K+1]; REP(i,N) p[i] = 1; sum[0] = N;
    REP(i,K){
        REP(j,N){
            p[j] *= A[j];
            sum[i+1] += p[j];
        }
        sum[i+1] /= kai[i+1];
    }

    mint same_pair[K+1]; same_pair[0] = N;
    REP(i,N) p[i] = 1;
    REP(i,K)REP(j,N){
        p[j] *= A[j]+A[j];
        same_pair[i+1] += p[j];
    }

    FOR(X,1,K+1){
        mint ans(0);
        REP(k,X+1) ans += sum[X-k] * sum[k];
        ans *= kai[X];
        ans = (ans - same_pair[X]) / 2;

        cout << ans.x << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int, int>;
using Queue = queue<int>;
using Graph = vector<vector<int>>;

int main()
{
    int N, M;
    cin >> N >> M;
    int M2 = M + 1;
    vector<Pair> XY(M2);
    map<Pair, int> idx_map;
    map<int, vector<int>> YX;
    XY.at(0) = {0, N};
    idx_map[{0, N}] = 0;
    YX[N].push_back(0);
    for (int i = 1; i < M2; ++i) {
        auto &[Xi, Yi] = XY.at(i);
        cin >> Xi >> Yi;
        idx_map[{Xi, Yi}] = i;
        YX[Yi].push_back(Xi);
    }
    for (auto &[Yi, X] : YX)
        sort(X.begin(), X.end());
    Graph graph(M2);
    for (int i = 0; i < M2; ++i) {
        auto [Xi, Yi] = XY.at(i);
        auto ub = 2 * N + 1;
        auto &vec1 = YX[Yi];
        auto it1 = upper_bound(vec1.begin(), vec1.end(), Xi);
        if (it1 != vec1.end())
            ub = *it1;
        int y2 = Yi - 1, y3 = Yi + 1;
        if (YX.count(y2)) {
            auto &vec2 = YX.at(y2);
            auto it2 = upper_bound(vec2.begin(), vec2.end(), Xi);
            for ( ; (it2 != vec2.end()) && (*it2 <= ub); ++it2)
                graph.at(i).push_back(idx_map.at({*it2, y2}));
        }
        if (YX.count(y3)) {
            auto &vec3 = YX.at(y3);
            auto it3 = upper_bound(vec3.begin(), vec3.end(), Xi);
            for ( ; (it3 != vec3.end()) && (*it3 <= ub); ++it3)
                graph.at(i).push_back(idx_map.at({*it3, y3}));
        }
    }
    Queue que;
    vector<bool> seen(M2, false);
    que.push(0);
    seen.at(0) = true;
    assert(idx_map.at({0, N}) == 0);
    while (!que.empty()) {
        auto u = que.front(); que.pop();
        for (auto v : graph.at(u)) {
            if (seen.at(v))
                continue;
            seen.at(v) = true;
            que.push(v);
        }
    }
    int cnt = 0;
    for (auto &[Yi, X] : YX) {
        auto idx = idx_map.at({X.back(), Yi});
        if (seen.at(idx))
            ++cnt;
    }
    cout << cnt << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll modcom(ll a,ll b){
    if(a<b)return 0;
    ll res=1;
    rep(i,b){
        res*=modpow(i+1,mod-2);
        res%=mod;
        res*=a-i;
        res%=mod;
    }
    return res;
}
int main(){
    ll n,m;cin>>n>>m;
    ll sum=0;
    rep(i,n){
        ll a;cin>>a;sum+=a;
    }
    out(modcom(m+n,sum+n));
}

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

    void solve(){
      int n;
      cin>>n;
      vector<ll>a(n);
      rep(i,n){cin>>a[i];}
      sort(a.begin(),a.end());
      ll sum=0,ans=0;
      for(int i=n-1;i>=0;i--){
        (ans+=sum*a[i]+a[i]*a[i])%=mod;
        (sum=sum*2+a[i])%=mod;
      }
      cout<<ans<<endl;
    }
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      solve();
      return 0;
    }


#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> par, siz;

  UnionFind(int n) : par(n, -1), siz(n, 1){}

  // 根を求める
  int root(int x) {
    if (par[x] == -1) return x;
    else return par[x] = root(par[x]);
  }

  // xとyが同じグループか判定する
  bool isSame(int x, int y) { return root(x) == root(y); }

  // xを含むグループとyを含むグループを併合する
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;

    if (siz[x] < siz[y]) swap(x, y);
    par[y] = x;
    siz[x] += siz[y];
    return true;
  }

  // xを含むグループのサイズ
  int size(int x) { return siz[root(x)]; }
};

int main(void) {
  int  n;
  int M = 200005;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];

  UnionFind uf(M);

  int l = 0;
  int r = n - 1;

  while(l < r){
    if (a[l] != a[r]) uf.unite(a[l], a[r]);
    l++;
    r--;
  }
  int ans = 0;

  for (int i = 0; i < M; i++){
    if (i == uf.root(i)) ans += uf.size(i) - 1;
  }

  cout << ans << endl;
}

#include<bits/stdc++.h>
#define LL long long
#define DB double
#define pb push_back
#define mkp make_pair
#define LB lower_bound
#define UB upper_bound
#define rint register int
#define MS(x,y) memset(x,y,sizeof(x))
#define rep(i,a,b) for(rint i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(rint i=a,i##end=b;i>=i##end;--i)
#define cms printf("%.2lf\n",(&o2-&o1)/1024.0/1024)
using namespace std;bool o1;
char IO;
inline int Rd(){
	int _s_=0;
	bool _f_=0;
	while(!isdigit(IO=getchar()))
		IO=='-'&&(_f_=1);
	do _s_=(_s_<<1)+(_s_<<3)+(IO^48);
	while(isdigit(IO=getchar()));
	return _f_?-_s_:_s_;
}
struct node{
	int A,B;
	bool operator < (const node &_) const{
		if(A==_.A)
			return B<_.B;
		return A<_.A;
	}
}_b[400005];
int n,c[500005],a,b;
char d[500006];
bool o2;int main(){
	n=Rd();
	rep(i,1,2*n)
		_b[i]=(node){Rd(),i};
	sort(_b+1,_b+1+2*n);
	rep(i,1,n)
		c[_b[i].B]=1;
	a=0,b=0;
	rep(i,1,2*n){
		if(c[i]){
			if(!a&&b){
				d[i]=')';
				b--;
			}
			else {
				d[i]='(';
				if(!a){
					a=1;
					b=0;
				}
				b++;
			}
		}
		else {
			if(a&&b){
				d[i]=')';
				b--;
			}
			else {
				d[i]='(';
				if(a){
					a=0;
					b=0;
				}
				b++;
			}
		}
		putchar(d[i]);
	}
	cout<<d;
	return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
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...);
}

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=100005;

map<pii,int> edgeid;
int edgelabel[N*2];
set<int> adj[N];
bool vis[N];
int vertexlabel[N];
void dfs(int v,int p=0){
	vis[v] = 1;
	if(!p||vertexlabel[p]==edgelabel[edgeid[{v,p}]]){
		vertexlabel[v] = 1;
		if(p&&vertexlabel[p]==1){
			vertexlabel[v]++;
		}
	}else vertexlabel[v] = edgelabel[edgeid[{v,p}]];
	for(auto u:adj[v]){
		if(vis[u])continue;
		dfs(u,v);
	}
}
void solve(){
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i) {
		int u,v,c;
		cin>>u>>v>>c;
		adj[u].insert(v);
		adj[v].insert(u);
		edgeid[{u,v}]=i+1;
		edgeid[{v,u}]=i+1;
		edgelabel[i+1]=c;
	}
	dfs(1);
	for (int i = 0; i < n; ++i) {
		cout<<vertexlabel[i+1]<<"\n";
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 61;
constexpr int mod = 1e9+7;

struct Edge{
  int x, y, d;
  Edge(){}
  Edge(int x, int y, int d): x(x), y(y), d(d){}
  bool operator< (const Edge l)const{
    return d < l.d;
  }
};

struct UnionFind{
  vector<int> node;
  UnionFind(int n){
    node = vector<int>(n, -1);
  }
  int find(int v){
    if(node[v] < 0){
      return v;
    }
    return node[v] = find(node[v]);
  }
  bool merge(int v, int u){
    int rootv = find(v);
    int rootu = find(u);
    if(rootv == rootu) return false;
    if(node[rootv] < node[rootu]){
      swap(rootv, rootu);
    }
    node[rootv] += node[rootu];
    node[rootu] = rootv;
    return true;
  }
  int size(int v){
    return -node[v];
  }
};
vector<int> ans;
void dfs(int v, vector<vector<pair<int, int>>> &g, int root){
  for(auto edge : g[v]){
    int nv = edge.first;
    int cost = edge.second;
    if(nv == root) continue;
    assert(nv != v);
    if(ans[v] == cost){
      if(cost ==0){
        ans[nv]= 1;
      }
      else{
        ans[nv] = 0;
      }
    }
    else{
      ans[nv] = cost;
    }
    dfs(nv, g, v);
  }
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<Edge> edges(M);
  REP(i, M){
    int u, v, c;
    cin >> u >> v >> c;
    u--, v--, c--;
    edges[i] = Edge(u, v, c);
  }
  sort(edges.begin(), edges.end());
  vector<vector<pair<int, int>>> g(N);
  UnionFind uf(N);
  REP(i, M){
    int u, v;
    u = edges[i].x, v = edges[i].y;
    if(uf.merge(u, v)){
      g[v].push_back({u, edges[i].d});
      g[u].push_back({v, edges[i].d});
    }
  }
  ans.resize(N);
  ans[0] = 0;
  dfs(0, g, -1);
  REP(i, N){
    cout << ans[i]+1 << endl;
  }
  return 0;
}


#define ll long long
#define lld double
#define M 202
#define f first
#define s second
#define pi 3.141592653589793238
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define N 100002
#define Endl endl
#define maxx(a,b,c,d) max(max(a,b),max(d,c))
#define minn(a,b,c,d) min(min(a,b),min(d,c))
#define pb push_back
#define mod 1000000007
#define pp 31
#define ss(v) sort(v.begin(),v.end())
#define sr(v) sort(v.begin(),v.end(),greater<pll>())
#define rin(A, B, C) (((A)<=(B))&&((B)<=(C)))
#include <bits/stdc++.h>
using namespace std;
ll power(ll a, ll b)
{
	if(!b)return 1LL;
	ll aa=power(a,b/2);
	if(b%2)return aa*aa%mod*a%mod;
	return aa*aa%mod;
}
ll im(ll a)
{
	return power(a,mod-2);
}
// ll ncr(ll n,ll r)
// {
// 	return f[n]*im(f[r])%mod*im(f[n-r])%mod;
// }
bool check(ll n)
{
	ll m=n;
	while(n)
	{
		if(n%10!=0 && m%(n%10)!=0)
		{
			return false;
		}
		n/=10;
	}
	return true;
}
pll ol(ll a, ll b, ll c, ll d)
{
	a=max(a,c);
	b=min(b,d);
	return {a,b};
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// freopen("output.txt", "w", stdout);
	// freopen("input.txt", "r", stdin);
    ll a,b;
	cin>>a>>b;
	ll ans1=0,ans2=0;
	while(a)
	{
		ans1+=a%10;
		a/=10;
	}
	while(b)
	{
		ans2+=b%10;
		b/=10;
	}
	cout<<max(ans1,ans2)<<endl;

	return 0;
}

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define M 100001
typedef long long ll;
typedef unsigned long long ull;

inline void read(ull &T) {
	ull x = 0; bool f = 0; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = !f; c = getchar(); }
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	T = f ? -x : x;
}

ull n, l, r;

ull s(ull x) { return (1 + x) * x / 2; }

int main() {
    read(n);
    l = 1, r = 6e9;
    while (l <= r) {
        ull mid = (l + r) >> 1;
        if (s(mid) > n + 1) r = mid - 1;
        else l = mid + 1;
    }
    std::cout << n - r + 1 << '\n';
    return 0;
}


/*

                                  In the name of Allah, Most Gracious, Most Merciful

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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
   ll a[4];
   cin>>a[0]>>a[1]>>a[2]>>a[3];
   sort(a,a+4);
   cout<<a[0]<<endl;

}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }

return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    cout<<*min_element(a, a+4);
    return 0;
}


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

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

    n += 99;
    cout << n / 100 << endl;

    return 0;
}

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
bool f2;
char IO;
int rd(){
	int num=0;bool f=0;
	while(IO=getchar(),IO<48||IO>57)if(IO=='-')f=1;
	do num=(num<<1)+(num<<3)+(IO^48);
	while(IO=getchar(),IO>=48&&IO<=57);
	return f?-num:num;
}

bool f1;
int main(){
//	cout<<(&f1-&f2)/1024.0/1024.0<<endl;
	printf("%d",(rd()-1)/100+1);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>

using namespace std;

typedef long long ll;

//e_gcd()自体はaとbの最大公約数を返す。
//xとyは、a*x+b*y=gcd(a,b)となる(x,y)の1つの組を返す。
//a*x+b*y=gcdの時、a=b*p+(a%b)を代入して、b*p*x+(a%b)*x+b*y=b*(p*x+y)+(a%b)*x
//次のx->p*x+y
//次のy->x
//次のa->b
//次のb->a%b
ll e_gcd(ll a, ll b, ll& x, ll& y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll gcd_res = e_gcd(b, a % b, x, y);
	ll p = a / b;
	ll nx = x, ny = y;
	x = ny;
	y = nx - p * x;
	return gcd_res;
}

ll lcm(ll a, ll b) {
	ll t1, t2;
	ll gcd = e_gcd(a, b, t1, t2);
	return a * b / gcd;
}

ll T;

int main() {

	cin >> T;
	while (T--) {
		ll X, Y, P, Q;
		cin >> X >> Y >> P >> Q;

		ll ans = 4 * 1000000000000000000LL;//INFの値はこうする。

		for (ll A = X; A < X + Y; A++) {
			for (ll B = P; B < P + Q; B++) {
				ll p, q;
				//p * (2X + 2Y) - q * (P + Q) = gcd(2X + 2Y, P + Q)となる(p, q)を求める。
				ll gcd = e_gcd(2 * (X + Y), (P + Q), p, q);

				if ((B - A) % gcd != 0)continue;//このB - Aでは解がない場合

				//(p, q)はただの解のセットで、別にpが正などと約束されてるわけではない。
				//よって、まずは適切にあまりを取って0に近づけて、そこから必要な符号に直す。

				//gcd倍の係数をかける。
				p *= (B - A) / gcd;

				p %= (P + Q) / gcd;
				if (p < 0)p += (P + Q) / gcd;

				ll t = A + p * 2 * (X + Y);
				ans = min(ans, t);
			}
		}
		if (ans == 4 * 1000000000000000000LL)
			cout << "infinity" << endl;
		else
			cout << ans << endl;
	}
	return 0;
}

/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Fourtune Cookies
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 4;
const int NBITS = 1 << N;

/* typedef */

/* global variables */

int as[N];

/* subroutines */

/* main */

int main() {
  int sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", as + i);
    sum += as[i];
  }

  for (int bits = 0; bits < NBITS; bits++) {
    int bs = 0;
    for (int i = 0, bi = 1; i < N; i++, bi <<= 1)
      if (bits & bi) bs += as[i];
    if (bs * 2 == sum) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n);i++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
const int MAX = 510000;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    rep(i, n) cin>> s[i];
    vector<int> v(n);
    ll odd= 0;
    ll even=0;
    rep(i, n){
        int x=0;
        rep(j, m){
            if(s[i][j] == '1'){
                x++;
            }
        }
        x = x % 2;
        if(x ==0){
            even++;
        }else{odd++;}
    }
    cout << even * odd << endl;
    return 0;
}

#include <limits.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <cmath>
#include <iomanip>
#include <string>
#include <deque>
#include <assert.h>
#include <random>
#include <ctime>
#include <unordered_map>

#define pnode node*

typedef long long ll;
typedef long double ld;

using namespace std;

const ll mod = 998244353;

ll pw(ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    ll b2 = b / 2;
    ll tmp = pw(a, b2);
    if (b % 2 == 0) {
        return (tmp * tmp) % mod;
    } else {
        return (((tmp * tmp) % mod) * a) % mod;
    }
}

ll sub(ll a, ll b) {
    return (a - b + mod) % mod;
}

ll add(ll a, ll b) {
    return (a + b) % mod;
}

ll mul(ll a, ll b) {
    return (a * b) % mod;
}

ll n, m;

ll cnt[5100][5100];

ll sm[5100][5100];

void solve(){
    cin >> n >> m;
    // cout << n << " " << m << endl;
    for (int i = 1; i <= 5000; ++i) {
        cnt[i][0] = 1;
    }
    for (int i = 1; i <= 5000; ++i) {
        for (int j = 1; j <= 5000; ++j) {
            if (j == 1) {
                cnt[i][j] = i;
            } else {
                cnt[i][j] = (cnt[i][j - 1] * i) % mod;
            }
        }
    }
    for (int i = 1; i <= 5000; ++i) {
        for (int j = 1; j <= 5000; ++j) {
            sm[i][j] = cnt[i][j];
            sm[i][j] += sm[i][j - 1];
            sm[i][j] %= mod;
        }
    }
    ll ans = 0;
    ll atleastonce = sub(pw(m, n), pw(m - 1, n));
    // cout << atleastonce << "\n";
    ans += atleastonce * m;
    // cout << ans << "\n";
    ans %= mod;
    for (int a = 1; a <= m; ++a) {
        for (int len = 1; len <= n; ++len) {
            ll minpos = 1;
            ll maxpos = n - len - 1;
            if (maxpos < minpos) {
                continue;
            }
            ans += mul(mul(cnt[m][n - len - 2], sub(cnt[m - 1][len], cnt[m - a][len])), (maxpos - minpos + 1));
            ans %= mod;
        }
    }
    cout << ans << "\n";
}

signed main(){
    ll t = 1;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed;
    cout << setprecision(20);
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
    #endif
    while(t--){
        solve();
    }
}


/*
author: madhav_1999 aka orthodoxparadox
18 April 2021 at 5:31 PM
*/

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

#define dbl long double
#define int ll
#define ll long long
#define pii pair<int, int>
#define len(x) (int) x.size()
#define rev(a) reverse(all(a))
#define oiint ostream_iterator<int>(cout, " ")
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
#define inf 2e18
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef MADHAV
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
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...);}
#else
#define dbg(...) 42
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<(int)v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const multiset<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pair_hash {inline std::size_t operator()(const std::pair<int, int> & v) const {return v.first*31+v.second;}};
const int MOD = 1e9 + 7;

int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}

int fast_exp(int base, int expo, int mod = MOD) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;}
	return res;}

int modinv(int a, int mod = MOD){return takemod(fast_exp(takemod(a, mod), mod-2, mod), mod);}

void solve() {
	int a, b;
	cin >> a >> b;
	vector<int> ans;
	if(a > b) {
		int sum = 0;
		for(int i = 1; i <= a; i++) {
			ans.push_back(i);
			sum += i;
		}
		for(int i = 1; i <= b - 1; i++) {
			ans.push_back(-i);
			sum -= i;
		}
		ans.push_back(-sum);
	}
	else {
		int sum = 0;
		for(int i = 1; i <= b; i++) {
			ans.push_back(-i);
			sum += i;
		}
		for(int i = 1; i <= a - 1; i++) {
			ans.push_back(i);
			sum -= i;
		}
		ans.push_back(sum);
	}
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifdef MADHAV
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	clock_t t1, t2;
	t1 = clock();

	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
#ifdef MADHAV
	t2 = clock(); cout << "\n\ntime taken: " << (t2-t1)/(dbl)CLOCKS_PER_SEC;
#endif
	return 0;
}

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

struct ios
{
    inline char read()
    {
        static const int IN_LEN = 1e6 + 10;
        static char buf[IN_LEN], *s, *t;
        return (s == t) && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)), s == t ? -1 : *s++;
    }
    template <typename _Tp>
    inline ios &operator>>(_Tp &x)
    {
        static char c11, boo;
        for (c11 = read(), boo = 0; !isdigit(c11); c11 = read())
        {
            if (c11 == -1)
                return *this;
            boo |= c11 == '-';
        }
        for (x = 0; isdigit(c11); c11 = read())
            x = x * 10 + (c11 ^ '0');
        boo && (x = -x);
        return *this;
    }
} io;

namespace IO
{
    template <typename T>
    inline void w(T x)
    {
        if (x > 9)
            w(x / 10);
        putchar(x % 10 + 48);
    }
    template <typename T>
    inline void write(T x, char c)
    {
        if (x < 0)
            putchar('-'), x = -x;
        w(x);
        putchar(c);
    }
    template <typename T>
    inline void read(T &x)
    {
        x = 0;
        T f = 1;
        char c = getchar();
        for (; !isdigit(c); c = getchar())
            if (c == '-')
                f = -1;
        for (; isdigit(c); c = getchar())
            x = (x << 1) + (x << 3) + (c ^ 48);
        x *= f;
    }
} // namespace IO

#define int long long
#define x first
#define y second
#define PII pair<int,int>
#define LL long long
#define pb push_back
#define pqp priority_queue<PII,vector<PII>,greater<PII>>
#define pqi priority_queue<int,vector<int>,greater<int>>
#define PSS pair<string,string>
#define in insert
#define line inline
// #define sort(s) sort(s.begin(),s.end());
#define reverse(s) reverse(s.begin(),s.end());
#define max_(s) *max_element(s.begin(), s.end())
#define V vector<int>
#define VV vector<V>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int dx[]=  {0,-1,0,1,0,0},dy[]= {-1,0,1,0,0,0},dz[] = {0,0,0,0,-1,1};
string s;
int m;

bool check(int x)
{
	 __int128 sum=0;

	for(__int128 i = s.size() - 1,j = 1; i >= 0; i--,j *= x)
	{
		sum = sum + (s[i]-'0') * j;
		if(sum > m || j > m) return 0;
	}
	return 1;
}

void solve()
{
    cin >> s;
    cin >> m;
    int t = 0;
    for(auto x : s) t = max(t,(int)(x - '0' + 1));
    int k = t - 1;
    if(s.size() == 1){
        k = s[0] - '0';
        if(k <= m) puts("1");
        else puts("0");
    }
    else{
        int l = t, r = m;
        int res;
        while(l <= r){
       	   int mid = l + r >> 1;
       	   if(check(mid)) l = mid + 1,res = mid;
       	   else r = mid - 1;
        }
        cout << max(0ll,res - k);
    }

}

signed main()
{
    // IOS
    // int _; cin >> _; while(_ --)
    solve();
}


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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

void solve(int test)
{
    int n;
    cin >> n;
    int i;
    VInt a(n), b(n);
    FOR(i, 0, n) cin >> a[i];
    FOR(i, 0, n) cin >> b[i];
    reverse(ALL(a));

    priority_queue<int> q;
    FOR(i, 0, n)
    {
        q.push(-a[i]);
        q.push(-b[i]);
        q.pop();
    }

    Int res = 0;
    FOR(i, 0, n)
    {
        res -= q.top();
        q.pop();
    }
    cout << res << endl;
}

int main()
{
    int T = 1, t;
    //cin >> T;
    FOR(t, 0, T)
    {
        //cerr << "Solving " << t << "/" << T << endl;
        solve(t);
    }
    return 0;
}

// I've done my sentence but committed no crime
#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod (int)(1e9+7)
#define mod2 998244353
#define flush fflush(stdout);
#define PI 3.1415926535897932384626433832795

void solve() {
    int n; cin>>n;
    int ans=0;
    for(int i=1;i<n;i++){
        if(i>0&&(n-i)>0)ans++;
    }
    cout<<ans<<'\n';
}

int32_t main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const ll INF = 1e17;

ll N, M;
vector<ll> W;
vector<pair<ll,ll>> A; //A[i] := first以下の耐荷重を持つものの最大の長さ

// #include"debug.hpp"

ll calc(ll weight) {
    auto girigiri = upper_bound(A.begin(), A.end(), pair<ll,ll>{weight, -INF});
    if(girigiri == A.begin()) {
        return 0;
    }
    girigiri--;
    if(girigiri -> first > weight) {
        return INF;
    }
    return girigiri -> second;
}

int main()
{
    cin >> N >> M;
    W.resize(N), A.resize(M);
    for(ll i = 0; i < N; i++)cin >> W[i];
    for(ll i = 0; i < M; i++)cin >> A[i].second >> A[i].first;
    sort(W.begin(), W.end());
    sort(A.begin(), A.end());

    // /*
    {
        ll maxweight = W.back();
        for(int i = 0; i < M; i++) {
            if(A[i].first < maxweight) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    // */

    for(ll i = 1; i < M; i++) {
        A[i].second = max(A[i].second, A[i - 1].second);
    }

    // print(A);

    ll answer = 1e17;

    do {

        vector<vector<ll>> hen(N);
        for(ll i = 0; i < N; i++) {
            for(ll j = i + 1; j < N; j++) {
                ll sum = 0;
                for(ll k = i; k <= j; k++)sum += W[k];
                // print(sum);
                ll len = calc(sum); //重さsumを乗せれる最小の長さ
                hen[i].push_back(len);
            }
        }

        vector<ll> dist(N);
        for(ll i = 0; i < N; i++) {
            for(ll j = i + 1; j < N; j++) {
                dist[j] = max(dist[j], dist[i] + hen[i][j - i - 1]);
            }
        }
        answer = min(answer, dist[N - 1]);

    } while(next_permutation(W.begin(), W.end()));

    if(answer == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << answer << endl;

}

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll
const long double pi = 3.14159265358979323846;

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

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

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

template <typename T>
struct UnionFind {
   private:
    vector<T> par;
    vector<T> rank;
    vector<T> sz;
    vector<T> a, b;
    int n;

   public:
    // n要素で親を初期化、par[x]はxの親を表す
    UnionFind(int n) : n(n) {
        par.resize(n, 0);
        rank.resize(n, 0);
        sz.resize(n, 1);
        a.resize(n);
        b.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }

    void init(vector<ll> &A, vector<ll> &B){
        rep(i,0,n){
            a[i] = A[i];
            b[i] = B[i];
        }
    }
    //木の根を求める
    int root(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = root(par[x]);
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            swap(x, y);
        }

        par[y] = x;
        sz[x] += sz[y];
        a[x] += a[y];
        b[x] += b[y];
        if (rank[x] == rank[y]) rank[x]++;
    }

    // xとyが同じ集合に属するか否か
    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    // xが属する集合のサイズを返す
    int size(int x) {
        return sz[root(x)];
    }

    // 集合の数を返す
    int num_of_s() {
        vector<int> cnt(n);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (!cnt[root(i)]) ans++, cnt[root(i)] = 1;
        }
        return ans;
    }
    T get_a(int k){
        return a[root(k)];
    }
    T get_b(int k){
        return b[root(k)];
    }
};
void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> b(n);
    for(int i = 0; i < n; i++) cin >> b[i];

    UnionFind<ll> uf(n);
    uf.init(a, b);
    rep(i,0,m){
        ll u,v; cin >> u >> v;
        u--;
        v--;
        uf.unite(u, v);
    }

    bool ok = true;
    rep(i,0,n){
        ok &= uf.get_a(i) == uf.get_b(i);
    }

    YES(ok);
}


#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(i, t){
    	int n;
    	cin >> n;
    	string a;
    	rep(j, 3) cin >> a;
    	string s(n, '0');
    	string t(n, '1');
    	cout << s + t + "0" << endl;
    }
    return 0;
}

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

int main(){
    ll t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        ll cs = a.size();
         cs /= 2;
         fr(i,0,cs){
             cout<<"0";
         }
         fr(i,0,cs){
             cout<<"1";
         }
         cout<<"0"<<"\n";

    }
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)

typedef long long ll;
const ll INFll = 1LL << 60;

int main(){
    //input, initialize
    int N, M; cin >> N >> M;
    vector<vector<int>> A(N);
    rep(i, M){
        int a, b;
        cin >> a >> b; a--; b--;
        A[a].push_back(b);
    }
    //solve
    ll ans = 0;
    rep(s, N){
        vector<int> dist(N, -1);
        queue<int> que;
        dist[s] = 0; que.push(s);
        while(!que.empty()){
            int v = que.front(); que.pop();
            for(auto nv: A[v]){
                if(dist[nv] == -1){
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                }
            }
        }

        rep(t, N){
            if(dist[t] != -1) ans++;
        }
    }
    //output
    cout << ans << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define vi std::vector<ll>
#define si set<ll>
#define pb push_back

vi v[2020];
bool visited[2020];
ll ans;

void dfs(ll s){
    if(visited[s])return;
    visited[s] = true;
    ans++;
    for (auto u: v[s]){
        dfs(u);
    }
    return;
}

ll solve(){
    for (int i = 0; i < 2020; ++i){
        visited[i] = false;
        v[i].clear();
    }

    ll n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        v[a].pb(b);
    }
    ll totans = 0;

    for (ll i = 1; i <= n; ++i){
        memset(visited, false, 2020);
        ans = 0;
        dfs(i);
        totans += ans;
    }
    cout << totans;
    return 0;
}

int main(){
    fastio;
    ll t= 1;
   // cin >> t;
    for (int i = 0; i < t; ++i){
       // cout << "Case #" << i+1 << ": ";
        solve();
        cout << "\n";
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
#define N 200007
using namespace std;
int n,sum,ans,ma,a[N],fa[N];
int find(int x){
	if (fa[x]==x) return x;
	fa[x]=find(fa[x]);
	return fa[x];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum++;
		ma=max(ma,a[i]);
	}
	ans=n;
	for (int i=1;i<=ma;i++)
		fa[i]=i;
	for (int i=1;i<=n/2;i++)
		if (a[i]!=a[n-i+1]){
			int fx=find(a[i]),fy=find(a[n-i+1]);
			if (fx!=fy){
				ans--;
				fa[fy]=fx;
			}
		}
	printf("%d\n",sum-ans);
}

#include <bits/stdc++.h>
#include <chrono>
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>
/* find_by_order(x) give iterator of the index x
   order_by_key(x) give the position where x will be placed*/
#define int long long
#define lop(i,a,b,c) for (int i=a;i<b;i+=c)
#define rlop(i,a,b,c) for (int i=a-1;i>=b;i-=c)
#define prii pair <int,int>
#define PB push_back
#define S second
#define F first
#define all(x) x.begin(),x.end()
#define vvii vector < vector < int > >
#define vii vector <int>
#define count_1(x) __builtin_popcount(x)
#define cn(a) scanf("%lld",&a);
#define cn_vl(arr,n) lop(i,0,n,1){scanf("%lld",arr+i);}
#define shw_vl(arr,n) lop(i,0,n,1){printf("%lld ",arr[i]);}printf("\n");
#define shw(CON) cout << &("NO\0YES"[3 * CON]) << '\n';
const int MAX=2e5+10;
/*......................................................................*/

struct dsu
{
	int parent[MAX];int size[MAX];
	void init(){
		lop (i,1,MAX,1){parent[i]=i;size[i]=1;}
	}
	int trace(int a){
		return (a==parent[a])?a:parent[a]=trace(parent[a]);
	}
	bool connect(int a,int b){
		if ((a=trace(a))==(b=trace(b)))return false;
		if (size[b]>size[a])swap(a,b);
		parent[b]=a;size[a]+=size[b];
		return true;
	}
}ori;
vii adj[MAX];
void solve(){
	int n;cn(n)
	vii vec;ori.init();
	lop (i,0,n,1){
		int a;cn(a)
		vec.PB(a);adj[a].PB(i);ori.connect(adj[a].front(),i);
	}

	int cst=0;
	lop (i,0,n/2,1){
		if (ori.trace(i)!=ori.trace(n-1-i)){
			cst++;ori.connect(i,n-1-i);
		}
	}
	cout<<cst;
}
int32_t main(){
	int t;t=1;
	// cin>>t;
	while (t--){
		auto t_1=chrono::high_resolution_clock::now();
		solve();
		auto t_2=chrono::high_resolution_clock::now();
		// cout <<". Elapsed (ms): " << chrono::duration_cast<chrono::milliseconds>(t_2 - t_1).count() << endl;
	}
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	long long mx = -1e9;
	long long sm = 0;
	long long pre = 0, pre_sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sm += a[i];
		sm += pre;
		pre += a[i];
		mx = max(mx, a[i]);
		cout << sm + mx * (i + 1) << endl;
	}
}

#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

template <typename Abel> struct BIT {
    private:
    int n;
    vector<Abel> data;

    public:
    BIT (const int n_) : n(n_+1), data(n+1, 0) {}

    void add(const int i, const Abel x) {
        for(int k = i + 1 ; k < n; k += k & -k) data[k-1] += x;
    }

    Abel sum(int r) {
        Abel ret = data[r-1];
        while(r > 0) ret += data[(r -= r & -r)-1];
        return ret;
    }
    Abel sum(const int l, const int r) {
        return sum(r) - sum(l);
    }

    int lower_bound(Abel w){
        if(w <= 0) return 0;
        int ret = 0, k = 1;
        while(k < n) k <<= 1;
        for(int i = k; i > 0; i >>= 1){
            assert(typeid(w) == typeid(int) || typeid(w) == typeid(long long));
            if(ret+i/*-1*/ < n && data[ret+i-1] < w) w -= data[(ret+=i)-1];
        }
        return ret;
    }
    int upper_bound(const Abel w){
        return lower_bound(w + 1);
    }

    void print(){
        for(int i = 0; i < n - 1; i++) cout << sum(i, i+1) << ' ';
        cout << endl;
    }
};

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

    int n;
    cin >> n;

    vector<long long> a(n);
    vector<long long> mx(n, -1);
    cin >> a[0];
    mx[0] = a[0];
    for(int i = 1; i < n; i++){
        cin >> a[i];
        mx[i] = max(mx[i-1], a[i]);
    }

    long long ans = 0;
    long long tmp = 0;
    cout << a[0]*2 << endl;
    ans += a[0]+mx[0];
    tmp = a[0]+mx[0];
    for(int i = 1; i < n; i++){
        tmp += mx[i]-mx[i-1];
        ans += tmp + a[i];
        tmp = tmp+a[i];
        ans += max(i*(mx[i]-mx[i-1]), 0LL);
        cout << ans << " " << endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define pb push_back
template <typename _Tp>void read(_Tp &x){
	char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
typedef long long ll;
ll f[105];
bool tag[105];
int main(){
	f[0]=1,f[1]=1;for(int i=2;i<=90;++i)f[i]=f[i-1]+f[i-2];
	ll n;read(n);
	int p=0;for(int i=1;i<=90;++i)if(f[i]<=n)p=i;
	std::vector<int> ans;
	ll x=n;
	for(int i=90;i>=0;--i)if(x>=f[i])tag[i]=true,x-=f[i];
	if(p&1){
		for(int i=0;i<=p;++i){
			if(tag[p-i])ans.pb(2-i%2);
			if(i<p)ans.pb(3+i%2);
		}
	}
	else{
		for(int i=0;i<=p;++i){
			if(tag[p-i])ans.pb(i%2+1);
			if(i<p)ans.pb(4-i%2);
		}
	}
	printf("%d\n",SZ(ans));
	for(auto it:ans)printf("%d\n",it);
	return 0;
}

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

bool tooBig(__int128 x, __int128 y) {
    return (2 * x - y) * (2 * x - y) > 5 * y * y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    ll x;
    cin >> x;
    ll l = 0, r = x + 1, y = x;
    while (l < r) {
        ll mid = (l + r) / 2;
        if (tooBig(x, mid)) {
            y = mid;
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    vector<int> ans;
    while (x > 0 && y > 0) {
        if (x > y) {
            while (tooBig(x - 1, y)) {
                ans.push_back(1);
                x--;
            }
            ans.push_back(3);
            x -=y;
        } else {
            while (tooBig(y - 1, x)) {
                ans.push_back(2);
                y--;
            }
            ans.push_back(4);
            y -= x;
        }
    }
    while (x > 0) {
        ans.push_back(1);
        x--;
    }
    while (y > 0) {
        ans.push_back(2);
        y--;
    }
    reverse(ans.begin(), ans.end());
    cout << int(ans.size()) << '\n';
    for (int i : ans) cout << i << '\n';
    return 0;
}


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

int main(int argc, const char* argv[]){
    string n;
    cin >> n;

    int n_s = n.length()-1;

    while(n.at(n_s) == '0' && n_s != 0){
        n_s = n_s-1;
    }

    int n_min=0;
    int n_max=n_s;
    bool r_f=true;

    while(n_min < n_max) {
        if (n.at(n_min) != n.at(n_max)) {
            r_f=false;
        }
        n_min = n_min+1;
        n_max = n_max-1;
    }

    if(r_f){
        std::cout<<"Yes"<<endl;
    } else{
        std::cout<<"No"<<endl;
    }

}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define sc(x) scanf("%d",&x)
#define fra(v) for(auto &it:v)
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL)
ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
void SieveOfEratosthenes(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (ll p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {

            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
        if (prime[p])
            cout << p << " ";
}

int main()
{
    fastIO;
    ll t;
    t=1;
    while(t--)
    {
        string s,s1,x;
        cin>>s;
        x=s;
        reverse(x.begin(),x.end());
        if(s==x)
        {
            cout<<"Yes";
            continue;
        }
        ll a=0;
        ll l=s.size()-1;
        while(s[l]=='0')
        {
            a++;
            l--;
        }
        while(a--)
        {
            s1+='0';
        }
        s=s1+s;
        x=s;
        reverse(x.begin(), x.end());
        if(s==x)
        {
            cout<<"Yes" ;
        }
        else
        {
            cout<<"No" ;
        }
    }
}


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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define DBG(a) cerr<< "Line "<<__LINE__ <<" : "<< #a <<" = "<<(a)<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

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

const int N=100009;
const int mod=1e9+7;

ll dp[2002][2002][4];
                  //0 ->total sum
                  //1->Horizontal prefix sum
                  //2->Vertical prefix sum
                  //3-> Corner Prefix sum
vector<string> vec;
int main()
{

    string s;
    int row,col,i,j,k;

    cin>>row>>col;
    for(i=0; i<row; i++){
        cin>>s;
        vec.pb(s);
    }
    int wallH=1,wallV=1,wallC=1;
    ll sum;
    for(i=1; i<=row; i++){
        for(j=1; j<=col; j++){
            for(k=0; k<4; k++) dp[i][j][k]=0;

            if(i==1 && j==1) continue;

            if(vec[i-1][j-1]=='.'){
                sum=dp[i][j-1][1]+dp[i-1][j][2]+dp[i-1][j-1][3];
                if(i==1) sum+=wallH;
                else if(j==1) sum+=wallV;
                else if(i==j) sum+=wallC;
                sum=sum%mod;
                dp[i][j][0]=sum;
                dp[i][j][1]=(dp[i][j-1][1]+sum)%mod;
                dp[i][j][2]=(dp[i-1][j][2]+sum)%mod;
                dp[i][j][3]=(dp[i-1][j-1][3]+sum)%mod;
            }
            else{
                if(i==1) wallH=0;
                else if(j==1) wallV=0;
                else if(i==j) wallC=0;
            }
        }
    }
    cout<<dp[row][col][0]%mod<<'\n';
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int solve(long long* available, int n, long long k) {
    if (available[n - 1] < k) {
        return -1;
    }

    int l = 0, r = n - 1;

    while (l < r) {
        int middle = l + (r - l) / 2;

        if (available[middle] >= k) {
            if (available[middle - 1] < k) {
                return middle;
            }

            r = middle - 1;
        } else {
            l = middle + 1;
        }
    }

    return l;
}

int main() {
    int n, q;

    cin >> n >> q;

    auto available = new long long[n];
    auto not_available = new long long[n];

    cin >> not_available[0];

    available[0] = not_available[0] - 1;

    int i;

    for (i = 1; i < n; i++) {
        cin >> not_available[i];

        available[i] =
            available[i - 1] + not_available[i] - not_available[i - 1] - 1;
    }

    long long k;

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

        auto solution = solve(available, n, k);

        if (solution == -1) {
            cout << not_available[n - 1] + k - available[n - 1];
        } else {
            cout << not_available[solution] - (available[solution] - k) - 1;
        }

        cout << '\n';
    }
}


#include<bits/stdc++.h>
#define mxn 500005
#define ll long long
using namespace std;
char str[mxn], t[mxn];
int a[mxn], b[mxn];
int main()
{
    int n;
    scanf("%d %s %s", &n, str+1, t+1);
    for(int i=1; i<=n; i++)
    a[i]= str[i]-'0', b[i]= t[i]-'0';
    ll res= 0;
    int lst;
    if(str[1]==t[1])lst= 2;
    else lst= 1;
    for(int i=2; i<=n; i++)
    {
        if(str[i]=='1')
        {
            if(lst<i)
            {
                res+= (i-lst);
                a[lst]^= 1;
                a[i]= 0;
                while(lst<=i)
                {
                    if(a[lst]==b[lst])lst++;
                    else break;
                }
            }
            else if(a[i]==b[i])lst++;
        }
        else if(lst==i && a[i]==b[i])lst++;
    }
    if(lst<=n)res= -1;
    printf("%lld\n", res);
    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;

int main() {
    ll N, X; cin >> N >> X;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> S(N);
    repm(i,N-1,0) {
        S[i] = X / A[i];
        X %= A[i];
    }

    vector<vector<ll>> dp(N+1,vector<ll>(2));
    dp[0][0] = 1;
    rep(i,N) {
        rep(j,2) {
            ll x = S[i] + j;
            if (x==0) {
                dp[i+1][0] = dp[i][j];
                continue;
            }
            if (i<N-1) {
                dp[i+1][1] += dp[i][j];
                if (x==A[i+1]/A[i]) continue;
            }
            dp[i+1][0] += dp[i][j];
        }
    }

    ll ans = dp[N][0];
    Cout(ans);
}


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

int read();
#define LL long long
#define fr(i,l,r) for(int i = (l);i <= (r);++i)
#define rf(i,l,r) for(int i = (l);i >= (r);--i)
#define fo(i,l,r) for(int i = (l);i < (r);++i)
#define foredge(i,u,v) for(int i = fir[u],v;v = to[i],i;i = nxt[i])
#define ci const int &
#define cl const LL &
#define I inline void
#define filein(File) freopen(File".in","r",stdin)
#define fileout(File) freopen(File".out","w",stdout)

const int N = 105;
const int p[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int n,a[N],cnt[N];
int gcd(int x,int y) {
	return !y ? x : gcd(y,x % y);
}
LL now = 1,ans = 9e18;
I chk() {
	fr(i,1,n) if(gcd(now % a[i],a[i]) == 1) return;
	ans = min(ans,now);
}
void dfs(int cur) {
	if(cur == 15) return chk();
	dfs(cur + 1);
	now *= p[cur];
	dfs(cur + 1);
	now /= p[cur];
}
int main() {
	cin >> n;
	fr(i,1,n) cin >> a[i];
	dfs(0);
	cout << ans << endl;
	return 0;
}

/**
 *    Author : Tanbin_Hasan
 *    Created : 14.03.2021
**/
#include <bits/stdc++.h>

using namespace std ;

void subsets(vector<long long> &ar , int n , vector<long long> &d) {
  for (int mask = 0 ; mask < (1LL << n) ; ++mask) {
    vector<long long> temp ;
    for (int i = 0 ; i < n ; ++i) {
      if (mask & (1LL << i)) {
        temp.push_back(ar[i]) ;
      }
    }
    long long res = 1 ;
    if (!temp.empty()) {
      for (auto &i : temp) {
        res *= i ;
      }
      d.push_back(res) ;
    }
  }
}

int main(void) {
  ios::sync_with_stdio(false) ; cin.tie(0) ;
  vector<long long> prime = {2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43 , 47} ;
  int n ;
  cin >> n ;
  vector<long long> v(n) ;
  unordered_set<long long> us ;
  for (auto &i : v) {
    cin >> i ;
    for (auto &p : prime) {
      if (!(i % p)) {
        us.insert(p) ;
      }
    }
  }
  vector<long long> fact ;
  vector<long long> d ;
  for (auto &i : us) {
    fact.push_back(i) ;
  }
  subsets(fact , (int) fact.size() , d) ;
  long long res = LONG_LONG_MAX ;
  for (auto &i : d) {
    int cnt = 0 ;
    for (auto &j : v) {
      if (__gcd(i , j) != 1) {
        ++cnt ;
      }
    }
    if (cnt == n) {
      res = min(res , i) ;
    }
  }
  cout << res << '\n' ;
  return 0 ;
}


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

const int maxn = 100;
double ret[maxn][maxn][maxn];

double dfs(vector<int>&coins){
    if(coins[1]==0) return 100.0 - coins[0];
    if(coins[0]==100 || coins[1] ==100 || coins[2]==100) return 0.0;
    double &ans = ret[coins[0]][coins[1]][coins[2]];
    if(ans>=0) return ans;
    int s = 0;
    for(auto c: coins) s += c;
    double res = 0;
    for(int i=0;i<3;i++){
        vector<int>nxt(coins);
        nxt[i] ++;
        res += (double)coins[i] / s * (1+dfs(nxt));
    }
    return ans = res;
}

int main(){
    vector<int> coins(3);
    for(int i=0;i<3;i++) cin>>coins[i];
    sort(coins.rbegin(), coins.rend());
    memset(ret, -1, sizeof ret);
    printf("%.12f\n", dfs(coins));
    return 0;
}

#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <cassert>
#include <cmath>
using namespace std;

int main()
{
	auto& in = cin;
	int a, b, c;
	in >> a >> b >> c;

	vector<vector<vector<double>>> count(101, vector<vector<double>>(101, vector<double>(101)));
	for (int ia = 99; ia >= 0; --ia) {
		for (int ib = 99; ib >= 0; --ib) {
			for (int ic = 99; ic >= 0; --ic) {
				double sum = ia + ib + ic;
				count[ia][ib][ic]
					= ((double)ia / sum) * (count[ia + 1][ib][ic] + 1.0)
					+ ((double)ib / sum) * (count[ia][ib + 1][ic] + 1.0)
					+ ((double)ic / sum) * (count[ia][ib][ic + 1] + 1.0);
			}
		}
	}
	cout.precision(15);
	cout << count[a][b][c];

	return 0;
}


// #define _GLIBCXX_DEBUG
// #define _LIBCPP_DEBUG 0
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
// clang-format off
#define PI 3.14159265358979323846264338327950L
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep2(i,s,n) for (int i=(s); i<(int)(n); ++i)
#define prep_ios(do_flush) if(!do_flush){ ios::sync_with_stdio(false);cin.tie(nullptr);constexpr char endl='\n'; } cout<<fixed<<setprecision(20)
#define put(expr) cout<<expr<<'\n'
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "[ "; for (auto v: vec) os << v << " "; os << "]"; return os; }template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "< "; 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 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 T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
typedef int8_t i8; typedef int16_t i16; typedef int32_t i32; typedef int64_t i64; typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; typedef float f32; typedef double f64; typedef long double f80;
typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef map<int, int> mii;
typedef __int128_t i128; i128 parse(string &s) { i128 ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } istream &operator>>(istream &is, i128 &v) { string s; is >> s; v = parse(s); return is; } ostream &operator<<(ostream &os, const i128 &v) { if (v == 0) return (os << "0"); i128 num = v; if (v < 0) { os << '-'; num = -num; } string s; for (; num > 0; num /= 10) s.push_back('0' + (char)(num % 10)); reverse(s.begin(), s.end()); return (os << s); }
template <typename T> bool chmax(T &now, const T &cand) { if (now < cand) { now = cand; return true; } return false; } template <typename T> bool chmin(T &now, const T &cand) { if (now > cand) { now = cand; return true; } return false; }
template <typename T> T gcd(const T &a, const T &b) { if (a % b == 0) return b; return gcd(b, a % b); } template <typename T> T lcm(const T &a, const T &b) { return a * b / gcd(a, b); }
template <typename T> T nCr(const T &n, T k) { if (k > n) return 0; if (k * 2 > n) k = n - k; if (k == 0) return 1; int result = n; for (int i = 2; i <= k; ++i) { result *= (n - i + 1); result /= i; } return result; }
const int INF = 1<<30; /* INF > 10^9 */ const i64 INFLL = 1LL<<60; /* INFLL > 10^18 */ const string YES = "Yes", NO = "No";

// clang-format on?

int main() {
  prep_ios(true);

  i64 N;
  cin >> N;

  i64 _max = 100000;
  i64 _min = 0;

  vector<i64> A(N);
  rep(i, N) cin >> A[i];

  vector<i64> B(N);
  rep(i, N) cin >> B[i];

  rep(i, N) chmax(_min, A[i]);
  rep(i, N) chmin(_max, B[i]);

  i64 diff = _max - _min + 1;
  if (diff < 0) diff = 0;
  put(diff);
}


#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<int> a(n), b(n);
    map<int, int> cnt;
    vector<pair<int, char>> pos(2 * n + 1, pair<int, char>(-1, 'N'));
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        cnt[a[i]]++;
        cnt[b[i]]++;
        if (a[i] != -1)
            pos[a[i]] = {b[i], 'L'};
        if (b[i] != -1)
            pos[b[i]] = {a[i], 'R'};
    }
    for (auto &p : cnt) {
        if (p.first != -1 && p.second >= 2) {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    vector<bool> dp(2 * n + 1, false);
    dp[0] = true;
    for (int i = 2; i <= 2 * n; ++i) {
        for (int j = i - 2; j >= 0; j -= 2) {
            if (!dp[j])
                continue;
            bool ok   = true;
            int width = (i - j) / 2;
            for (int k = j + 1; k <= i; ++k) {
                auto c = pos[k];
                if (k < j + 1 + width) { // left
                    if (c.second == 'R' || (c.second == 'L' && (c.first != -1 && c.first != k + width)))
                        ok = false;
                    if (c.second == 'L' && c.first == k + width)
                        if (!(pos[k + width].second == 'R' && pos[k + width].first == k))
                            ok = false;
                    if (c.second == 'L' && c.first == -1)
                        if (pos[k + width].second != 'N')
                            ok = false;
                } else { // right
                    if (c.second == 'L' || (c.second == 'R' && (c.first != -1 && c.first != k - width)))
                        ok = false;
                    if (c.second == 'R' && c.first == k - width)
                        if (!(pos[k - width].second == 'L' && pos[k - width].first == k))
                            ok = false;
                    if (c.second == 'R' && c.first == -1)
                        if (pos[k - width].second != 'N')
                            ok = false;
                }
            }
            if (ok) {
                dp[i] = true;
                break;
            }
        }
    }
    if (dp[2 * n])
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cassert>
#include <numeric>
#include <unordered_map>
//#include <atcoder/all>
#include <queue>
#include <math.h>
#include <climits>
#include <set>
#include <map>
//using namespace atcoder;

typedef long long ll;
#define FOR(i, a, b) for(ll i=(a); i<(b);i++)
#define REP(i, n) for(ll i=0; i<(n);i++)
#define ROF(i, a, b) for(ll i=(b-1); i>=(a);i--)
#define PER(i, n) for(ll i=n-1; i>=0;i--)
#define REPREP(i,j,a,b) for(ll i=0;i<a;i++)for(ll j=0;j<b;j++)
#define VV(type) vector<vector<type>>
#define VV2(type,n,m,val) vector<vector<type>> val;val.resize(n);for(ll i;i<n;i++)val[i].resize(m)
#define vec(type) vector<type>
#define VEC(type,n,val) vector<type> val;val.resize(n)
#define VL vector<ll>
#define SZ size()
#define all(i) begin(i),end(i)
#define SORT(i) sort(all(i))
#define max(a,b) a>b?a:b
using namespace std;

int main() {
  ll n;
  cin >> n;
  VL x(n),y(n),r(n);
  ll mi = n;
  ll mx = 0;
  REP(i, n) {
    cin >> x[i] >> y[i] >> r[i];
    if (mx < r[i]) {
      mx = r[i];
      mi = i;
    }
  }
  if (1.25*1e9 < mx * n) {
    REP(i, n) {
      if (i == mi) {
        cout << x[(i + 0) % n] <<" "<< y[(i + 0) % n] << " " << x[(i + 0) % n] + 1 << " " << y[(i + 0) % n] + 1<<endl;
      }
      else if ((i + 1) % n == mi) {
        cout << x[(i + 2) % n] << " " << y[(i + 2) % n] << " " << x[(i + 2) % n] + 1 << " " << y[(i + 2) % n] + 1 << endl;
      }
      else {
        cout << x[(i + 1) % n] << " " << y[(i + 1) % n] << " " << x[(i + 1) % n] + 1 << " " << y[(i + 1) % n] + 1 << endl;
      }
    }
  }
  else {
    REP(i, n) {
      cout << x[(i + 1) % n] << " " << y[(i + 1) % n] << " " << x[(i + 1) % n] + 1 << " " << y[(i + 1) % n] + 1 << endl;
    }
  }

  return 0;
}

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

struct ad {
    int x;
    int y;
    int r;
    ad(int _x = 0, int _y = 0, int _r = 0) : x(_x), y(_y), r(_r) {}

    int left;
    int up;
    int right;
    int down;

    int& operator[](int i) {
        if (i == 0) {
            return left;
        } else if (i == 1) {
            return up;
        } else if (i == 2) {
            return right;
        } else {
            assert(i == 3);
            return down;
        }
    }

    double score() {
        int s = (right - left) * (down - up);
        return 1.0 - pow(1.0 - min(s, r) * 1.0 / max(s, r), 2);
    }
};

bool intersect(ad a, ad b) {
    if (a.right < b.left || b.right < a.left) {
        return false;
    }
    if (a.down < b.up || b.down < a.up) {
        return false;
    }
    return true;
}

vector<int> get_intersect(ad b, const vector<ad>& a) {
    int n = (int)a.size();
    vector<int> res;
    for (int i = 0; i < n; i++) {
        if (intersect(a[i], b)) {
            res.emplace_back(i);
        }
    }
    return res;
}

int main() {
    long long start_time = clock();
    int n;
    cin >> n;
    vector<ad> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y >> a[i].r;
        a[i].left = a[i].x;
        a[i].right = a[i].x + 1;
        a[i].up = a[i].y;
        a[i].down = a[i].y + 1;
    }
    vector<int> order(n);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](int i, int j) { return a[i].r < a[j].r; });

    auto modify = [&](int i, int k, int d = 1) {
        ad b = a[i];
        if (k >= 2) {
            a[i][k] += d;
        } else {
            a[i][k] -= d;
        }
        /*
        if (k == 0) {
            a[i].left -= d;
        } else if (k == 1) {
            a[i].up -= d;
        } else if (k == 2) {
            a[i].right += d;
        } else {
            a[i].down += d;
        }
        */
        bool ok = true;
        for (int j = 0; j < n; j++) {
            if (i != j && intersect(a[i], a[j])) {
                ok = false;
            }
        }
        if (min(a[i].left, a[i].up) < 0 || max(a[i].right, a[i].down) > 9999) {
            ok = false;
        }
        if (!ok) {
            swap(a[i], b);
        }
        return ok;
    };

    int tt = 10000;
    while (tt--) {
        long long now = clock();
        if (now - start_time > 4900 * 1000) {
#ifndef tabr
            break;
#endif
        }
        for (int i : order) {
            ad b = a[i];
            b.right++;
            double cur = a[i].score();
            double lr = b.score();
            b.right--;
            b.up--;
            double ud = b.score();
            vector<double> d(4);
            d[0] = d[2] = (lr - cur);
            d[1] = d[3] = (ud - cur);
            for (int k = 0; k < 4; k++) {
                b = a[i];
                if (k >= 2) {
                    b[k] = 9999;
                    b[k ^ 2] = a[i][k] + 1;
                } else {
                    b[k] = 0;
                    b[k ^ 2] = a[i][k] - 1;
                }
                vector<int> t = get_intersect(b, a);
                int c = 10000;
                for (int j : t) {
                    c = min(c, abs(a[i][k] - a[j][k ^ 2]));
                }
                d[k] *= c;
            }
            double mx = *max_element(d.begin(), d.end());
            if (mx <= 0) {
                continue;
            }
            for (int j = 0; j < 4; j++) {
                if (mx - d[j] < 1e-9) {
                    modify(i, j, 1);
                }
            }
        }
    }

    double t = 0;
    for (int i = 0; i < n; i++) {
        cout << a[i].left << " " << a[i].up << " " << a[i].right << " " << a[i].down << '\n';
        t += a[i].score();
    }
    cerr << fixed << setprecision(6);
    cerr << t / n * 1e9 << '\n';
    return 0;
}


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

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

//ll の最大値　2147483647≒10^9
//long longの最大値　9,223,372,036,854,775,807≒10^18

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
ll digit(ll x){
    ll d=0;
    while(x){
        d++;
        x/=10;
    }
    return d;
}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll a_ = abs(a);
    ll b_ = abs(b);
    bool c_2 = c%2;
    if(a<0 && c_2){
        a_ *= -1;
    }
    if(b<0 && c_2){
        b_ *= -1;
    }
    if(a_>b_){
        cout<<">"<<endl;
    }
    else if(a_<b_){
        cout<<"<"<<endl;
    }
    else{
        cout<<"="<<endl;
    }
}

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll INF = 2e18;
int n, m;
ll A[200005];
ll B[200005]; // それ以前の最小の金額
int X[200005], Y[200005];
vector<int> G[200005];
ll costs[200005]; // その町で買った時の最大金額

int main() {
  INCANT;
  cin >> n >> m;
  rep(i, n) cin >> A[i];
  rep(i, n) B[i] = INF;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    G[x-1].push_back(y-1);
  }
  rep(i, n) {
    for (auto ne: G[i]) {
      B[ne] = min(B[ne], B[i]); // すでに更新されているものと、今更新するもののどちらが低いか
      B[ne] = min(B[ne], A[i]); // 今の値と、前からきたものどちらが低いか
    }
  }

  ll ans = -INF;
  rep(i, n) {
    ans = max(ans, A[i]-B[i]);
  }

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


#pragma GCC optimize("Ofast")
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <cmath>
#include <iomanip>
#include <string>
#include <deque>
#include <assert.h>
#include <random>
#include <ctime>
#include <unordered_map>
#include <complex>
#include <chrono>

#define pnode node*

using namespace std;

typedef long long ll;
typedef long double ld;

ll n;
string t;

void zer() {
    cout << 0 << "\n";
    exit(0);
}

void solve(){
	cin >> n;
    cin >> t;
    ll ten = 10'000'000'000;
    if (t == "1") {
        cout << 2 * ten << "\n";
        return;
    } else if (t == "11") {
        cout << ten << "\n";
        return;
    }
    ll fst = -1;
    for (ll i = 0; i < t.size(); ++i) {
        if (t[i] == '0') {
            fst = i;
            break;
        }
    }
    if (fst == -1) {
        zer();
    }
    vector < ll > z(t.size());
    for (ll shft = 0; shft <= t.size(); ++shft) {
//		cerr << shft << "\n";
        ll l = fst - 3 * shft;
        ll r = fst + 3 * shft;
        if (l >= 0) {
            if (t[l] == '1') {
                zer();
            } else {
            	z[l] = 1;
            }
        }
        if (r < t.size()) {
            if (t[r] == '1') {
				zer();
            } else {
            	z[r] = 1;
            }
        }
    }
//    for (ll i = 0; i < z.size(); ++i) {
//		cerr << z[i] << " ";
//    }
//    cerr << "\n";
    for (ll i = 0; i < t.size(); ++i) {
        if (!z[i] && t[i] == '0') {
            zer();
        }
    }
    ll sz = t.size();
    if (t.size() >= 2 && t[0] == '1' && t[1] == '1') {
		sz -= 2;
    } else if (t[0] == '1') {
        sz--;
    }
    ll res = (3 * ten - 2 - sz) / 3 + 1;
    cout << res << "\n";
}

signed main(){
    ll t = 1;
    ios_base::sync_with_stdio(0);
    srand(time(0));
    cin.tie(0);
    cout.tie(0);
    cout << fixed;
    cout << setprecision(20);
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
    #endif
    while(t--){
        solve();
    }
}

//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define rrep(i,j,k) for(ll i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}
template<typename... T>
void write(T&&... args) {
	((cout << args << " "), ...);
}
template<typename... T>
void writen(T&&... args) {
	((cout << args << "\n"), ...);
}
ll bin(ll a, ll b, ll mod)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2 , mod) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2 , mod) % mod)) % mod;
}
void solve()
{
	ll n;
	read(n);
	ll ans = 0;
	rep(i, 0, n) {
		ll a, b;
		read(a, b);
		ans += b * (b + 1) / 2;
		ans -= a * (a - 1) / 2;
	}
	cout << ans;
} int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	ll t;
	t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}