#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define per(i,a,b) for(i=(a);i>=(b);--i)
#define REP(i,a,b) for(i=(a);i< (b);++i)
#define PER(i,a,b) for(i=(a);i> (b);--i)
#define ERR(...) fprintf(stderr,__VA_ARGS__)
template<class T>inline void cmn(T &x,const T &a){if(a<x)x=a;}
template<class T>inline void cmx(T &x,const T &a){if(x<a)x=a;}
template<class T>inline bool bmn(T &x,const T &a){if(a<x){x=a;return true;}else return false;}
template<class T>inline bool bmx(T &x,const T &a){if(x<a){x=a;return true;}else return false;}

const int p=998244353;
inline void add(int &x){if(x>=p)x-=p;}
#define MUL(a,b) ((0ll|(a))*(b)%p)

const int MAXN=101,MAXS=5005;
int Fc[MAXN],W[MAXN],F[MAXN][MAXS];
signed main(){
#ifdef ONLINE_JUDGE
	//freopen("problemname.in","r",stdin);
	//freopen("problemname.out","w",stdout);
#endif
	int N;
	scanf("%d",&N);
	int i,s=0;
	{
		int m=0,a;
		REP(i,0,N){
			scanf("%d",&a);
			cmx(m,a);s+=a;W[i]=a;
		}
		if((s&1)||m>(s>>1)){
			puts("0");
			return 0;
		}
	}
	int goal=(s>>1);
	Fc[0]=s=1;rep(i,1,N)Fc[i]=s=MUL(s,i);
	sort(W,W+N);
	int a,b,w;
	s=0;F[0][0]=1;
	REP(i,0,N){
		w=W[i];
		per(a,i,0)per(b,min(s,goal-w),0)add(F[a+1][b+w]+=F[a][b]);
		s+=w;
	}
	ll Ans=0ll;
	rep(i,0,N)if(a=F[i][goal])Ans=(Ans+a*MUL(Fc[i],Fc[N-i]))%p;
	printf("%d\n",int(Ans));
	return 0;
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

constexpr ll mod = 1e9 + 7;

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

    rep(t, T) {
        ll N, A, B;
        cin >> N >> A >> B;

        if (N - A - B < 0) {
            cout << 0 << endl;
            continue;
        }

        ll a = ((N-A+1) * (N-A+1) % mod) * ((N-B+1) * (N-B+1) % mod);
        a %= mod;
        ll b = ((N-A+1)*(N-B+1)%mod) - ((N-A-B+2)*(N-A-B+1)%mod);
        b = (b + mod) % mod;

        cout << (((a - (b*b)%mod)+mod) % mod) << endl;
    }

}


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

int main()
{
    int n;
    cin >> n;
    if(n%2==0){
        cout << "White" << endl;
    }else{
        cout << "Black" << endl;
    }

}

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef double d;
typedef long double ld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<d> vd;
typedef vector<ld> vld;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int n;
  cin >> n;
  if(n%2==0) cout << "White" << endl;
  else cout << "Black" << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> G[n];
    for (int i = 0; i < n - 1; ++i) {
        int p;
        cin >> p;
        --p;
        G[p].push_back(i + 1);
    }
    vector<int> f(n, 1);
    vector<int> sz(n, 1);
    function<void(int)> dfs = [&](int u) {
        if (G[u].size() == 0) {
            f[u] = 1;
            sz[u] = 1;
            return;
        }
        vector<pair<int, int>> odd;
        vector<int> even;
        for (int i = 0; i < G[u].size(); ++i) {
            int v = G[u][i];
            dfs(v);
            sz[u] += sz[v];
            if (sz[v] % 2 == 0) {
                if (sz[v] - f[v] >= f[v]) {
                    f[u] += f[v];
                } else {
                    even.push_back(v);
                }
            } else {
                odd.push_back(make_pair(sz[v] - f[v] - f[v], v));
            }
        }
        sort(odd.begin(), odd.end());
        reverse(odd.begin(), odd.end());
        for (int i = 0; i < odd.size(); ++i) {
            int v = odd[i].second;
            if (i % 2 == 0) {
                f[u] += f[v];
            } else {
                f[u] += sz[v] - f[v];
            }
        }
        for (int i = 0; i < even.size(); ++i) {
            int v = even[i];
            if (odd.size() % 2 == 1) {
                f[u] += sz[v] - f[v];
            } else {
                f[u] += f[v];
            }
        }
    };
    dfs(0);
    cout << f[0] << endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> p(n);
  vector<vector<int>> tree(n);

  rep(i,n-1){
    int p; cin >> p; p--;
    tree[p].push_back(i+1);
  }

  /*
  頂点vを根とした木で考えたときの chokudaiさんのスコア - kenshoさんのスコア = f(v) とする
  頂点vを根とした木の大きさ = g(v)

  頂点vからどの子に移動するのが最適か
  vの子供uにおいて

  g(u) %2 == 1
  => -f(u)して、手番が逆になる

  else
  => -f(u)して、もう一回動かせる

  から、 f(u)が小さい順に選ぶ？

  1. f(u)<0 かつ、g(u)%2 == 0
  2. g(u)%2 == 1 のもののf(u)
    3. (f(u)>=0 かつ、g(u)%2 == 0)の合計 の昇順
  //*/

  vector<int> f(n, 1), g(n, 1);

  auto dfs = [&](auto self, int v=0) -> void{
    vector<int> p;
    int sum = 0;
    for(auto&&u : tree[v]){
      self(self, u);
      g[v] += g[u];

      if(g[u]%2 == 0){
        if(f[u] < 0) f[v] += f[u];
        else sum += f[u];
      }else{
        p.push_back(f[u]);
      }
    }
    sort(p.begin(), p.end());
    int turn = -1;
    for(auto&&x : p){
      f[v] -= x * turn;
      turn *= -1;
    }
    f[v] -= sum * turn;
  };

  dfs(dfs);

  /*
  a + b = n
  a - b = f[0]
  a = (n + f[0])/2
  //*/

  cout << (n + f[0])/2 << endl;
}


#include <bits/stdc++.h>
using namespace std;
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) {
    scan(head);
    IN(tail...);
}
#define all(a) a.begin(),a.end()
#define Srep(n) for(int64_t i = 0; i < int64_t(n); i++)
#define Lrep(i,a,n) for(int64_t i = int64_t(a); i < int64_t(n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2d(n,m) Srep(n) Lrep(j,0,m)
#define vec(type,name) vector<type> name
#define vecc(type,name,...) vector<type> name(__VA_ARGS__)
#define vvec(type,name,size,...) vector<vector<type>> name(size, vector<type>(__VA_ARGS__))
#define scan(...) IN(__VA_ARGS__)
#define intscan(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define i64scan(...)\
    int64_t __VA_ARGS__;\
    IN(__VA_ARGS__)
#define charscan(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define strscan(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define vecscan(type,name,size)\
    vector<type> name(size);\
    IN(name)
#define vvecscan(type,name,size1,size2)\
    vector<vector<type>> name(size1, vector<type>(size2));\
    IN(name)

int main(){
    i64scan(a,b,c);
    int64_t ans = 0;
    int64_t sa = a * (a + 1) / 2;
    sa %= 998244353;
    int64_t sb = b * (b + 1) / 2;
    sb %= 998244353;
    ans = sa * sb % 998244353;
    int64_t sc = c * (c + 1) / 2;
    sc %= 998244353;
    ans = ans * sc % 998244353;
    cout << ans << endl;
    return 0;
}

#include <iostream>
#define DENOM 998244353

using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    cout << ((((a*(a+1)/2)%DENOM) * ((b*(b+1)/2)%DENOM))%DENOM * ((c*(c+1)/2)%DENOM))%DENOM << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#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...);
}
#else
#define trace(...)
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100002;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
vector<pair<int,int>> g[maxn];
int c[maxn], d[maxn];
vector<int> djikstra(ll src,ll n)
{
  priority_queue< pair<int,int>, vector <pair<int,int>> , greater<pair<int,int>> > pq;
  vector<ll> dist(n+1, 1e18),vis(n+1,0);
  pq.push(make_pair(0, src));
  dist[src] = 0;
  while (!pq.empty())
  {
      ll u = pq.top().second;
      pq.pop();
      if(vis[u]) continue;
      vis[u] = 1;

      for (auto i:g[u])
      {
          ll v = i.first;
          ll x = dist[u], D = d[i.second];
          ll C = c[i.second];
          ll weight = 1e15;

          int temp = sqrtl(D);
          for(int t = max(0ll, -x + temp - 2); t<=-x + temp + 2;t++){
          		weight = min(weight, C + (t + D/(x + t + 1)));
          }

          weight = min(weight, C + (0LL + D/(x + 0LL + 1)));

          if (dist[v] > dist[u] + weight)
          {
              dist[v] = dist[u] + weight;
              pq.push(make_pair(dist[v], v));
          }
      }
  }
  return dist;
}
int32_t main()
{
  IOS

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

  	for(int i = 1;i<=m;i++){
  		int a, b;
  		cin >> a >> b >> c[i] >> d[i];

  		g[a].push_back({b, i});
  		g[b].push_back({a, i});
  	}

	int ans = djikstra(1, n)[n];
	if(ans >=1e15) ans = -1;
	cout << ans << endl;

}

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

#define int long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const int MOD=(int)1e9+7;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("teamwork.in","r",stdin);
    //freopen("teamwork.out","w",stdout);
    int n;
    cin>>n;
    vector<pair<int,pair<int,int>>> v;
    for(int i=0;i<n;i++) {
        int a,b,c;
        cin>>a>>b>>c;
        v.push_back({a,{b,c}});
    }
    sort(all(v));
    int t=0,ans=MOD;
    for(int i=0;i<n;i++){
        t+=v[i].first-t;
        if(v[i].second.second-t>=1) ans=min(ans,v[i].second.first);
    }
    if(ans!=MOD) cout<<ans;
    else cout<<-1;
}


#include<bits/stdc++.h>
#define deb(x) cout<<#x<<" "<<x<<endl;
#define int long long

using namespace std;
const int mod = 1e9 + 7;
const int MAX = 2e5+ 5;
const int N = 5e4 + 5;
vector< pair<int,int> >a[N];
vector<int>g[MAX];

int mypow(int x, int n ){

	if(n == 0){
		return 1;
	}

	int xn2 = mypow(x,n/2)%mod;
	int xn = xn2*xn2;
	xn%=mod;
	if(n & 1){
		xn = (xn%mod * x%mod)%mod;
	}

	return xn;
}

void solve(){

  vector<int>temp(3);
  for(int i =0 ; i < 3 ; i ++)cin >> temp[i];
  sort(temp.begin(),temp.end());

  cout<<temp[2] + temp[1]<<endl;

}

signed main(){

 	int t = 1;
// 	 cin >> t;

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

	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<(n-a)+b;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, t[50];

int main(){
	string ch;
	cin >> ch;
	for(int i = 1;i < ch.size();i++)cout << ch[i];
	cout << ch[0];
}

#include<bits/stdc++.h>
using namespace std;
int main(){
int x;
cin>>x;
if(x<0){cout<<'0';}
else if(x>0){cout<<x;}
else if(x==0){cout<<'0';}
return 0;}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) {
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) {
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(void) {
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll cur = 1;
    ll ret = 0;
    while(1) {
        ll x = stoll(to_string(cur)+to_string(cur));
        if(x>n) break;
        cur++;
        ret++;
    }
    cout << ret << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007ll
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using pii = pair<int, int>;
const int INF = 1001001001;
//fixed << setprecision(n) 小数点以下n桁の表示(cout)

int main() {
    ll n; cin >> n;
    for (int i = 1; true; i++) {
        if (stoll(to_string(i) + to_string(i)) > n) {
            cout << i - 1 << endl;
            return 0;
        }
    }
    return 0;
}


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

#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

struct Conbinatorics
{
    int _max_N;
    const int _mod;
    const bool _pre_caluculation;
    int *_F, *_R;
    Conbinatorics(int n, int mod=1000000007, bool pre_calculation=true)
        : _max_N(2 * n)
        , _mod(mod)
        , _pre_caluculation(pre_calculation)
        {
            _F = new int[_max_N + 1];
            _F[0] = 1;
            for(int i = 1; i <= _max_N; i++)_F[i] = _F[i - 1] * i % mod;

            if(pre_calculation)
            {
                _R = new int[_max_N + 1];
                for(int i = 0; i <= _max_N; i++)_R[i] = inv(_F[i]);
            }
        }

    ~Conbinatorics()
    {
        delete[] _F;
        if(_pre_caluculation) delete[] _R;
    }

    int pow_mod(int a, int b)
    {
        if(b == 0)return 1;
        int ret = pow_mod(a * a % _mod, b / 2);
        if(b % 2 == 1)ret = ret * a % _mod;
        return ret;
    }

    int inv(int x) { return pow_mod(x, _mod - 2); }

    int P(int a, int b)
    {
        if(a < b)return 0;
        if(b < 0)return 0;
        if(_pre_caluculation) return _F[a] * _R[a - b] % _mod;
        else return _F[a] * inv(_F[a - b]) % _mod;
    }

    int C(int a, int b)
    {
        if(a < b)return 0;
        if(b < 0)return 0;
        if(_pre_caluculation) return P(a, b) * _R[b] % _mod;
        else return P(a, b) * inv(_F[b]) % _mod;
    }

    int H(int a, int b){ return C(b + a - 1, a - 1); }
};

int N, K;
int A[200010];
const int mod = 998244353;
int mem[310];
int P[200010];
Conbinatorics con(1010, mod);

signed main()
{
    cin >> N >> K;

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

    rep(i, N)P[i] = 1;
    rep(i, K + 1)
    {
        rep(j, N)
        {
            mem[i] = (mem[i] + P[j]) % mod;
            P[j] = P[j] * A[j] % mod;
        }
    }

    rep(i, N)P[i] = 1;

    for(int i = 1; i <= K; i++)
    {
        int ans = 0;
        rep(j, N)P[j] = P[j] * 2 * A[j] % mod;

        rep(j, i + 1)
        {
            ans = (ans + con.C(i, j) * mem[j] % mod * mem[i - j]) % mod;
        }

        rep(j, N)ans = (ans - P[j] + mod) % mod;

        ans = ans * con.pow_mod(2, mod - 2) % mod;

        cout << ans << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define nline "\n"
const ll M1=1e9+7;
const ll M2=998244353;
const ll N=1000005;
const ll INF_MUL=1e13;
const ll INF_ADD=1e18;
#define f first
#define s second
#define pll pair<ll,ll>
#ifndef ONLINE_JUDGE
#define debug(x) cerr<<#x<<" "; _print(x); cerr<<nline;
#else
#define debug(x);
#endif
void _print(ll x){cerr<<x;}
template<class T,class V> void _print(pair<T,V> p) {cerr<<"{"; _print(p.first);cerr<<","; _print(p.second);cerr<<"}";}
template<class T>void _print(vector<T> v) {cerr<<" [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T>void _print(set<T> v) {cerr<<" [ "; for (T i:v){_print(i); cerr<<" ";}cerr<<"]";}
template<class T>void _print(multiset<T> v) {cerr<< " [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T,class V>void _print(map<T, V> v) {cerr<<" [ "; for(auto i:v) {_print(i);cerr<<" ";} cerr<<"]";}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void solve(){
    ll l,r,final=0; cin>>l>>r;
    vector<ll> ans(r+5,0),bad(r+5,0);
    for(ll i=r-1;i>=2;i--){
        ans[i]=r/i-(l-1)/i-(i>=l);
        bad[i]=r/i-(l-1)/i;
        bad[i]=bad[i]*(bad[i]-1);
        ans[i]=ans[i]*(ans[i]-1);
        for(ll j=i+i;j<=r;j+=i){
            ans[i]-=bad[j];
            bad[i]-=bad[j];
        }
        final+=ans[i];
    }
    cout<<final;
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    ll test_cases=1;
    //cin>>test_cases;
    while(test_cases--){
        solve();
    }
    /*
    Correct data type?
    Infinity?
    Base case?
    */
    cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
}


/* これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました */

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int n;
	cin>>n;
	ll s[2]={0,0};
	map<ll,int> m;
	ll ans=0;
	m[0]=1;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		s[i%2]+=a;
		ans += m[s[0]-s[1]];
		m[s[0]-s[1]]++;
	}
	cout<<ans<<'\n';
}

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

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return ;
}

typedef unsigned long long uLL;
typedef long long LL;

LL a[300010], t[300010];
LL n, ans;

int lowbit(int x) { return x & -x; }

void modify(int x, LL d) {
    while (x <= n) {
        t[x] += d;
        x += lowbit(x);
    }
    return ;
}

LL query(int x) {
    LL s = 0;
    while (x) {
        s += t[x];
        x -= lowbit(x);
    }
    return s;
}

int main() {
    read(n);
    for (int i = 1; i <= n; ++i)    read(a[i]);
    for (int i = n; i >= 1; --i) {
        ans += query(a[i] + 1);
        modify(a[i] + 1, 1);
    }
    printf("%lld\n", ans);
    for (int i = 1; i < n; ++i) {
         ans = ans + n - a[i] - a[i] - 1;
         printf("%lld\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

struct UF{
    int n;
    vector<int> par,size,edge;

    void init(int n_){
        n=n_;
        par.assign(n,-1);
        size.assign(n,1);
        edge.assign(n,0);

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

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

    void unite(int a,int b){
        edge[root(a)]++;
        if(root(a)!=root(b)){
            size[root(a)]+=size[root(b)];
            edge[root(a)]+=edge[root(b)];
            par[root(b)]=root(a);
        }
    }

    bool check(int a,int b){
        return root(a)==root(b);
    }
};

vector<int> S[MAX];
int from[MAX],to[MAX];

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;cin>>N;
    vector<int> A(N),B(N),p(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

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

    UF uf;
    uf.init(N);

    bool ok=true;

    for(int i=0;i<N;i++){
        cin>>p[i];p[i]--;
        uf.unite(i,p[i]);

        if(A[i]<=B[p[i]]&&i!=p[i]) ok=false;

        to[i]=p[i];
        from[p[i]]=i;
    }

    if(!ok){
        cout<<-1<<endl;
        return 0;
    }

    for(int i=0;i<N;i++){
        if(uf.root(i)!=i) continue;
    }

    for(int i=0;i<N;i++) S[uf.root(i)].push_back(i);

    vector<pair<int,int>> ans;

    for(int i=0;i<N;i++){
        sort(all(S[i]),[&](auto a,auto b){
            return B[a]>B[b];
        });

        for(auto x:S[i]){
            if(from[x]==x) continue;
            ans.push_back(mp(from[x],x));

            int a=from[x],b=to[x];

            to[a]=b;
            from[b]=a;

            from[x]=x;
            to[x]=x;
        }
    }

    cout<<si(ans)<<endl;

    for(auto x:ans) cout<<x.fi+1<<" "<<x.se+1<<endl;
}

#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#include <tuple>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000; //10^18
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

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

int main(void) {

  int n;
  int a[300];
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] = a[i] % 200;

  int b[300] = {};

  rep(i, n) b[a[i]]++;

  rep(i, 200) {
    if (b[i] > 1) {
      cout << "Yes" << endl;
      int cnt = 0;
      rep(j, n) {
	if (a[j] == i) {
	  cout << 1 << " " << j+1 << endl;
	  cnt++;
	  if(cnt == 2) return 0;
	}
      }
    }
  }

  if (n >8) n = 8;

    int c[300] = {};
    for (int i = 1; i < (1 << n); i++) {
      int d = 0;
      rep(j, n) {
	if ((i>>j) & 1) {
	  d += a[j];
	}
      }
      d %= 200;
      c[d]++;
    }
    int q = 0, z;
    rep(i, 200) {
      if (c[i] > 1) {
	q++;
	z = i;
	break;
      }
    }
    if (q == 0) {
      cout << "No" << endl;
      return 0;
    }

    cout <<"Yes"<<endl;

    vector<int> w[3];
    int ur = 0;
    for (int i = 1; i < (1 << n); i++) {
      int d = 0;
      rep(j, n) {
	if ((i>>j) & 1) {
	  d += a[j];
	}
      }
      d %= 200;
      if (d == z) {

	rep(j, n) {
	  if ((i>>j) & 1) {
	    w[ur].push_back(j+1);
	  }
	}
	cout << w[ur].size() << " ";
	rep(j, w[ur].size()) cout << w[ur][j] << " ";
	cout << endl;
	ur++;
	if (ur == 2) return 0;
      }
    }

}


//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
#define FAST_IO ios::sync_with_stdio(0);cin.tie(NULL)
#define all(v) (v).begin(),(v).end()
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long Long;
typedef long double Double;
typedef unsigned long long ULong;
typedef pair<Long, Long> Pair;

const int N = 100;
const Long INF = 1e18;
const Double EPS = 1e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
Long random(Long a, Long b) { return uniform_int_distribution<Long> (a, b) (rng); }

string s[N];
int n;
Long dp[N][2];
bool is_done[N][2];

Long DP(int i, bool was_true) {
  if (i == n) return (was_true) ? 1LL : 0LL;
  if (is_done[i][was_true]) return dp[i][was_true];
  if (s[i] == "AND") {
    if (was_true) {
      dp[i][was_true] = DP(i + 1, true) + DP(i + 1, false);
    } else {
      dp[i][was_true] = 2 * DP(i + 1, false);
    }
  } else {
    if (was_true) {
      dp[i][was_true] = 2 * DP(i + 1, true);
    } else {
      dp[i][was_true] = DP(i + 1, true) + DP(i + 1, false);
    }
  }
  is_done[i][was_true] = true;
  return dp[i][was_true];
}

void Solve(void) {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  Long ans = DP(0, true) + DP(0, false);
  cout << ans << '\n';
}

int main(void) {
  FAST_IO;
  int t = 1;
  //cin >> t;
  while (t--) Solve();
  return 0;
}

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

ll f(ll v){
  sz[v]=1;
  ll r=1;
  vector<ll> p1,p2,p3;
  for(ll nv:C[v]){
    ll b=f(nv);
    if(sz[nv]%2==0 && b<0)p1.push_back(b);
    else if(sz[nv]%2==0 && b>=0)p2.push_back(b);
    else p3.push_back(b);
    sz[v]+=sz[nv];
  }
  for(ll x:p1)r+=x;
  sort(p3.begin(),p3.end());
  ll flg=0;
  for(ll x:p3){
    if(flg%2==0)r+=x;
    else r-=x;
    flg++;
  }
  for(ll x:p2){
    if(flg%2==0)r+=x;
    else r-=x;
  }
  return r;
}

int main(){
  ll n,p;cin>>n;
  C.resize(n);sz.resize(n);
  for(ll i=1;i<n;i++){
    cin>>p;p--;
    C[p].push_back(i);
  }
  cout<<(n+f(0))/2<<endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define pb push_back
#define vi vector<int>
#define vl vector<long long>
#define fast  \
  cin.tie(0); \
  ios::sync_with_stdio(false);
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, int>;

struct UnionFind {
  vector<int> rank, par;
  UnionFind() {}
  UnionFind(int n) {
    rank.resize(n, 0);
    par.resize(n, 0);
    for (int i = 0; i < n; i++) {
      makeTree(i);
    }
  }
  void makeTree(int x) {
    par[x] = x;
    rank[x] = 0;
  }
  bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
  bool unite(int x, int y) {
    x = findRoot(x);
    y = findRoot(y);
    if (x == y) return false;
    if (rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
    return true;
  }
  int findRoot(int x) {
    if (x != par[x]) {
      par[x] = findRoot(par[x]);
    }
    return par[x];
  }
};

int main() {
  fast;
  int n, m;
  cin >> n >> m;
  vl a(n), b(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];
  UnionFind s(n);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    s.unite(a - 1, b - 1);
  }
  map<int, vi> g;
  rep(i, 0, n) g[s.findRoot(i)].pb(i);
  for(auto i:g){
    ll cnt = 0;
    ll cnt2 = 0;
    for(auto j:i.se){
      cnt += a[j];
      cnt2 += b[j];
    }
    if(cnt != cnt2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

#define fo(i, x, y) for (int i = (x); i <= (y); ++i)
#define fd(i, x, y) for (int i = (x); i >= (y); --i)

const int maxn = 2e5 + 5;

struct edge{int to, w; edge *nxt;}*arc1[maxn], *arc2[maxn], pool[maxn << 2], *pt = pool;
int n, m;
int ans[maxn];
bool vis[maxn];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

void addedge(edge *arc[], int u, int v, int w)
{
	*pt = (edge){v, w, arc[u]};
	arc[u] = pt++;
}

void gettr(int x)
{
	vis[x] = true;
	for (edge *e = arc1[x]; e; e = e->nxt)
		if (!vis[e->to])
		{
			addedge(arc2, x, e->to, e->w);
			gettr(e->to);
		}
}

void dfs(int x)
{
	for (edge *e = arc2[x]; e; e = e->nxt)
	{
		if (e->w != ans[x])
			ans[e->to] = e->w;
		else
			ans[e->to] = e->w - 1? e->w - 1 : e->w + 1;
		dfs(e->to);
	}
}

int main()
{
	n = getint(); m = getint();
	fo(i, 1, m)
	{
		int u, v, w;
		u = getint(); v = getint(); w = getint();
		addedge(arc1, u, v, w);
		addedge(arc1, v, u, w);
	}
	gettr(1);
	ans[1] = 1;
	dfs(1);
	fo(i, 1, n) printf("%d\n", ans[i]);
	return 0;
}


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

int main()
{
	long long int r,c;
    cin>>r>>c;
    char mat[r][c];
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            cin>>mat[i][j];
        }
    }
    long long int count=0;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(((mat[i][j]=='.' && mat[i+1][j]=='.') && i<=r-2) && ((mat[i][j]=='.' && mat[i][j+1]=='.') && j<=c-2 )  )
            {
                count=count+2;
            }
            else if(((mat[i][j]=='.' && mat[i+1][j]=='.') && i<=r-2) || ((mat[i][j]=='.' && mat[i][j+1]=='.') && j<=c-2) )
                count++;
        }
    }
    cout<<count<<endl;
	return 0;
}

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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

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) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

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

const int maxn = 100+10;
char A[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N,M; cin >> N >> M;
	forn(i,1,N+1){
		forn(j,1,M+1){
			cin >> A[i][j];
		}
	}
	int res = 0;
	forn(i,1,N+1){
		forn(j,1,M+1){
			if(A[i][j] == '.' && A[i][j+1] == '.')res++;
			if(A[i][j] == '.' && A[i+1][j] == '.')res++;
		}
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

bool isP(int n) {
    if(n <= 1) return 0;
    for(int i = 2; i*i <= n; i++)
        if(n%i == 0) return 0;
    return 1;
}

int main() {
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
    int x[n];

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

    vi p;
    ll ans = 1;

    for(int i = 2; i <= 50; i++) {
        if(isP(i)) {
            p.pb(i);
            ans *= i;
        }
    }

    int m = p.size();

    for(int i = 0; i < (1 << m); i++) {
        ll curr = 1;
        for(int j = 0; j < m; j++) {
            if((i >> j)&1) {
                curr *= p[j];
            }
        }

        bool comp = 1;
        for(int j = 0; j < n; j++) {
            if(__gcd((ll) x[j], curr) == 1) comp = 0;
        }

        if(comp) ans = min(ans, curr);
    }

	cout << ans;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define fornext(x, i) for(int i = head[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define mset(a, b) memset(a, b, sizeof(a))
#define Rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define dRep(i, a, b) for(int i = (a); i >= (b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define endl '\n'
#define int ll
#define un unsigned
#define ll long long
#define db double
#define rept cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
#define dbg cout<<"c "
#define dbug(x) cerr << #x " = " << (x) << endl
template<typename _T> inline void _prt(_T _d) { cerr << _d << ' '; }
template <typename _T, typename ...Args> inline void _prt(_T _d, Args ..._a) { _prt(_d), _prt(_a...); }
template <typename _T, typename ...Args> inline void prt(_T _d, Args ..._a) { _prt(_d), _prt(_a...), cerr << endl; }
template <typename _T, typename ...Args> inline void prt(_T _d) { cerr << _d << endl; }
template<typename _T> inline void rd(_T &_d) {
	signed _f; char _c; _f = _d = 0; while (_c = getchar(), !isdigit(_c)) _f = _f || (_c == '-');
	while (isdigit(_c)) _d = _d * 10 + _c - '0', _c = getchar();
	_d = (_f ? -_d : _d);
}
template <typename _T, typename ...Args> inline void rd(_T &_d, Args &..._a) { rd(_d); rd(_a...); }

// const int N=
int n,a[55],p[50],d[55],c[55],l=-1;

signed main() {
	rd(n);
	Rep(i,1,n) rd(a[i]);
	int tp,x;
	Rep(i,2,50) {
		tp=sqrt(i),x=i;
		Rep(j,2,tp) while(x%j==0) x/=j;
		if(x==i) p[++l]=i,c[i]=1;
	}
	++l;
	Rep(i,2,50) {
		Rep(j,0,l-1) if(i%p[j]==0) {
			d[i]|=(1<<j);
		}
		// prt(i,d[i]);
	}
	int win,ans=0;
	// Rep(i,1,n) prt(d[a[i]]);
	Rep(i,0,(1<<l)-1) {
		win=1,tp=1;
		Rep(j,1,n) if(!(d[a[j]]&i)) win=0;
		if(win) {//prt(i);
			Rep(j,0,l-1) if((i>>j)&1) tp*=p[j];
			ans=ans?min(ans,tp):tp;
		}
	}
	cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, k, m;
llong sum;

int main() {
    cin >> n >> k >> m;
    for (int i = 0; i < n - 1; i++) {
        llong a;
        cin >> a;
        sum += a;
    }

    if ((n * m) - sum > k) {
        cout << -1 << endl;
    }
    else {
        cout << max(0ll, (n * m) - sum) << endl;
    }

    return 0;
}

#include<bits/stdc++.h>
#define G getchar();getchar();
using namespace std;
const double eps = 0.0000001;
void solve()
{
    double a,b,c;
    cin>>a>>b>>c;
    double d=sqrt(b*b+c*c);
    int i=0;
    while(d>2*a)//d==2*a
    {
        d-=a;
        i++;
    }
    if(d==a)//d==a
    {
        i+=1;
    }
    else    i+=2;
    cout<<i;
    G
}
int main()
{
    solve();
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    long long prefix_sum = 0; // A[0] - A[1] + A[2] - A[3] + ...
    map<long long, int> count;
    count[0] = 1;
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            prefix_sum += A[i];
        } else {
            prefix_sum -= A[i];
        }
        ans += count[prefix_sum];
        ++count[prefix_sum];
    }
    cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T>>;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<ld,ld>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    V<ll> sum(n+1);
    rep(i,n){
        if(i%2==0) sum[i+1] = sum[i] + a[i];
        else sum[i+1] = sum[i] - a[i];
    }
    map<ll,ll> mp;
    rep(i,n+1){
        mp[sum[i]]++;
    }
    ll ans = 0;
    //rep(i,n+1) cout << sum[i] << ' ';
    //cout << endl;
    for(auto p : mp){
        //cout << p.first << ' ' << p.second << endl;
        ans += p.second*(p.second-1)/2;
    }
    cout << ans << endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <set>
#include <math.h>

typedef long long ll;
using  namespace  std;

int main() {

    int a,b,c;
    cin>>a>>b>>c;
    if (c==0){
        if(a>=b+1) cout<<"Takahashi"<<endl;
        else cout<<"Aoki"<<endl;
    }else{
        if(b>=a+1)cout<<"Aoki"<<endl;
        else cout<<"Takahashi"<<endl;
    }

    return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long a[3];
void solve()
{
    sort(a,a+3);
    if (2*a[1]==a[2]+a[0]) puts("Yes");
    else puts("No");
}
int main()
{
    while(cin>>a[0]>>a[1]>>a[2])
        solve();
}


#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
//Do DEBUG OR NOT
#define DEBUG

#ifdef DEBUG
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#else
#define debug(...) true
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

//prototype declaration
ll pow_mod(ll n, ll k, ll m);//繰り返し二乗法 return val:(n^k)%m
ll gcd(ll a, ll b);//最大公約数 2引数
ll ngcd(vector<ll> a);
ll lcm(ll a, ll b);//最小公倍数 2引数
ll nlcm(vector<ll> numbers);
bool isPrime(ll x);//素数判定
ll digsum(ll n);//桁和
vector<ll> enum_div(ll n);//約数全列挙
ll stringcount(string s, char c);//特定文字カウント

//__________________________main__________________________

int main(){
    int n;

    cin>>n;
    int div=n/100;
    if(n%100==0){
        cout<<div<<endl;
    }else{
        cout<<div+1<<endl;
    }
    return 0;
}

//__________________________functions_____________Ctrl+K,Ctrl+0
//繰り返し二乗法関数
ll pow_mod(ll n, ll k, ll m){//r:(n^k)%m
    ll r=1;
    for(;k>0;k=k>>1){
        if(k&1) r=(r*n)%m;
        n = (n*n) % m;
    }
    return r;
}
//最大公約数 2引数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最大公約数 n引数
ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
//最小公倍数 2引数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
//最小公倍数 n引数
ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}
//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}
//桁和
ll digsum(ll n) {
    ll res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}
//約数全列挙
vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}
//特定文字カウント
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

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


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

typedef long long ll;

int main(){
  string x;
  ll m;
  cin >> x >> m;
  ll d = 0, lm = 9223372036854775807;
  for(char pp : x){ d = max(d, (ll)(pp - '0') ); }
  if(x.size() == 1){
    if((ll)(x[0] - '0') <= m) {cout << 1; return 0;}
  	else {cout << 0; return 0;}
  }
  ll mind = d, maxd = m;
  while(mind < maxd){
    ll nu = (mind + maxd)/2, tm = 0;
    int f=0;
    for(char xi : x){
      if(tm >= (lm-10)/nu){ f = 1; break;}
      tm *= nu;
      tm += (ll)(xi - '0');
    }
    if(f == 1 || tm > m) maxd = nu - 1;
    else mind = nu + 1;
  }
  ll ddd = 0, dnu = mind, f = 0;
  for(char xi : x){
      if(ddd >= (lm-10)/dnu){ f = 1; break;}
      ddd *= dnu;
      ddd += (ll)(xi - '0');
    }
  maxd = mind;
  if(f == 0 && ddd <= m) {if(maxd < d) {cout << 0;} else {cout <<  maxd - d;} }
  else { if(maxd >= d+1) {cout << maxd - d - 1;} else { cout << 0; } }
  return 0;
}

# include <cstdio>
# include <cstring>

namespace Main {
    namespace Source {
        typedef short unsigned int hu;
        typedef long long unsigned int llu;
        static inline const hu max(const hu a, const hu b) { return a < b ? b : a; }
        static inline const void amax(hu& a, const hu b) { a = max(a, b); }
    }
    using namespace Source;
    enum { X = 60 };
    static char x[X + 1];
    static hu log, mx;
    static llu m;
    static inline const bool check(const llu k) {
        llu r(0), b(1);
        for (hu i(1); i <= log; ++i, b *= k) {
            if ((m - r) / b < (const llu)(x[log - i] - '0')) return false;
            r += b * (x[log - i] - '0');
            if (i < log and m / b < k) return false;
        }
        return true;
    }
    static inline const void main() {
        scanf("%s%llu", x, &m), log = strlen(x);
        for (hu i(0); i < log; ++i) amax(mx, x[i] - '0');
        if (mx > m) return (const void)puts("0");
        if (log == 1) return (const void)puts("1");
        llu l(mx), r(m + 1);
        while (r - l > 1) (check((l + r) / 2) ? l : r) = (l + r) / 2;
        printf("%llu\n", l - mx);
    }
}

signed int main() { Main::main(); return 0; }


#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

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

#define fo(i,n) for(int i = 0; i < n; i++)
#define parr(a,n) fo(i,n){cout << a[i] << " ";}cout<<"\n"
#define sarr(a,n) fo(i,n)cin >> a[i]
#define pb push_back
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define ps(x,y) fixed<<setprecision(y)<<x //cout << ps(ans, decimal places);
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
typedef pair<int, int> pi;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long long int ll;
typedef unsigned long long int  ull;
typedef priority_queue<ll> mxhpl;
typedef priority_queue<int> mxhpi;
typedef priority_queue<ll, vector<ll>, greater<ll>> mnhpl;
typedef priority_queue<int, vector<int>, greater<int>> mnhpi;

// DEBUGGING
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V>& x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; }
template<typename T>
void __print(const T& x) { int f = 0; cerr << '{'; for (auto& i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; }
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// Fast IO
void IO() {
  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
}

#define MOD 1000000007

//CODE
/*******************************************************/

ll n, w;
ll req[200001];
ll pre[200001];

void solve() {
  memset(req, 0, sizeof(req));
  memset(pre, 0, sizeof(pre));

  cin >> n >> w;
  ll mx = 0;
  ll s, t, p;
  fo(i, n) {
    cin >> s >> t >> p;
    mx = max(mx, t);
    // s--;
    // t--;

    req[s] += p;
    req[t] -= p;
  }

  pre[0] = req[0];
  // debug(pre[0]);
  fo(i, mx) {
    if (i != 0) pre[i] = pre[i - 1] + req[i];
    if (pre[i] > w || pre[i] < 0) {
      // debug(pre[i-1], i-1, pre[i], i, req[i]);
      cout << "No\n";
      return;
    }

  }

  cout << "Yes\n";
}

int main() {
  IO();
  int t = 1;

  // cin >> t;

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

  return 0;
}

/*******************************************************/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <random>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>

//#include <atcoder/all>

#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[8]={-1,0,1,0,1,1,-1,-1},dy[8]={0,1,0,-1,1,-1,1,-1};

//using namespace atcoder;

int n;
string s;
vi a;

int main(){
	cin>>n>>s;
	a=vi(n+1);
	for(auto &i:a) cin>>i;
	int k=inf;
	for(int i=0;i<n;i++) k=min(k,abs(a[i]-a[i+1]));
	cout<<k<<endl;
	for(int i=0;i<k;i++){
		for(int j=0;j<=n;j++){
			cout<<a[j]/k+(i<a[j]%k?1:0)<<" \n"[j==n];
		}
	}
}


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

bool con7(int n){
  int t = n;
  while(t>0){
    if(t%10 == 7) return 0;
    t /= 10;
  }
  while(n>0){
    if(n%8 == 7) return 0;
    n /= 8;
  }
  return 1;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep1(i,n) ans += con7(i);
  cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int x=a+b,y=b+c,z=a+c;
	int m=max(x,y);
	int n=max(m,z);
	cout<<n;
	return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for(int i=int(n-1);i>=int(0);--i)
#define fore(i,a) for(auto &i:a)
#define all(x) x.begin(),x.end()
#define sz(x) ((int)(x).size())
#define bp(x) (__builtin_popcount((long long)(x)))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define V vector
#define P pair<int,int>
#define TP tuple<int,int,int>
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1001001001;
const ll INFL = 1001001001001001001;
const int MAX = 2e6+1;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-min({a,b,c})<<endl;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int temp,sum = 0;
  for (int i = 0; i < n; i++){
    cin >> temp;
    if (temp > 10){
      sum += temp -10;
    }
  }
  cout << sum << endl;

  return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;

int n;
vector<vector<int>> a;

bool is_ok(int x){
    bool res = false;
    set<int> s;
    rep(i,n){
        int y = 0;
        rep(j,5){
            if(a[i][j] >= x){
                y |= 1<<j;
            }
        }
        s.insert(y);
    }
    for(auto i:s)for(auto j:s)for(auto k:s){
        if((i|j|k) == (1<<5)-1){
            res = true;
        }
    }
    return res;
}

int l=1,r=1009009009;

void bs(){
    if(r-l==1) return;

    int m = (l+r)/2;
    if(is_ok(m)){
        l = m;
    }
    else{
        r = m;
    }

    bs();
}

int main(){
    cin >> n;
    a.resize(n,vector<int>(5));

    rep(i,n)rep(j,5){
        cin >> a[i][j];
    }

    bs();

    cout << l << endl;

}


#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;
typedef vector<string> vs;
#define deb(x) cout << #x": " << (x) << endl;

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}
lli lcm(lli a, lli b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
int popcount(lli x) { return __builtin_popcountll(x); }

 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

lli poww(lli a, lli b){
	lli res =1;
	while(b){ if(b&1) res = res * a; a = a*a; b/=2; }
	return res;
}
bool isPrime(lli x){
	if(x==1 or (x%2==0 and x>2))return 0;
	for(lli i = 3; i*i<=x; i+=2)if(x%i==0)return 0;
	return 1;
}
vi sieve(int N){
	vi m(N+1,0);
	vi primes(1,2);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
	return primes;
}
int dx[4]={0,0,1,-1}, dy[4]={1,-1,0,0};
vvi graph(int n, int m, bool dir=1){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		if(dir)v[b].pb(a);
	}
	return v;
}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
// ---- コーディングはここから！ ('-')7

void solve(){
	int n; cin>>n;
	vl v(n); fore(i,0,n)cin>>v[i];
	vl pre(n+1,0); fore(i,0,n)pre[i+1]=pre[i]+v[i];
	lli sum =0;
	lli mx = 0;
	lli m = 0;
	fore(i,0,n){
		m = max(m,pre[i]);
		mx = max(mx,sum+m),sum=sum+pre[i+1];
	}
	mx=max(mx,sum);
	cout<<mx<<ENDL;

}

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

#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

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

ll temp1,temp2,temp;
char tempc;

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

#define N 1000000009
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define vi vector<int>

ll binpow(ll a, ll b)
{
    a%=N;b=b%(N-1);
    ll res=1;
    while(b>0)
    {
        if(b&1) res=res*a%N;
        a=a*a%N;
        b>>=1;
    }
    return res%N;
}

int simpow(int a,int b)
{
    // b=b%(N-1);
    ll res=1;
    while(b>0)
    {
        if(b&1) res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

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

int mini(int a,int b)
{
    if(a<b) return a;
    return b;
}

int maxi(int a,int b)
{
    if(a>b) return a;
    return b;
}

struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n+1);
        parent.resize(n+1);
        for (int i = 1; i <= n; i++) make_set(i);
    }
};

signed main() {

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("inputf.in", "r", stdin);
    // for writing output to output.txt
    freopen("outputf.in", "w", stdout);
    #endif

    string s; cin >> s;
    int l = s.length(); bool flag = true;
    forn(i,l) {
        if(i%2==0){
            if(isupper(s[i])) flag = false;
            // break;
        }
        else {
            if(islower(s[i])) flag=false;
            // break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define gcd(a,b) __gcd(a,b)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) (int)a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterator
#define SET setprecision
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
#define mod1 1000000007
#define mod2 998244353
#define infmod 9223372036854775783
#define tc int t;cin>>t;while(t--)solve();
#define over(x) {cout<<x<<endl;return;}
#define intsz(x) (int)sz(to_string(x))
using namespace std;
int n;
int c[100005];
vector<int>ver[100005];
bool flag[100005];
V<int>ans;
void dfs(int x,int fx){
	if(!flag[c[x]])
	ans.pb(x+1);
	bool f=flag[c[x]];
	flag[c[x]]=1;
	REP_sz(i,ver[x])if(ver[x][i]!=fx)dfs(ver[x][i],x);
	flag[c[x]]=f;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	cin>>n;
	REP(i,0,n)cin>>c[i];
	REP(i,0,n-1){
		int a,b;
		cin>>a>>b;
		ver[a-1].pb(b-1);
		ver[b-1].pb(a-1);
	}
	dfs(0,-1);
	SO(ans);
	REP(i,0,ans.size())cout<<ans[i]<<endl;
    return 0;
}

#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define um          unordered_map<ll,ll>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
//#define M           998244353
#define yes       cout<<"Yes"<<'\n';
#define no        cout<<"No"<<'\n';
#define C         continue;
#define pa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define pv(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define pvp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll MAXN = 1e7+1;
const ll N = 100;
const dd eps = 1e-14;

ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }
ll power(ll x, ll y)
{
    ll res=1;
	x%=M;
    while(y>0)
    {
        if(y&1)
        res=res*x;
        res%=M;
        y=y>>1;
        x=x*x;
        x%=M;
    }
    return res;
}

set<ll>s;
map<ll,ll>m;
vector<vi>v;
vi a;
void dfs(ll n,ll p)
{
	ll t=a[n];
	if(m[t]==0)
	{
		s.insert(n);
		m[t]=n;
	}
	for(auto i:v[n])
	{
		if(i!=p)
		dfs(i,n);
	}
	t=a[n];
	if(m[t]==n)
	m[t]=0;
}
signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,i;
		cin>>n;
		a=vi(n+1);
		fo(i,1,n+1)
		{
			cin>>a[i];
		}
		v=vector<vi>(n+1);
		fo(i,0,n-1)
		{
			ll a,b;
			cin>>a>>b;
			v[a].pb(b);
			v[b].pb(a);
		}
		dfs(1,-1);
		for(auto i:s)
		cout<<i<<u;
	}
	return 0;
}


#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

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

    vector<ll> nodes(n);
    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        nodes[a] |= (1ULL << b);
        nodes[b] |= (1ULL << a);
    }

    vector<ll> dp((1ULL << n), INF);  // INF*2でもオーバーフローしないこと

    // 完全グラフかどうか調査 O(2^n)
    // もうちょい雑にやるなら O(n * 2^n) , O(n^2 * 2^n) とかのほうが楽
    ll msb = 1;
    ll msb_node = 0;
    for (ll i = 1; i < ll(1ULL << n); i++) {
        if ((msb << 1) <= i) {
            msb = msb << 1;
            msb_node++;
        }
        ll rest = msb ^ i;
        if (rest == 0) {
            dp[i] = 1;
        } else if ((nodes[msb_node] & rest) == rest && dp[rest] == 1) {
            dp[i] = 1;
        }
    }

    // j<=i, rest<=i なのでトポロジカル順序にはなっている
    for (ll i = 0; i < ll(1ULL << n); i++) {
        // 部分集合の列挙 (O(3^n) / n=18 -> 3^n≒3.9e8)
        // https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361
        for (ll j = i;; j = (j - 1) & i) {
            ll rest = i ^ j;  // 残り
            dp[i] = min(dp[i], dp[j] + dp[rest]);
            if (!j) break;
        }
    }
    print(dp[(1ULL << n) - 1]);
}

#include <bits/stdc++.h>
#define nput(a) cout << a << endl
#define sput(a) cout << a << ' '
using namespace std;
typedef long long ll;
const int maxn = 110;
int a[maxn], b[maxn];
int c[17], d[17];
void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
    }
    int k;
    cin >> k;
    for (ll i = 0; i < k; i++)
        cin >> c[i] >> d[i];
    int ans = 0;
    for (int i = 0; i < (1 << k); i++) {
        int use[102] = {0};
        for (int j = 0; j < k; j++) {
            if ((1 << j) & i)
                use[c[j]] = 1;
            else
                use[d[j]] = 1;
        }
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            if (use[a[j]] && use[b[j]])
                cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}
int main() {
    ios::sync_with_stdio(false);
    int t;
    t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
#define inf 1e18
#define spc " "
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define mk(arr,n,type)  type *arr=new type[n];
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define repm(i,a,b) for(int i=a ; i<b ; i++)
#define endl "\n"
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
typedef long long ll;
//#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>

template<class T>void _print(T t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}

void cp(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    #endif
}

void solve(){

    int n;
    cin>>n;

    vi nums(n);

    unordered_map<int,int> unmap;

    rep(i,n)cin>>nums[i];

    int ans = 0;

    unmap[nums[0]]++;

    for(int i = 1 ; i<n ; i++){
        ans+=(i - unmap[nums[i]]);
        unmap[nums[i]]++;
    }

    cout<<ans<<endl;
}

int32_t main(){
    cp();
    int t = 1;
    // cin>>t;

    while(t--)
        solve();

        return 0;
}

//ll min_len[1<<8];
//void __(){
//    _(ll,n);
//    _(ll,m);
//    _(vl,a,n);
//    _(vpll,b,m);
//    rep(bm,1<<n){
//        ll w = 0;
//        rep(i,n)
//            if(bm&(1<<i))
//                w += a[i];
//        rep(i,m){
//            if(b[i].Y < w)
//                min_len[bm] = max(min_len[bm],b[i].X);
//        }
//    }
//    rep(i,n)
//        if(min_len[1<<i] != 0){
//            print -1;
//            return;
//        }
//    vi order(n);
//    iota(all(order),0);
//    ll ans = INF;
//    do{
//        vl x(n);
//        rep(i,1,n-1){
//            x[i] = x[i-1];
//            ll bm = 1<<order[i];
//            per(j,i){
//                bm |= 1<<order[j];
//                x[i] = max(x[i],min_len[bm]+x[j]);
//            }
//        }
//        ans = min(ans,x.back());
//    }while(next_permutation(all(order)));
//    print ans;
//}
//
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = (l); i <= (r); ++i)
#define REP_ZERO_INT(i,r) for(int i = 0; i < (r); ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define PER_ZERO_INT(i,r) for(int i = (r)-1; i >= 0; --i)
#define GET_PER_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define per(...) GET_PER_MACRO(__VA_ARGS__,PER_ANY,PER_INT,PER_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define X first
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<int> vi;
const ll INF = ll(2e18) + 666;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
template <typename F, typename S> static
istream& operator>>(istream& stream, pair<F, S>& t){
    return stream >> t.first >> t.second;
}
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }

    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define _IWI(type,name,...) type name(__VA_ARGS__); cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
ll min_len[1<<8];
void __(){
    _(ll,n);
    _(ll,m);
    _(vl,a,n);
    _(vpll,b,m);
    rep(bm,1<<n){
        ll w = 0;
        rep(i,n)
            if(bm&(1<<i))
                w += a[i];
        rep(i,m){
            if(b[i].Y < w)
                min_len[bm] = max(min_len[bm],b[i].X);
        }
    }
    rep(i,n)
        if(min_len[1<<i] != 0){
            print -1;
            return;
        }
    vi order(n);
    iota(all(order),0);
    ll ans = INF;
    do{
        vl x(n);
        rep(i,1,n-1){
            x[i] = x[i-1];
            ll bm = 1<<order[i];
            per(j,i){
                bm |= 1<<order[j];
                x[i] = max(x[i],min_len[bm]+x[j]);
            }
        }
        ans = min(ans,x.back());
    }while(next_permutation(all(order)));
    print ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}


#define _DEBUG
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define prind(argument) cout<<std::fixed<<setprecision(13)<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba(a) emplace_back(a)
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[21];
	scan(N);
	rep(i,N) scan(A[i]);
	ll ans=INFl;
	int bitall=(1<<(N-1));
	rep(bit,bitall){
		ll xo=0;
		int now=A[0];
		rep(i,N-1){
			if(bit&(1<<i)){
				xo^=now;
				now=A[i+1];
			}
			else{
				now|=A[i+1];
			}
		}
		xo^=now;
		chmin(ans,xo);
	}
	prin(ans);
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <set>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
using Interval = pair<ll,ll>;
using Graph = vector<vector<ll> >;
#define fi first
#define se second

struct Edge{
    ll to;
    ll w;
    Edge(ll to, ll w):to(to),w(w){}
};

using wGraph = vector<vector<Edge> >;

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

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

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

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

const ll INF = 1LL << 60;

ll n;
vector<ll> a(25);
vector<vector<ll> > OR(25,vector<ll>(25,0));

int main(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }

    rep(i,n){
        repi(j,i+1,n+1){
            ll tmp = 0;
            repi(k,i,j){
                tmp |= a[k];
            }
            OR[i][j] = tmp;
        }
    }

    ll ans  = INF;

    for (ll bit = 0; bit < 1<<(n-1);bit++){
        vector<ll> interval;
        interval.push_back(0);
        for (ll i = 0; i<n-1; i++){
            if (bit & (1<<i)){
                 interval.push_back(i+1);
            }
        }
        interval.push_back(n);

        ll res = -1;

        rep(i,interval.size()-1){
            ll l = interval[i];
            ll r = interval[i+1];
            if (res == -1){
                res = OR[l][r];
            }
            else{
                res ^= OR[l][r];
            }
        }

        ans = min(ans,res);

    }

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll unsigned long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define ld long double
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define endl "\n"
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll power(ll x, ll y, ll p) {
    ll res = 1;    x = x % p;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y = y>>1;    x = (x*x) % p;
    } return res;
}

inline void solve()
{

    ll n,w;
    cin>>n>>w;
    cout<<n/w;

}
int main()
{
    Imposter

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();

    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
  {
  long long int n,w,x;
  cin>>n>>w;
  x=n/w;
  cout<<x;

  }


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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint fun(int n){
	vector<mint> dp(2), ndp(2);
	dp[0]=1;
	rep(i, n){
		rep(j, 2) ndp[j]=0;
		ndp[0]=dp[0]+dp[1];
		ndp[1]=dp[0];
		swap(dp, ndp);
	}
	return dp[0]+dp[1];
}

mint p2(int n){
	mint c=1;
	rep(i, n) c*=2;
	return c;
}

int main(){
	int n;
	cin>>n;
	vector<char> c(4);
	rep(i, 4) cin>>c[i];

	mint ans=0;
	if(c[1]=='A'){
		if(c[0]=='A') ans=1;
		else{
			if(c[2]=='A') ans=fun(n-3);
			else ans=p2(n-3);
		}
	}
	else{
		if(c[3]=='B') ans=1;
		else{
			if(c[2]=='B') ans=fun(n-3);
			else ans=p2(n-3);
		}
	}

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

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

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
//#define endl '\n'

using ll = long long;
//using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
int go[2][2], n;
int fibo[1005];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

    fibo[0]=fibo[1] = 1;
    f(i,2,1005)fibo[i]=fibo[i-1]+fibo[i-2], fibo[i]%=MOD;
    cin >> n;
    f(i,0,2)
        f(j,0,2){
            char c;
            cin >> c;
            go[i][j] = c-'A';
        }
    if(n<=3) {
        cout << 1 << '\n';
        return 0;
    }
    if(go[0][1] == 0 && go[0][0] == 0) {
        cout << 1 << "\n";
        return 0;
    }
    if(go[0][1] == 1 && go[1][1] == 1) {
        cout << 1 << "\n";
        return 0;
    }
    if(go[0][1] != go[1][0]) {
        int ans = 1;
        f(i,0,n-3)ans += ans, ans %= MOD;
        cout << ans << '\n';
        return 0;
    }
    cout << fibo[n-2] << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> Vll;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int a,b;
  cin >> a >> b;
  cout << 2*a+100-b << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rev(i,n,a) for(ll i=n-1;i>=a;i--)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define secreterror() ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve(){

    ll a,b;
    cin>>a>>b;

    ll ans=2*a + 100;
    cout<<max((ll)0,ans-b)<<endl;

}

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

    //}

}


#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using ll = long long;
using namespace std;

ll modpow(ll a, ll n, ll mod) {
  ll ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }
    a = a * a % mod;
    n >>= 1;
  }
  return ans;
}

int main(int argc, char *argv[]) {
  ll N, P;
  cin >> N >> P;
  ll mod = 1e9 + 7;
  // (P - 1) * (P - 2)^N - 1
  cout << (P - 1) * modpow(P - 2, N - 1, mod) % mod << endl;
}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
#define all(v) v.begin(), v.end()
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, b) for (ll i = a; i < b; ++i)
#define rep_down(i, a, b) for (ll i = a; i > b; --i)

#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second

#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

#define vvvvdo vector<vector<vector<vector<double>>>>
#define vvvdo vector<vector<vector<double>>>
#define vvdo vector<vector<double>>
#define vdo vector<double>

#define maze(S, H, W) vector<vector<char>> S(H, vector<char>(W))

#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
// ll mod = 998244353;
// ll mod = 67280421310721;
// ll mod = 1e18+3;
ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
void pt(T val) {
    cout << val << "\n";
}
template <typename T>
void pt_vll(vector<T> &v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];

        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}
template <typename T>
void pt_vvll(vector<vector<T>> &v) {
    ll vs = v.size();
    rep(i, vs) pt_vll(v[i]);
}

template <typename X, typename Y>
void pt_pair(pair<X, Y> val) {
    cout << val.fi << " " << val.se << "\n";
}

template <typename X, typename Y>
void pt_vpair(vector<pair<X, Y>> &v) {
    rep(i, v.size()) pt_pair(v[i]);
}

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

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll x, ll n) {
    ll ret = 1;
    if (x < 0) return 0ll;
    while (n > 0) {
        if (n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}
ll minv(ll a, ll m) { return modpow(a, m - 2); }

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

    ll N, p;
    cin >> N >> p;
    ll ans = p - 1;

    (ans *= modpow(p - 2, N - 1)) %= mod;
    pt(ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using V2 = vector<vector<int>>;

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

void dfs(Graph &graph, const vector<int> &P, vector<int> &tour, int u)
{
    auto p = P.at(u);
    tour.push_back(u);
    for (int v : graph.at(u)) {
        if (p == v)
            continue;
        dfs(graph, P, tour, v);
    }
    tour.push_back(u);
}

int main()
{
    int N;
    cin >> N;
    vector<int> P(N, -1);
    Graph graph(N);
    for (int i = 1; i < N; ++i) {
        cin >> P.at(i);
        --P.at(i);
        graph.at(i).push_back(P.at(i));
        graph.at(P.at(i)).push_back(i);
    }
    vector<int> tour;
    dfs(graph, P, tour, 0);
    vector<int> in(N, -1), out(N, -1);
    for (int i = 0; i < 2 * N; ++i) {
        auto u = tour.at(i);
        if (in.at(u) == -1)
            in.at(u) = i;
        else
            out.at(u) = i;
    }
    vector<int> cost(N, 2 * N);
    cost.at(0) = 0;
    V2 list(N);
    list.at(0).push_back(0);
    for (auto u : tour) {
        auto p = P.at(u);
        if (p == -1)
            continue;
        auto cost_u = cost.at(p) + 1;
        if (chmin(cost.at(u), cost_u))
            list.at(cost_u).push_back(in.at(u));
    }
    int Q;
    cin >> Q;
    for ( ; Q > 0; --Q) {
        int U, D;
        cin >> U >> D;
        --U;
        auto &list_D = list.at(D);
        auto ite1 = lower_bound(list_D.begin(), list_D.end(), in.at(U));
        auto ite2 = lower_bound(list_D.begin(), list_D.end(), out.at(U));
        cout << ite2 - ite1 << endl;
    }
}


/*  **    ** ******    ****** ****** **     ******    ***
    **    ** **  **    **  ** **  ** **     **  ** *********
    **\../** ******    ****** **  ** ****** **  **    ***
    **    ** ** **     ** **  **  ** **  ** **  **    *****
    **    ** **  ** ** **  ** ****** ****** ******    *****
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define vt vector
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e6;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	for(auto& a:x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	for(auto& a:x)
		read(a);
}
vector<pair<int,int>>adj[N];
int label[N],vis[N];
void dfs(int u,int l){
	label[u]=l;
	vis[u]=1;
	for(auto child:adj[u]){
		int v = child.fr,c = child.sc;
		if(!vis[v]){
			if(label[u]==c){
				if(label[u]==1){
					dfs(v,2);
				}else{
					dfs(v,1);
				}
			}else{
				dfs(v,c);
			}
		}
	}
}
void _run(){
	int n,m;
	read(n,m);
	lp(i,m){
		int x,y,c;
		read(x,y,c);
		adj[x].pb({y,c});
		adj[y].pb({x,c});
	}
	dfs(1,1);
	range(i,1,n){
		cout<<label[i]<<endl;
	}
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
	init();
    int t=1;
    // read(t);
    while(t--)_run();

    return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << b-c << endl;

}


#include <bits/stdc++.h>

using namespace std;

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

#define LOCAL
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

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

#define REP(i, x)	for (int i = 0; i < (int)(x); i++)
#define REPS(i, x)	for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x)	for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(x)		((x).begin(), (x).end())
#define SIZE(x)		((int)(x).size())
#define BITS(x)		(1LL << (x))

constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001LL;
constexpr int MOD = 1000000007;
constexpr double EPS = 1e-10;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx8[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
constexpr int dy8[8] = { 1, 0, -1, 1, -1, 1, 0, -1 };

random_device seed_gen;
mt19937 mrand(seed_gen());
mt19937_64 mrand64(seed_gen());
int rand32(int x) {
	return mrand() % x;
}
ll rand64(long x) {
	return mrand64() % x;
}

template<typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
	out << "(" << a.first << "," << a.second << ")";
	return out;
}
template<typename T, size_t N>
ostream& operator<<(ostream& out, const array<T, N>& a) {
	out << "[";
	bool first = true;
	for (auto& v : a) {
		out << (first ? "" : ",");
		out << v;
		first = 0;
	}
	out << "]";
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
	out << "[";
	bool first = true;
	for (auto& v : a) {
		out << (first ? "" : ",");
		out << v;
		first = 0;
	}
	out << "]";
	return out;
}
template<typename T, class Cmp>
ostream& operator<<(ostream& out, const set<T, Cmp>& a) {
	out << "{";
	bool first = true;
	for (auto& v : a) {
		out << (first ? "" : ",");
		out << v;
		first = 0;
	}
	out << "}";
	return out;
}
template<typename U, typename T, class Cmp>
ostream& operator<<(ostream& out, const map<U, T, Cmp>& a) {
	out << "{";
	bool first = true;
	for (auto& p : a) {
		out << (first ? "" : ",");
		out << p.first << ": " << p.second;
		first = 0;
	}
	out << "}";
	return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}

struct fast_ios {
	static constexpr int IOS_PREC = 20;
	static constexpr bool AUTOFLUSH = false;

	fast_ios() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH) cout << unitbuf;
	}
} fast_ios_;

int main() {
	int n;
	cin >> n;
	cout << n - 1 << endl;
	// if (n < 2) {
	// 	cout << 0 << endl;
	// } else {
	// 	// if (n & 1) {
	// 	// 	cout << 2 * (n - 2 + 1) / 2 << endl;
	// 	// } else {
	// 	// 	cout << n - 2 + 1 << endl;
	// 	// }
	// 	cout << n - 1 << endl;
	// }
	return 0;
}


#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

/*.....................DEFINE FUNCTIONS ......................*/

/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__

	ll N;
	cin>>N;
	ll mx=0;

	for (ll k = 1; k*(k+1) <=2*(N+1); ++k)
	{
		mx=k;
	}

	cout<<N-mx+1<<endl;

		return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<string.h>
#include<time.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cctype>
using namespace std;
#define ll  long long
#define ull unsigned long long
inline int read() {
    char ch = getchar(); int x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}

ll mod=1e9+7;
int main()
{
    ll n;
    cin>>n;
    ll tmp=0;
    ll sum=0;
    for(int i=1;i<=n;++i)
    {
        if(tmp+i<=n+1)
        {
            tmp+=i;
            sum++;
        }
        else
        {
            break;
        }
    }
    cout<<n-sum+1<<endl;

	//system("pause");
	return 0;
}
//max 1 1 2 3
//2n 2n+1 3n 4n


/*        All is Well        */
#include <bits/stdc++.h>
using namespace std;
#define tera_baap_aaya main
#define TEZZ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);//
#define ll long long int
#define PB push_back
const ll C=998244353;
////////////////////
bool checkprime(ll n)
{
    for (int i=2;i*i<=n;i++)
    {
        if (n%i==0)
        {
            return false;
        }
    }
    return true;
}//////////
ll ncr(int n, int r)
{
    if (r>n)
    {
        return 0;
    }
    r=min(r,n-r);
    ll num=1,den=1;
    for (int i=0;i<r;i++)
    {
        num*=n-i;
        den*=i+1;
        ll g=__gcd(num,den);
        num/=g;
        den/=g;
    }
    return num;
}//////////
ll pasc_triangle(int n, int r)
{
    if (r>n)
    {
        return 0;
    }
    r=min(r,n-r);
    if (r==0)
    {
        return 1;
    }
    vector <ll> a;
    a.PB(1);
    for (int i=0;i<n-1;i++)
    {
        vector <ll> b;
        b.PB(1);
        for (int j=1;j<a.size();j++)
        {
            b.PB((a[j]+a[j-1])%C);
        }
        b.PB(1);
        a=b;
    }
    return (a[r]+a[r-1])%C;
}//////////
vector <ll> fact(200000+1);
void factarray()
{
    fact[0]=1%C;
    for (int i=1;i<200000+1;i++)
    {
        fact[i]=(fact[i-1]*i)%C;
    }
}//////////
ll modpower(ll n,ll p)
{
    if (p==0)
    {
        return 1%C;
    }
    ll m=modpower(n,p/2);
    m*=m;
    m%=C;
    if (p%2)
    {
        m*=n%C;
        m%=C;
    }
    return m;
}//////////
ll modinverse(ll n)
{
    return modpower(n, C-2);
}//////////
ll ncrmodc(int n,int r)
{
    if (r>n)
    {
        return 0;
    }
    r=min(r,n-r);
    return ((fact[n]*modinverse(fact[r]))%C*modinverse(fact[n-r]))%C;
}//////////
/******************/
void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-c;
}//////////
////////////////////
int tera_baap_aaya()
{
    TEZZ;
    int t=1;
    //cin>>t;
    //factarray();
    while (t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}
/*..fir milenge chalte chalte*/

#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    flash
    int t = 1;
    //cin>>t;
    while (t--) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<b-c;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cout<<(2*i)%n+1<<' '<<(2*i+1)%n+1<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pl pair<ll, ll>
#define vl vector<ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define N 100005

int main()
{
    fastIO
    string s; cin>>s;
    ll n = s.size();
    string ans;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='.')
        break;
        ans.pb(s[i]);
    }
    cout<<ans<<"\n";

}