#ifdef __LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using PIL = pair<int,ll>;
using PLI = pair<ll,int>;
using PLL = pair<ll,ll>;
using Graph = vector<vector<int>>;
using Cost_Graph = vector<vector<PIL>>;

template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;}
template<class T> void show_vec(T v) {for (int i=0;i<v.size();i++) cout<<v[i]<<endl;}
template<class T> void show_pair(T p) {cout<<p.first<<" "<<p.second<<endl;}
template<class T> bool judge_digit(T bit,T i) {return (((bit&(1LL<<i))!=0)?1:0);}
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ROUNDUP(a,b) ((a+b-1)/b)
#define YESNO(T) cout<<(T?"YES":"NO")<<endl
#define yesno(T) cout<<(T?"yes":"no")<<endl
#define YesNo(T) cout<<(T?"Yes":"No")<<endl

const int INFint = 1 << 29;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007LL;
const double pi = 3.14159265358979;
const vector<int> h_idx4 = {-1, 0,0,1};
const vector<int> w_idx4 = { 0,-1,1,0};
const vector<int> h_idx8 = {-1,-1,-1, 0,0, 1,1,1};
const vector<int> w_idx8 = {-1, 0, 1,-1,1,-1,0,1};

int n;
string s,t;

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

    cin >> n >> s >> t;

    int s0 = 0,s1 = 0,t0 = 0,t1 = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == '0') s0++;
        else s1++;

        if (t[i] == '0') t0++;
        else t1++;
    }

    if (s0 != t0){
        cout << -1 << endl;
        return 0;
    }

    vector<ll> ss,tt;
    for (int i = 0; i < n; i++){
        if (s[i] == '0') ss.push_back(i);
        if (t[i] == '0') tt.push_back(i);
    }

    int m = ss.size();
    int ans = 0;
    for (int i = 0; i < m; i++){
        if (ss[i] != tt[i]) ans++;
    }

    cout << ans << endl;

}

#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;++i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<endl
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1e18+7;
const lint inf=1e9+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  string s;cin>>s;
  string t;cin>>t;
  lint res=0;
  vector<int> a,b;
  a.push_back(-1);
  b.push_back(-1);
  rep(i,n){
    if(s[i]=='1')a.push_back(i);
    if(t[i]=='1')b.push_back(i);
  }
  if(a.size()!=b.size()){
    cout<<-1<<"\n";
    return 0;
  }
  rep1(i,a.size()-1){
    int move=b[i-1]-a[i-1];
    int sub=b[i]-a[i];
    if(move<=0){
      if(b[i]<=a[i-1])res+=a[i]-a[i-1]-1;
      else res+=abs(sub);
    }
    else if(move>0){
      if(b[i-1]>=a[i])res+=b[i]-(b[i-1]+1);
      else res+=abs(sub);
    }
  }
  cout<<res<<"\n";
  return 0;
}


#include <iostream>
#include <map>
#include <tuple>
#include <algorithm>
#include <iomanip>
#include <array>

int main()
{
  int A, B, C;
  std::cin >> A >> B >> C;

  std::array<int, 3> init_status = {A,B,C};
  std::sort(init_status.begin(), init_status.end());

  std::map<std::array<int,3>, double> status;
  status.emplace(init_status, 1);

  double coinsExpected = 0.0;

  while( !status.empty() )
  {
    std::map<std::array<int, 3>, double> statusNext;

    for (const auto& e : status)
    {
      const auto& state = e.first;
      double coins = state[0] + state[1] + state[2];
      double pA = e.second * state[0] / coins;
      double pB = e.second * state[1] / coins;
      double pC = e.second * state[2] / coins;

      if (pA != 0)
      {
        if (state[0] == 99)
        {
          coinsExpected += pA * (coins + 1);
        }
        else
        {
          auto next = state;
          next[0] += 1;
          std::sort(next.begin(), next.end());
          statusNext[next] = (statusNext.count(next) ? statusNext[next] : 0.0) + pA;
        }
      }

      if (pB != 0)
      {
        if (state[1] == 99)
        {
          coinsExpected += pB * (coins + 1);
        }
        else
        {
          auto next = state;
          next[1] += 1;
          std::sort(next.begin(), next.end());
          statusNext[next] = (statusNext.count(next) ? statusNext[next] : 0.0) + pB;
        }
      }

      if (pC != 0)
      {
        if (state[2] == 99)
        {
          coinsExpected += pC * (coins + 1);
        }
        else
        {
          auto next = state;
          next[2] += 1;
          std::sort(next.begin(), next.end());
          statusNext[next] = (statusNext.count(next) ? statusNext[next] : 0.0) + pC;
        }
      }
    }
    status = statusNext;
  }
  std::cout <<
    std::setprecision(14) <<
    coinsExpected-A-B-C << std::endl;
  return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long tnum;

#define loop(i, num) for(int i = 0; i < num; i++)

tnum* tnumAlloc(int num);
tnum getNumStdin();
tnum* getNumsStdin(int);
char* getCharsStdin(int maxlength);
string getStringStdin();
void printlnNums(int count, tnum* nums);
void printlnNum(tnum num);
void printString(string str);

#define min(a,b) (a <= b ? a : b)
#define max(a,b) (a >= n ? a : b)

/*void sort(T* start, T* end) (in <algorithm>)
example:
	int a[5] = {2, 1, 3, 5, 4};
	sort(a, a + 5);
	-> a: {1, 2, 3, 4, 5}
*/

int main() {
	tnum m = getNumStdin();
	tnum h = getNumStdin();

	if (h % m == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

//have to be free()
tnum* tnumAlloc(int num) {
	return (tnum*)calloc(num,sizeof(tnum));
}

tnum getNumStdin() {
	tnum ret;
	cin >> ret;

	return ret;
}

//have to be free()
tnum* getNumsStdin(int num) {
	tnum* buf;
	tnum* tmp;
	buf = tnumAlloc(num);
	for (int i = 0; i < num; i++) {
		cin >> buf[i];
	}

	return buf;
}

//have to be free()
char* getCharsStdin(int maxlength) {
	char* ret = (char*)malloc(maxlength+1);
	scanf("%s", ret);

	return ret;
}

//have to be free()
string getStringStdin() {
	string ret;
	cin >> ret;
	return ret;
}

void printlnNum(tnum num) {
	cout << num << endl;
}

// can be used for debugging
void printlnNums(int count, tnum *nums) {
	loop(i, count) {
		cout << nums[i];
		if (i != count - 1) printf(" ");
	}
	printf("\n");
}

void printString(string str) {
	cout << str;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(2 * N);
	REP(i, 2 * N) scanf("%d", &A[i]);

	ll ans = accumulate(ALL(A), 0ll);
	priority_queue<int, vector<int>, greater<int> > pq;
	REP(i, N) {
		pq.emplace(A[N - i - 1]);
		pq.emplace(A[N + i]);
		ans -= pq.top();
		pq.pop();
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int mul (int a, int b) { return 1ll * a * b % MOD; }
int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	a.push_back(0);
	sort(a.begin(), a.end());
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = mul(ans, a[i] - a[i - 1] + 1);
	}
	printf("%d\n", ans);
	return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)

const ll MOD = 1000000007;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 1;
  rep(i, n){
    if (i == 0)
      ans *= (a[i] + 1);
    else{
      ll diff = a[i] - a[i-1];
      if (diff == 0) continue;
      ans *= (diff + 1);
    }
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


#include<iostream>
using namespace std;
int main(){
int N;
cin>>N;
if(N%2==0)
    cout<<"White";
else
    cout<<"Black";
return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

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

    int N,i=1,save=0;

    cin>>N;
    while(save<N)
    {
        save=save+i;
        i++;
    }
    cout<<i-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll mod=998244353;
ll N,K;
ll power[301];
ll modpow(ll a,ll n){
ll res=1;
  while(0<n){
  if(n%2==1)res=(res*a)%mod;
    a=(a*a)%mod;
    n>>=1;
  }return res;
}
ll fac[301];
ll rev[301];
ll comb(ll n,ll k){
if(n<k)return 0;
  ll x=(fac[n]*rev[k])%mod;
  x=(x*rev[n-k])%mod;return x;
}
int main(){
  cin>>N>>K;ll rev2=modpow(2,mod-2);
  fac[0]=1;rev[0]=1;
  for(ll i=1;i<=300;i++){
  fac[i]=(i*fac[i-1])%mod;
    rev[i]=modpow(fac[i],mod-2);
  }
  vector<ll>A(N);
  for(ll i=0;i<N;i++)
    cin>>A[i];power[0]=N;
  for(ll i=0;i<N;i++){
  ll a=A[i];
    for(ll j=1;j<=300;j++){
    power[j]=(power[j]+a)%mod;
      a=(a*A[i])%mod;
      }
  }for(ll k=1;k<=K;k++){
    ll ans=0;
  for(ll i=1;i<=k/2;i++){
    ll x=(comb(k,i)*(mod-power[k]+(power[i]*power[k-i])%mod))%mod;
     ans=(ans+x)%mod;
  }
   ans=(ans+(N-1)*power[k])%mod;
 if(k%2==0){ ll x=(comb(k,k/2)*(mod-power[k]+(power[k/2]*power[k/2])%mod))%mod;
            x=(x*rev2)%mod;
     ans=(mod+ans-x)%mod;}
    cout<<ans<<endl;
  }
  return 0;
}


#include "bits/stdc++.h"
#include <chrono>
#include <random>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000
#define common cout << "Case #" << w+1 << ": "
#define maxn 2000010

void setIO(string name) {
	ios_base::sync_with_stdio(0); cin.tie(0);
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

template< typename T>
void PVecPrint(vector<T>&v)
{
    for(int i=0;i<(int)v.size();i++)
        cout << v[i].first << "," << v[i].second << ' ';
    cout << '\n';
}
template<class T>
void VecPrint(vector<T>&v)
{
    for(int i=0;i<v.size();i++)
        cout << v[i] << ' ';
    cout << '\n';
}
/*-------------------------------------------------------------------Code-----------------------------------------------------------------*/

typedef complex<double> point;
#define x real()
#define y imag()

double piv= (double)3.141592653589793/(double)180;

point func(point X,int val)
{
    double theta = piv*val;
    point Xnew=(X * polar(1.0, theta));
    return Xnew;
}

bool iseq(point p1,point p2)
{
    if(abs(p1.x-p2.x)<=0.1 and abs(p1.y-p2.y)<=0.1)
        return true;
    return false;
}

bool found(point p,vector<point>&v)
{
    for(int i=0;i<v.size();i++)
    {
        if(iseq(p,v[i]))
            return true;
    }
    return false;
}

bool func(vector<point>&v1,vector<point>&v2)
{
    for(int i=0;i<v1.size();i++)
    {
        if(!found(v1[i],v2))
            return false;
    }
    return true;
}

int main()
{
    fastio;
    int n;
    cin >> n;
    vector<point>v1(n),v2(n);
    for(int i=0;i<n;i++)
    {
        int x1,y1;
        cin >> x1 >> y1;
        point t(x1,y1);
        v1[i]=t;
    }
    for(int i=0;i<n;i++)
    {
        int x1,y1;
        cin >> x1 >> y1;
        point t(x1,y1);
        v2[i]=t;
    }
    int f=0;
    for(int i=0;i<360 and f==0;i++)
    {
        vector<point>v3(n);
        for(int j=0;j<n;j++)
            v3[j]=func(v1[j],i);
        for(int k=0;k<n;k++)
        {
            // cout << i << ' ' << k << '\n';
            double dx = v2[k].x-v3[0].x,dy=v2[k].y-v3[0].y;
            for(int j=0;j<n;j++)
                v3[j]=point(v3[j].x+dx,v3[j].y+dy);
            if(func(v3,v2))
                f=1;
        }
    }
    if(f==1)
        cout << "Yes\n";
    else
        cout << "No\n";
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

ll pow(P p1, P p2) {
    ll x0 = p1.first; ll y0 = p1.second;
    ll x1 = p2.first; ll y1 = p2.second;
    return (x0-x1)*(x0-x1)+(y0-y1)*(y0-y1);
}
int main(){
    ll n; cin >> n;
    vector<P> s(n);
    vector<P> t(n);
    REP(i,n) cin >> s[i].first >> s[i].second;
    REP(i,n) cin >> t[i].first >> t[i].second;
    if (n==1) {
        cout << "Yes" << endl;
        return 0;
    }
    if (n==2) {
        if (pow(s[0],s[1])==pow(t[0],t[1])) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    ll xt = t[0].first; ll yt = t[0].second;
    REP(i,n) t[i].first-=xt, t[i].second-=yt;
    // REP(i,n) cout << s[i].first << " " << s[i].second << " " << t[i].first << " " << t[i].second << endl;
    REP(i,n) REP(j,n){
        if (i==j) continue;
        ll d0 = pow(s[i],s[j]); ll d1 = pow(t[0],t[1]);
        if (d0!=d1) continue;
        vector<P> u(n);
        ll x = s[i].first; ll y = s[i].second;
        REP(k,n) u[k].first = s[k].first-x, u[k].second = s[k].second-y;
        // cout << "test2 " << i << " " << j << endl; cout << x <<  " " << y << endl;
        // cout << "u" << endl;
        // REP(k,n) cout << u[k].first << " " << u[k].second << endl;
        ll a, b, c;
        x = u[j].first; y = u[j].second;
        ll z = t[1].first; ll w = t[1].second;
        b = y*z-x*w; a = z*x+w*y; c = x*x+y*y;
        // cout << a << " " << b << " " << c << endl;
        vector<P> uu(n);
        REP(k,n) {
            uu[k].first = a*u[k].first+b*u[k].second;
            uu[k].second = a*u[k].second-b*u[k].first;
        }
        swap(u,uu);
        vector<P> v(n);
        REP(k,n) v[k].first = t[k].first*c, v[k].second = t[k].second*c;
        sort(u.begin(),u.end());
        sort(v.begin(),v.end());
        // cout << "test1 " << i << " " << j << endl;
        // cout << "u" << endl;
        // REP(k,n) cout << u[k].first << " " << u[k].second << endl;
        // cout << "v" << endl;
        // REP(k,n) cout << v[k].first << " " << v[k].second << endl;
        bool judtmp = true;
        REP(k,n) if (v[k]!=u[k]) judtmp = false;
        if (judtmp) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
//#include <set>
using namespace std;
typedef long long LONG;

LONG gcd(LONG x, LONG y) {
    if(x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
        //x%y==0でないときはユーグリットの互除法を使って再帰的に関数を呼び出す。
    }
}
void print(vector<int>A){
    for(size_t i=0;i<A.size();i++){
        if(A[i]==1){
            cout<<'(';
        }else{
            cout<<')';
        }
    }
}

bool comp1(pair<int,int> lhs, pair<int,int>rhs) {
    return lhs.first<rhs.first;
}

bool comp2(pair<string,int> lhs, pair<string,int>rhs) {
    return lhs.second<rhs.second;
}
void solve(int min,int max,vector<int>&A,int B){
    if(min+1==max){
        cout<<std::min(A[max]-B,B-A[min])<<endl;
        return;
    }
    int a=(min+max)/2;
    if(A[a]<B){
        solve(a,max,A,B);
    }else{
        solve(min,a,A,B);
    }

}
LONG pow2(LONG a,LONG b){
    LONG res=1;
    for(int i=0;i<b;i++){
        res=res*a;
    }
    return a;
}

void solve1(vector<bool>&A,vector<LONG>&C,int pos,vector<vector<pair<int,LONG>>>&path){
    for(int i=0;i<path[pos].size();i++){
        if(!A[path[pos][i].first]){
            A[path[pos][i].first]=true;
            C[path[pos][i].first]=C[pos]^path[pos][i].second;
            solve1(A,C,path[pos][i].first,path);
        }
    }
}

const LONG mod=1000000007;
int main() {
    int N;
    cin>>N;
    vector<LONG>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    vector<LONG>B(N);
    B[0]=A[0];
    map<LONG,LONG>C;
    map<LONG,LONG>D;
    C[A[0]]=1;
    for(int i=1;i<N;i++){
        B[i]=A[i]-B[i-1];
        if(i%2==0){
            if(C.count(B[i])==0){
                C[B[i]]=1;
            }else{
                C[B[i]]++;
            }
        }else{
            if(D.count(B[i])==0){
                D[B[i]]=1;
            }else{
                D[B[i]]++;
            }

        }

    }
    LONG result=0;
    for(int i=1;i<N+1;i++){
        if(i%2==0){
            result+=C[-B[i-1]];
            result+=D[B[i-1]]-1;

        }else{
            result+=C[B[i-1]]-1;
            result+=D[-B[i-1]];

        }
    }
    result=result/2;

    result+=C[0]+D[0];
    cout<<result<<endl;

    return 0;

}

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

#define int long long
const int N = 3e5 + 5;

int n;
int a[N];
map<int , int> mp;

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

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

    int cur = 0 , ans = 0;
    mp[0] = 1;
    for (int i = 1 ; i <= n ; ++i)
    {
        if (i & 1) cur += a[i];
        else cur -= a[i];

        ans += mp[cur];
        mp[cur]++;
    }
    cout << ans;
}


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

int main()
{
    int N,M;
    string a;
    int x,y;
    char dna[20][20];

    cin >> N >> M;

    x=y=0;

    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++){
            dna[i][j]='.';
        }
    }

    for(int i=0; i<M; i++) {
        cin >> a;
        if(a.size()>5) {
            for(int i=0; i<a.size(); i++){
                dna[y][x]=a[i];
                x++;
                if(x>=N){y++;x=0;}
                if(y>=N){y=0;x=0;}
            }
        }
    }

    for(int y=0; y<N; y++) {
        for(int x=0; x<N; x++){
            cout << dna[y][x];
        }

        cout << endl;
    }
};

#include <bits/stdc++.h>

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

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

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

ll n, m;

void visualizer(vector<vector<char>> gene)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << gene[i][j];
        }

        cout << endl;
    }
}

vector<vector<char>> make_initial_solution(priority_queue<pair<int, string>> q)
{
    vector<vector<char>> gene(n, vector<char>(n, '.'));

    while (q.size())
    {
        auto p = q.top();
        q.pop();

        bool tate, yoko, best_flag = false; // trueが横,falseが縦
        int x, y;
        ll best_score = INF;

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                ll score = 0;
                bool flag = true;

                for (int k = 0; k < p.first; k++)
                {
                    if (gene[i][(j + k) % n] != p.second[k] && gene[i][(j + k) % n] != '.')
                    {
                        flag = false;
                        break;
                    }

                    if (gene[i][(j + k) % n] != p.second[k])
                    {
                        score++;
                    }
                }

                if (flag)
                {
                    if (chmin(best_score, score))
                    {
                        yoko = true;
                        tate = false;
                        best_flag = true;
                        x = i, y = j;
                    }
                }

                flag = true;
                score = 0;

                for (int k = 0; k < p.first; k++)
                {
                    if (gene[(i + k) % n][j] != p.second[k] && gene[(i + k) % n][j] != '.')
                    {
                        flag = false;
                        break;
                    }

                    if (gene[(i + k) % n][j] != p.second[k])
                    {
                        score++;
                    }
                }

                if (flag)
                {
                    if (chmin(best_score, score))
                    {
                        yoko = false;
                        tate = true;
                        best_flag = true;
                        x = i, y = j;
                    }
                }
            }
        }

        if (!best_flag)
        {
            continue;
        }

        for (int i = 0; i < p.first; i++)
        {
            gene[(x + (i * tate)) % n][(y + (i * yoko)) % n] = p.second[i];
        }
    }

    return gene;
}

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

    priority_queue<pair<int, string>> q;

    for (int i = 0; i < m; i++)
    {
        string s;
        cin >> s;

        q.push({s.size(), s});
    }

    auto initial_gene = make_initial_solution(q);

    visualizer(initial_gene);
}


#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) 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();
using namespace std;
int ans;
int n,k;
pii a[105],b[105];
map<int,bool>flag;
int z;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	cin>>z>>n;
	REP(i,0,n)cin>>a[i].first>>a[i].second;
	cin>>k;
	REP(i,0,k)cin>>b[i].first>>b[i].second;
	REP(i,0,1<<k){
		int x=i;
		REP(j,0,k){
			if(x%2==0)flag[b[j].first]=1;
			else flag[b[j].second]=1;
			x/=2;
		}
		int cnt=0;
		REP(j,0,n)
		if(flag[a[j].first]&&flag[a[j].second])cnt++;
		ans=max(ans,cnt);
		map<int,bool>::IT it;
		for(it=flag.begin();it!=flag.end();it++)it->second=0;
	}
	cout<<ans;
    return 0;
}

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

#define ll long long
#define vll vector<long long>
#define f first
#define s second
#define pb push_back
#define printoneline(arr) for(long long i=0;i<arr.size();i++){cout<<arr[i]<<" ";} cout<<"\n";
#define sort(a) sort(a.begin(),a.end());
#define rsort(a) sort(a.rbegin(),a.rend());
#define reverse(a) reverse(a.begin(),a.end());
#define input(arr) for(long long i=0;i<arr.size();i++){cin>>arr[i];}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,W;
    cin>>N>>W;
    cout<<(N/W)<<"\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
//const lint MOD=998244353;
const lint MAX = 4000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#pragma GCC optimize("Ofast")
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

lint fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }

    int main(){
        string s;
        cin>>s;
        bool isrev=false;
        deque<char> que;
        rep(i,s.size()){
            if(s[i]=='R'){
                if(isrev)isrev=false;
                else isrev=true;
            }else{
                if(que.empty())que.push_front(s[i]);
                else if(isrev){
                    char t=que.front();
                    if(t==s[i])que.pop_front();
                    else que.push_front(s[i]);
                }else{
                    char t=que.back();
                    if(t==s[i])que.pop_back();
                    else que.push_back(s[i]);
                }
            }
        }
        lint g=que.size();
        if(isrev){
            rep(i,g){
                cout<<que.back();
                que.pop_back();
            }
        }else{
            rep(i,g){
                cout<<que.front();
                que.pop_front();
            }
        }
        cout<<endl;

        }

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

int main(void)
{
      vector<int> vDice(3);
      for (int i = 0; i < 3; i++)
      {
          cin >> vDice.at(i);
      }
      vector<int> vFind(6);
      for (int i = 0; i < 6; i++)
      {
          std::vector<int>::iterator itr;
          size_t n_count = std::count(vDice.begin(), vDice.end(), i+1);
          vFind.at(i) = n_count;
      }

      size_t count = std::count(vFind.begin(), vFind.end(), 1);

      if (count == 3)
      {
          cout << 0 << endl;
      }
      else
      {
          for (int i = 0; i < 6; i++)
          {
              if (vFind.at(i) != 0 && vFind.at(i) != 2)
              {
                  cout << i + 1 << endl;
                  break;
              }
          }
      }
}


/*
 * @Author: tusikalanse
 * @Date: 2021-06-12 20:33:13
 * @LastEditTime: 2021-06-12 20:37:22
 * @LastEditors: tusikalanse
 * @Description:
 * @FilePath: /undefined/mnt/e/algo/atcoder/arc/122/b.cpp
 */
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}

const int N = 1e5 + 10;

int n, a[N];

double check(double x) {
    double ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += x + a[i] - min(0.0 + a[i], 2 * x);
    return ans / n;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    double l = 0, r = 1e9;
    while (r - l > 1e-6) {
        double ll = l + (r - l) / 3;
        double rr = r - (r - l) / 3;
        if (check(ll) > check(rr))
            l = ll;
        else
            r = rr;
    }
    printf("%.15f\n", check(l));
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second

const long double PI = acos(-1);

ll n, V[100005], SP[100005];

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

   cin >> n;
   for (int i=1; i<=n; i++)
   {
      cin >> V[i];
   }
   sort(V+1, V+n+1);
   for (int i=1; i<=n; i++)
   {
      SP[i] = SP[i-1] + V[i];
   }
   ld ans = 1e18;
   for (int i=1; i<=n; i++)
   {
      ll loc = (2 * i - n);
      ld x;
      if (loc < 0)
         x = 1.0 * V[i+1] / 2;
      else
         x = 1.0 * V[i] / 2;
      ans = min(ans, x * loc - SP[i]);
   }

   cout << setprecision(8) << fixed << (ans + SP[n]) / n;
   return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
//#include <atcoder/convolution>
//#include <atcoder/modint>

#define bug(x) cout << "zdongdebug1: " << x << endl;
#define bug2(x, y) cout << "zdongdebug2: " << x << " " << y << endl;
#define bug3(x, y, z) \
  cout << "zdongdebug3: " << x << " " << y << " " << z << endl;
#define bug4(x, y, z, w) \
  cout << "zdongdebug4: " << x << " " << y << " " << z << " " << w << endl;
using namespace std;
// using Modint = atcoder::modint998244353;
typedef long long ll;
void ex_gcd(ll a, ll b, ll &d, ll &x, ll &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    ex_gcd(b, a % b, d, y, x);
    y -= a / b * x;
  }
}
ll inv(ll a, ll n) {
  ll d, x, y;
  ex_gcd(a, n, d, x, y);
  return d == 1 ? (x % n + n) % (n / d) : -1;
}
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

const int maxn = 1000005;
const int mod = 998244353;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  // freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int x,y,z;
  cin>>x>>y>>z;
  cout<<21-x-y-z<<endl;
  return 0;
}

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

int a,b,c;

int main(void){
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",7-a+7-b+7-c);

    return 0;
}


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

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

    vector<vector<int>> pos(n);

    rep(i,n){
        int a;
        cin >> a;
        pos[a].push_back(i);
    }

    rep(i,n){
        int pre = -1;
        pos[i].push_back(n);
        for(int j:pos[i]){
            if(j-pre > m){
                cout << i << endl;
                return 0;
            }
            pre = j;
        }
    }

    cout << n << endl;

    return 0;
}

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

#define ll long long
#define ull unsigned ll
#define pi pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vs vector<string>
#define vvi vector<vi>
#define ff first
#define ss second
#define pb push_back
#define vpi vector<pi>
#define vpll vector<pll>
#define umap unordered_map
#define uset unordered_set
#define all(x) x.begin(),x.end()
#define fr(i,j,n) for(int i=j;i<n;++i)
#define rfr(i,j,n) for(int i=j; i>=n;--i)
#define MOD 1000000007
#define INF INT_MAX
#define LINF LONG_LONG_MAX
#define mp make_pair
#define endl "\n"
#define sz  size()
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void solve(){
    int n,m;
    cin>>n>>m;
    vi arr(n);
    vvi pos(n+1);
    fr(i,0,n+1){
        // cin>>arr[i-1];
        pos[i].pb(-1);
    }
    fr(i,0,n){
        cin>>arr[i];
        pos[arr[i]].pb(i);
    }
    fr(i,0,n+1){
        // cin>>arr[i-1];
        pos[i].pb(n);
    }
    fr(i,0,n+1){
        fr(j,1,pos[i].sz){
            if(pos[i][j]-pos[i][j-1]>m){
                cout<<i<<endl;
                return;
            }
        }
    }

}

void pre() {
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
        // cout<<solve()<<endl;
    }
}

int main() {
	fastIO;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	pre();
	return 0;

}


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

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1000005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll  b) {
	return (a + b - 1) / b;
}
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

bool check(ll n)
{
	ll m = n;
	while (n > 0) {
		if (n % 8 == 7) {
			return false;
		} else {
			n /= 8;
		}
	}
	while (m > 0) {
		if (m % 10 == 7) {
			return false;
		} else {
			m /= 10;
		}
	}
	return true;
}

signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	ll n;
	cin >> n;
	ll cnt = 0;
	FOR(i, 1, n) {
		if (check(i)) {
			++cnt;
		}
	}
	cout << cnt << END;

#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code

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

    priority_queue<ll, vector<ll>, greater<ll>> pq;

    ll r = 0;
    rep(i, N) {
        pq.push(A[N - 1 - i]);
        pq.push(A[N + i]);
        r += pq.top();
        pq.pop();
    }

    output(sum - r);

    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define mmod 998244353
#define inf 1000000000000000000
#define PI 3.141592653589793238
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,n) x.clear();x.resize(n,0)
#define precise(x) fixed<<setprecision(x)
#define popcount(x) __builtin_popcountll(x)
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update> ordered_multiset;

/**
 *  author: nayakashutosh9
 *	created: [2021-04-18 17:27]
 *	"Compete against yourself"
**/

const int N = 3e5 + 5;

void solve() {
	int a, b; cin >> a >> b;
	vi pos, neg;
	int n = max(a, b);
	for (int i = 1; i <= n; i++) pos.pb(i);
	for (int i = 1; i <= n; i++) neg.pb(-i);
	if (a >= b) {
		int dif = a - b;
		while (dif > 0) {
			neg[sz(neg) - 2] += neg[sz(neg) - 1];
			neg.pop_back();
			dif--;
		}
	}
	else {
		int dif = b - a;
		while (dif > 0) {
			pos[sz(pos) - 2] += pos[sz(pos) - 1];
			pos.pop_back();
			dif--;
		}
	}
	for (int i : pos) cout << i << " ";
	for (int i : neg) cout << i << " ";
	cout << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	//cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		//cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int read()
{
    int num=0;bool flag=1;
    char c=getchar();
    for(;c<'0'||c>'9';c=getchar())
      if(c=='-')flag=0;
    for(;c>='0'&&c<='9';c=getchar())
      num=(num<<1)+(num<<3)+c-'0';
    return flag?num:-num;
}
int n,m;
int jo[5];
char c[30];
long long ans;
int main(){
	n=read();
	m=read();
	int cnt=0;
	for(int i=1;i<=n;i++){
		scanf("%s",c+1);
		cnt=0;
		for(int j=1;j<=m;j++) if(c[j]=='1') cnt++;
		if(cnt%2==1){
			ans+=jo[2];
			jo[1]++;
		}
		else {
			ans+=jo[1];
			jo[2]++;
		}
	}
	cout<<ans;
	return 0;
}


# include <stdio.h>
# define max(a, b) (a>b?a:b)

using namespace std;

int n, x;
char s[200200];

int main() {
  scanf("%d%d%s", &n, &x, s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x') {
      x = max(0, x - 1);
    } else {
      x++;
    }
  }
  printf("%d", x);
}

#include<bits/stdc++.h>
// #include<iomanip>
// #pragma GCC optimize("Ofast")
#define eb  emplace_back
#define pb  push_back
#define top 200007
#define min(a,b) (a<b) ? a:b
#define max(a,b) (a>b) ? a:b;
#define F first
#define S second
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  cout.tie(0);
    int n, k;
    cin>>n>>k;
    int sum =0;
    for(int i=1;i<=n; ++i)
        for(int j=1; j<=k; ++j)
        {
            sum +=(i*100+j);
        }

    cout<<sum<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int BASE = 1e9 + 7;

int n;
char aa, ab, ba, bb;
int solve() {
    if (n <= 3) return 1;
    if (ab == 'A') {
        if (aa == 'A') return 1;
        if (ba == 'A') {
            // number of strings of length n-3 so that no two bs can be adjacent
            // A....AB (.... can have any chars)
            int lastA = 1, lastB = 0;
            for (int i = 1; i <= n-3; ++i) {
                int newLastA = (lastA + lastB) % BASE;
                int newLastB = lastA;
                lastA = newLastA;
                lastB = newLastB;
            }
            return (lastA + lastB) % BASE;
        } else {
            // number of strings of length n-3
            // A....AB (.... can have any chars)
            int x = 1;
            for (int i = 1; i <= n-3; ++i) x = (x << 1) % BASE;
            return x;
        }
    } else {
        if (bb == 'B') return 1;
        if (ba == 'B') {
            // number of strings of length n-3 so that no two as can be adjacent
            // AB....B (.... can have any chars)
            int lastA = 0, lastB = 1;
            for (int i = 1; i <= n-3; ++i) {
                int newLastA = lastB;
                int newLastB = (lastA + lastB) % BASE;
                lastA = newLastA;
                lastB = newLastB;
            }
            return (lastA + lastB) % BASE;
        } else {
            // number of strings of length n-3
            // AB....B (.... can have any chars)
            int x = 1;
            for (int i = 1; i <= n-3; ++i) x = (x << 1) % BASE;
            return x;
        }
    }
}

int main() {
    cin >> n >> aa >> ab >> ba >> bb;
    cout << solve() << endl;
    return 0;
}


#include <bits/stdc++.h>

template <class T>
inline void read(T &x) {
	static char ch;
	static bool opt;
	while (!isdigit(ch = getchar()) && ch != '-');
	x = (opt = ch == '-') ? 0 : ch - '0';
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0';
	if (opt)
		x = ~x + 1;
}

template <class T>
inline void putint(T x) {
	static char buf[45], *tail = buf;
	if (!x)
		putchar('0');
	else {
		if (x < 0)
			putchar('-'), x = ~x + 1;
		for (; x; x /= 10) *++tail = x % 10 + '0';
		for (; tail != buf; --tail) putchar(*tail);
	}
}

template <class T>
inline bool tense(T &x, const T &y) {
	return y < x ? x = y, true : false;
}

template <class T>
inline bool relax(T &x, const T &y) {
	return x < y ? x = y, true : false;
}

template <class T>
inline T getAbs(const T &x) {
	return x < 0 ? -x : x;
}

typedef long long s64;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
#define mp(x, y) std::make_pair(x, y)

const int MaxN = 3e6 + 5;

int n, a[MaxN];
s64 s[MaxN];

s64 ans;
std::map<s64, int> cnt;

int main() {
#ifdef orzczk
	freopen("a.in", "r", stdin);
#endif

	read(n), cnt[s[0] = 0] = 1;
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
		s[i] = s[i - 1] + (i & 1 ? -1 : 1) * a[i];

		ans += cnt[s[i]]++;
	}

	std::cout << ans << '\n';

	return 0;
}

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

#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define _ << ' ' <<

#define INF (ll)1e18
#define mod 998244353
#define maxn 100010

ll i, i1, j, k, k1, t, n, m, res, flag[10], a[maxn], b[maxn];
ll m1, m2, l[maxn], r[maxn], bsl, bsm, bsu;

bool solve(ll bsm, ll fll) {
    ll i, sl, sr, k;
    sl = 0; sr = 0;
    for (i = 1; i <= n; i++) {
        l[i] = max((ll)0, (a[i] * m2 - bsm + m1 - 1) / m1);
        r[i] = min(m2, (a[i] * m2 + bsm) / m1);
        sl += l[i]; sr += r[i];
    }

    if (fll == 1) {
        k = m2;
        for (i = 1; i <= n; i++) {
            sl -= l[i]; sr -= r[i];
            b[i] = max(l[i], k - sr);
            b[i] = min(b[i], r[i]);
            k -= b[i];
        }
    }

    /* cout << "bsm = " << bsm << nl;
    for (i = 1; i <= n; i++) {
        cout << i _ l[i] _ r[i] << nl;
    } */

    for (i = 1; i <= n; i++) {
        if (l[i] > r[i]) return false;
    }

    if (m2 >= sl && m2 <= sr) return true;
    else return false;
}

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

    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif

    cin >> n >> m1 >> m2;
    for (i = 1; i <= n; i++) {
        cin >> a[i];
    }

    bsl = 0; bsu = 3 * INF;
    while (bsl != bsu) {
        bsm = (bsl + bsu) / 2;
        if (solve(bsm, 0)) bsu = bsm;
        else bsl = bsm + 1;
    }

    solve(bsl, 1);
    for (i = 1; i <= n; i++) cout << b[i] << ' ';
    cout << nl;

    return 0;
}


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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (ll)(n); i++)
#define BIT(bit, n) for (int bit = 0; bit < (1 << (n)); ++bit)
#define INF 1000000000
//配列 vector<型> 配列名(要素数, 初期値);
//二次元配列 vector<vector<型>> 配列名(要素数縦,vector<int>(要素数横, 初期値))
//配列のサイズ(二次元縦) 配列名.size(), 二次元横 配列名[0].size()
// 1秒間のforループは10^8くらい
//小数点桁数 cout << fixed << setprecision(20) <<
// bit全探索 条件判定 if(bit & (1 << n))

int main() {
  int round;
  REP(k, 1000) {
    int Si, Sj, Ti, Tj;
    cin >> Si >> Sj >> Ti >> Tj;

    if (Si > Ti) {
      REP(i, Si - Ti) cout << "U";
    } else {
      REP(i, Ti - Si) cout << "D";
    }

    if (Sj > Tj) {
      REP(i, Sj - Tj) cout << "L";
    } else {
      REP(i, Tj - Sj) cout << "R";
    }
    cout << endl;
    cin >> round;
  }
}

//Soham
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define soham1192k ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
#define debug(x) cerr<<#x<<" ";_print(x);cerr<<'\n';
#else
#define debug(x)
#endif
const int mod=1000000007;
const double pi = 3.14159265358979323846;
const int mxN=2e5+2;
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
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 << "]";}
//*********************************************************************************************************************************************************************************************************
int p[200005];
int sz[200005];
int get(int x){
    if(p[x]==x) return x;
    return p[x]=get(p[x]);
}
void union_sets(int a, int b) {
    a = get(a);
    b = get(b);
    if (a != b) {
        if (sz[a]<sz[b])
            swap(a, b);
        p[b]=a;
        sz[a]+=sz[b];
    }
}
void solve(){
    int n;cin>>n;
    vector<int>a(n);
    for(int&x:a) cin>>x;
    for(int i=1;i<=n;i++){
        p[a[i-1]]=a[i-1];
        sz[a[i-1]]+=1;
    }
    int cnt=0;
    int i=0,j=n-1;
    for(i=0,j=n-1;i<j;i++,j--){
        int x=get(a[i]);
        int y=get(a[j]);
        if(x==y) ;
        else{
            cnt++;
            union_sets(a[i],a[j]);
        }
    }
    cout<<cnt<<'\n';
}
int32_t main(){
    soham1192k;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);
#endif
    int T=1;
    // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


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

#define INF 1e9
#define LLINF 1e18
#define PI 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;

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

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

ll lcm(ll x,ll y){
    return ll(x / gcd(x, y)) * y;
}

int main() {
    ll n, ans = 1;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        ans = lcm(ans, i);
    }
    cout << ans + 1 << endl;
}

#include <iostream>
using namespace std;
using ll = long long int;

int main(){
    ll n;
    cin >> n;
    ll ac = 0;
    ll wa = n+1;
    while(wa-ac > 1){
        ll mid = (ac+wa)/2;
        if(mid <= (2LL*(n+1))/(mid+1)) ac = mid;
        else wa = mid;
    }
    cout << n+1-ac << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y)
{
    if (y==0)
        return 1;
    else if (y%2==0)
        return power(x,y/2)*power(x,y/2);
    else
        return x*power(x,y/2)*power(x,y/2);
}
ll hcf(ll a,ll b)
{
    if(b==0)
        return a;
    return hcf(b,a%b);
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll a,b;
       cin>>a>>b;
       cout<<(a+b)/2<<" "<<(a-b)/2<<"\n";
   }
}

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

int main() {
	int a,b;
	cin>>a>>b;
	int an = min(a,b);
	int k = max(a,b);
	if(an+3>k)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
   #include <atcoder/all>
   using namespace atcoder;
#endif
#define all(v) v.begin(), v.end()
using in = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const int inf=max(int(1e18)+7,int(1e9)+7);
using P=pair<int,int>;
using T=tuple<int,int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
template <typename Typ>
bool chmin(Typ &a, const Typ& b) {if (a > b) {a = b; return true;} return false;}
template <typename Typ>
bool chmax(Typ &a, const Typ& b) {if (a < b) {a = b; return true;} return false;}
template <typename Typ>
Typ ceil(Typ x, Typ y){return (x+y-1)/y;}
#ifdef  _DEBUG
    #define debug(x) cout<<"debug:"<<x<<endl
    #define vdebug(x) cout<<"debug:";\
                      for(auto asdf:x) cout<<asdf<<" ";\
                      cout<<endl
#else
    #define debug(x)
    #define vdebug(x)
#endif
#define CASE(x) cout<<"Case #"<<x<<": "

//辺でカウント
vector<int> en(0),ex(0),vis(0);
vector<int> ran_f(0),ran_l(0);
vector<int> depth(0);
vector<int> par(0);
vector<vector<int>> tree(0);
int cnt=0;

void tour(int ed){
    int n = par.size();
    if(en.empty()){
        en.resize(n,-1);
        ex.resize(n,-1);
        ran_f.resize(n,-1);
        ran_l.resize(n,-1);
        depth.resize(n,-1);
        depth[ed] = 0;
    }

    en[ed] = cnt;
    cnt ++;
    vis.emplace_back(ed);
    ran_f[ed] = vis.size()-1;
    ran_l[ed] = vis.size()-1;

    for(auto nxt:tree[ed]){
        depth[nxt] = depth[ed]+1;
        tour(nxt);
        vis.emplace_back(ed);
        ran_l[ed] = vis.size()-1;
    }
    ex[ed] = cnt;
    cnt ++;
    return;
}

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
//cout << fixed << setprecision(12);
    int n;  cin>>n;
    vector<int> p(n,0);
    REP(i,1,n){
        cin>>p[i];
        p[i]--;
    }
    int q;  cin>>q;
    vector<int> u(q),d(q);
        rep(i,q) cin>>u[i]>>d[i];
        rep(i,q) u[i]--;

    par = p;
    tree = vector<vector<int>>(n,vector<int>(0));
    REP(i,1,n) tree[p[i]].emplace_back(i);
    tour(0);
    map<int,vector<int>> mp;
    rep(i,n) mp[depth[i]].emplace_back(en[i]);
    for(auto& [ignore,x]:mp) sort(all(x));

    rep(i,q){
        int x=u[i],y=d[i];
        int s=en[x],t=ex[x];
        int ans = upper_bound(all(mp[y]),t)-lower_bound(all(mp[y]),s);
        cout<<ans<<"\n";

    }

    // vdebug(en);
    // vdebug(ex);
    // vdebug(ran_f);
    // vdebug(ran_l);
    // vdebug(vis);
}/*
./problem.exe
*/

#include <bits/stdc++.h>

using namespace std;

struct DSU {
    vector<int> ps;
    vector<vector<int>> children;
    DSU(int n): ps(n), children(n) {
        iota(ps.begin(), ps.end(), 0);
        for (int i = 0; i < n; ++i) {
            children[i].push_back(i);
        }
    }
    int find(int i) {
        if (ps[i] == i) {
            return i;
        }
        return ps[i] = find(ps[i]);
    }
    bool merge(int i, int j) {
        i = find(i);
        j = find(j);
        if (i == j) {
            return false;
        }
        if (children[i].size() > children[j].size()) {
            swap(i, j);
        }
        ps[i] = j;
        children[j].insert(children[j].end(), children[i].begin(), children[i].end());
        return true;
    }
};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> edges(m);
    map<pair<int, int>, int> edges_dir; // -1 = not set, 0 = org, 1 = reverse
    for (auto& edge : edges) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        edge = {u, v};
        edges_dir[edge] = -1;
    }
    vector<int> cs(n);
    for (int& c : cs) {
        cin >> c;
    }
    vector<vector<int>> adj_list(n);
    for (auto& edge : edges) {
        int u, v;
        tie(u, v) = edge;
        if (cs[u] != cs[v]) {
            edges_dir[edge] = cs[u] > cs[v] ? 0 : 1;
        } else {
            adj_list[u].push_back(v);
            adj_list[v].push_back(u);
        }
    }
    DSU dsu(n);
    for (int u = 0; u < n; ++u) {
        set<int> seen;
        stack<int> seen_order;
        stack<pair<int, int>> edge_order;
        set<pair<int, int>> used_edges;
        function<bool (int)> dfs = [&](int v) {
            v = dsu.find(v);
            seen_order.push(v);
            if (seen.count(v)) {
                return true;
            }
            seen.insert(v);
            for (int w : dsu.children[v]) {
                for (int z : adj_list[w]) {
                    if (dsu.find(z) != v && !used_edges.count({w, z})) {
                        used_edges.insert({w, z});
                        used_edges.insert({z, w});
                        edge_order.push({w, z});
                        if (dfs(z)) {
                            return true;
                        }
                        edge_order.pop();
                    }
                }
            }
            seen_order.pop();
            return false;
        };
        if (dfs(u)) {
            assert (seen_order.size() == edge_order.size() + 1);
            int v = seen_order.top();
            seen_order.pop();
            vector<int> cycle = {v};
            while (true) {
                int w = seen_order.top();
                seen_order.pop();
                if (w == v) {
                    break;
                }
                cycle.push_back(w);
            }
            int cycle_size = (int) cycle.size();
            for (int i = 0; i < cycle_size; ++i) {
                assert (!edge_order.empty());
                int u0, v0;
                tie(u0, v0) = edge_order.top();
                edge_order.pop();
                if (edges_dir.count({u0, v0})) {
                    assert ((edges_dir[{u0, v0}] == -1));
                    edges_dir[{u0, v0}] = 0;
                } else {
                    assert (edges_dir.count({v0, u0}));
                    assert ((edges_dir[{v0, u0}] == -1));
                    edges_dir[{v0, u0}] = 1;
                }
            }
            for (int w : cycle) {
                dsu.merge(w, v);
            }
            --u;
        }
    }
    for (auto& edge : edges) {
        if (edges_dir[edge] == 1) {
            cout << "<-\n";
        } else {
            cout << "->\n";
        }
    }
}

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


#include<bits/stdc++.h>
using namespace std;
const int N=200005;
typedef long long LL;
int a[N],b[N],f[N],st[N],n,m,top;
long long sum[N][2];
inline int Find(int x){
    return x==f[x]?x:f[x]=Find(f[x]);
}
int main(void){
    cin>>n>>m;
    for(int i=1;i<=n;++i) f[i]=i;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i) cin>>b[i];
	for(int i=1;i<=m;++i){
        int u,v;
        cin>>u>>v;
        int fu=Find(u);
        int fv=Find(v);
		if(fu==fv) continue;
		else f[fv]=fu;
    }
	for(int i=1;i<=n;++i) st[++top]=Find(i);
	sort(st+1,st+top+1);
    top=unique(st+1,st+top+1)-st-1;
	for(int i=1;i<=n;++i){
        int fa=lower_bound(st+1,st+1+top,Find(i))-st;
        sum[fa][0]+=a[i];
        sum[fa][1]+=b[i];
    }
	int flag=1;
    for(int i=1;i<=top;++i){
        if(sum[i][0]!=sum[i][1]){
            flag=0;
            break;
        }
    }
	if(flag==1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

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

vi adj[MX];
int N,M;
vi a(MX),b(MX);

bool vis[MX];

pi p;

void dfs(int u){
	vis[u]=true;
	p.fi+=a[u]; p.se+=b[u];
	for(auto v: adj[u]) if(!vis[v]){
		dfs(v);
	}
}

int32_t main() {
	boost; IO();

	cin>>N>>M;

	FOR(i,1,N+1) cin>>a[i];
	FOR(i,1,N+1) cin>>b[i];

	FOR(i,0,M){
		int u,v; cin>>u>>v;
		adj[u].pb(v); adj[v].pb(u);
	}

	memset(vis,0,MX);
	FOR(i,1,N+1) if(!vis[i]){
		p={0,0};
		dfs(i);
		if(p.fi!=p.se){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}

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

const ll INF=1e9;

const ll mod = 998244353;
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;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    mint A=a*(a+1)/2;
    mint B=b*(b+1)/2;
    mint C=c*(c+1)/2;
    mint ans=A*B*C;
    cout << ans << endl;
    return 0;
}

// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define si set<int>
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;
// ll m = 1e9 + 7;
ll m = 998244353;
    vector<vi> adj;
vi h;
vi sz;
vi in;

ll add(ll a, ll b, ll mod = m)
{
    return ((a % mod) + (b % mod)) % mod;
}
ll mul(ll a, ll b, ll mod = m)
{
    return ((a % mod) * (b % mod)) % mod;
}
ll sub(ll a, ll b, ll mod = m)
{
    return ((a % mod) - (b % mod) + mod) % mod;
}

ll modmul(ll a, ll b, ll mod = m)
{
    ll ans = 0;
    a = a % mod;
    while (b)
    {
        if (b & 1)
            ans = add(ans, a, mod);
        a = mul(a, 2, mod);
        b >>= 1;
    }
    return ans;
}

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

ll fe(ll base, ll exp, ll mod = m)
{
    ll ans = 1;
    while (exp)
    {
        if (exp & 1)
            ans = mul(ans, base, mod);
        base = mul(base, base, mod);
        exp >>= 1;
    }
    return ans;
}

void dfs_h_sz(int cur, int par)
{
    h[cur] = h[par] + 1;
    sz[cur]++;
    for (const auto &v : adj[cur])
    {
        if (v == par)
            continue;
        dfs_h_sz(v, cur);
        sz[cur] += sz[v];
    }
}

void buildGraph(int n, int m)
{
    adj = vector<vi>(n + 1);
    h = vector<int>(n + 1);
    sz = vector<int>(n + 1);
    in = vector<int>(n + 1);

    loop(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs_h_sz(1, 0);
}
struct cmp
{
    bool operator()(const pi &a, const pi &b)
    {
        return a.ff < b.ff;
    }
};

ll modin(ll a){
    return fe(a,m-2);
}

ll sum(ll a){
    return mul(mul(a,a+1),modin(2));
}
void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll ans = sum(a);
    ans = mul(ans,sum(b));
    ans = mul(ans,sum(c));
    cout<<ans<<"\n";
}
int main()
{
    io;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int test;
    // cin >> test;
    test=1;
    while (test--)
    {
        solve();
    }
    return 0;
}


///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define                          ll                          long long int
ll gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

#define                          in(x)                       scanf("%lld",&x)
#define                          in2(x,y)                    scanf("%lld %lld",&x,&y)
#define                          in3(x,y,z)                  scanf("%lld %lld %lld",&x,&y,&z)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          inf                         1e18
#define                          neg                         -1e18
#define                          mx                          2111111
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                          fi                          first
#define                          si                          second
#define                          ce                          cout<<endl
#define                          pb                          push_back
#define                          vc(x)                       x.begin(),x.end()
#define                          pb                          push_back
#define                          pi                          pair<ll,ll>
#define                          debug                       printf("ok\n");
#define                          pg                          pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> >
#define                          mod                         1000000007

vector<ll>g[mx];
bool vis[mx];
ll a[mx],b[mx],m,n,s=0,sum=0;

void dfs(ll u){
 queue<ll>q;
 sum+=a[u];
 s+=b[u];

 vis[u]=1;
 q.push(u);
    while(!q.empty()){
        ll v;
        v=q.front();
        q.pop();
        for(auto x: g[v]){
            if(!vis[x]){
                vis[x]=1;
                sum+=a[x];
                s+=b[x];

                q.push(x);

            }
        }

    }

}

int main(){
    //fast
    ll t;

        ll i,j,m,ans=0,n;
        in2(n,m);
        for(i=1;i<=n;i++)in(a[i]);
        for(i=1;i<=n;i++)in(b[i]);
        ll u,v;
        for(i=0;i<m;i++){
                cin>>u>>v;
                g[v].pb(u);
                g[u].pb(v);
        }
        for(i=1;i<=n;i++){

            if(s!=sum){

                cout<<"No"<<endl;return 0;
            }
            s=0;sum=0;
            if(!vis[i]){
                dfs(i);
            }

        }

    cout<<"Yes"<<endl;

 }

/*
	author: parv2809
*/

#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

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

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

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

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

void dfs(vector<vector<int> >& gr, int src, vector<int>& visited, vector<int>& curr_tree) {

	visited[src] = 1;

	for (auto it : gr[src]) {
		if (!visited[it])
			dfs(gr, it, visited, curr_tree);
	}

	curr_tree.pb(src);
	return;

}

int32_t main() {

	fastIO();
	int t = 1;
	w(t) {

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

		vector<int> a(n), b(n);

		arrIn(a, n);
		arrIn(b, n);

		vector<vector<int> > graph(n);
		int c, d;
		for (int i = 0; i < m; i++) {
			cin >> c >> d;
			c--, d--;
			graph[c].pb(d);
			graph[d].pb(c);
		}

		vector<int> visited(n, 0);
		bool ans = true;
		for (int i = 0; i < n; i++) {
			if (!visited[i]) {
				vector<int> curr_tree;
				dfs(graph, i, visited, curr_tree);
				int sum = 0;
				for (auto it : curr_tree) {
					sum += (a[it] - b[it]);
				}
				if (sum != 0) {
					ans = false;
					break;
				}
			}
		}
		if (ans)
			cout << "Yes\n";
		else
			cout << "No\n";

	}

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;


#include<bits/stdc++.h>
using namespace std;
#define ll int
vector<ll>seg[4*200009];
vector<ll>ad[200009];
ll s[200009];
ll f[200009];
ll T;
ll val[200009];
ll lev[200009];
void dfs(ll a,ll p)
{
    lev[a]=lev[p]+1;
    T++;
    s[a]=T;
    val[T]=a;
    ll b,i,l=ad[a].size();
    for(i=0;i<l;i++)
    {
        b=ad[a][i];
        if(b!=p)
        {
            dfs(b,a);
        }
    }
    f[a]=T;
}
void merge_(ll pos,ll l,ll r)
{
    ll i,j,n,m;
    n=seg[l].size();
    m=seg[r].size();
    i=j=0;
    while(1)
    {
        if(i==n || j==m)
        {
            break;
        }
        if(seg[l][i]<=seg[r][j])
        {
            seg[pos].push_back(seg[l][i]);
            i++;
        }
        else
        {
            seg[pos].push_back(seg[r][j]);
            j++;
        }
    }
    while(i<n)
    {
        seg[pos].push_back(seg[l][i]);
        i++;
    }
    while(j<m)
    {
        seg[pos].push_back(seg[r][j]);
        j++;
    }
}
void create(ll lo,ll hi,ll pos)
{
    if(lo==hi)
    {
        seg[pos].push_back(lev[val[lo]]);
        return;
    }
    ll m=(lo+hi)/2;
    create(lo,m,2*pos);
    create(m+1,hi,2*pos+1);
    merge_(pos,2*pos,2*pos+1);
    return;

}
ll query(ll qlo,ll qhi,ll lo,ll hi,ll pos,ll val)
{
    if(qlo>hi || qhi<lo)
    {
        return 0;
    }
    if(qlo<=lo && qhi>=hi)
    {
        ll a=lower_bound(seg[pos].begin(),seg[pos].end(),val)-seg[pos].begin();
        ll b=upper_bound(seg[pos].begin(),seg[pos].end(),val)-seg[pos].begin();
        return (b-a);
    }

    ll m=(lo+hi)/2;
    return query(qlo,qhi,lo,m,2*pos,val)+query(qlo,qhi,m+1,hi,2*pos+1,val);

}
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    scanf("%d",&n);
    for(i=2;i<=n;i++)
    {
        scanf("%d",&a);
        ad[a].push_back(i);
    }
    T=0;
    lev[0]=-1;
    dfs(1,0);
    create(1,n,1);
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&a,&c);
        x=query(s[a],f[a],1,n,1,c);
        printf("%d\n",x);
    }
}

#include "bits/stdc++.h"
using namespace std;
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define mod 1000000007

const int N = 2e5 + 5;
vector<int> tree[N], depth(N);
vector<int> time_in(N), time_out(N);
vector<int> orders[N];
int timer = 0, n;

void dfs(int s) {
	time_in[s] = timer++;
	orders[depth[s]].push_back(time_in[s]);
	for (int v : tree[s]) {
		depth[v] = 1 + depth[s];
		dfs(v);
	}
	time_out[s] = timer++;
}

void test_case() {
	cin >> n;
	int j;
	for (int i = 2; i <= n; i++) {
		cin >> j;
		tree[j].push_back(i);
	}
	dfs(1);
	int q;
	cin >> q;
	while (q--) {
		int u, d;
		cin >> u >> d;
		auto &arr = orders[d];
		auto y = lower_bound(arr.begin(), arr.end(), time_out[u]);
		auto x = lower_bound(arr.begin(), arr.end(), time_in[u]);
		cout << y - x << "\n";
	}
}

signed main() {
	FastIO;
	test_case();
	return 0;
}
/*
         ▄              ▄
        ▌▒█           ▄▀▒▌
        ▌▒▒█        ▄▀▒▒▒▐
       ▐▄█▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
     ▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
   ▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
  ▐▒▒▒▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▌
  ▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
 ▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌
 ▌░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌
▌▒▒▒▄██▄▒▒▒▒▒▒▒▒░░░░░░░░▒▒▒▐
▐▒▒▐▄█▄█▌▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
▐▒▒▐▀▐▀▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▐
 ▌▒▒▀▄▄▄▄▄▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▒▌
 ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▒▄▒▒▐
  ▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▄▒▒▒▒▌
    ▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
      ▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
         ▀▀▀▀▀▀▀▀▀▀▀▀
*/


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

#define rep(i,n) for (int i=0;i<(int)(n);++i)
#define rep1(i,n) for (int i=1;i<=(int)(n);++i)
#define range(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

using namespace std;

int main(){

    string s;
    cin >> s;
    string ans = "";
    for(long long i=0;i<s.length();i++) {
        if(s[i] == '.') {
            break;
        } else {
            ans += s[i];
        }
    }
    cout << ans;

    return 0;
}

#pragma region Macros
#include <bits/stdc++.h>
#if defined(LOCAL) || defined(ONLINE_JUDGE) || defined(_DEBUG)
#include <atcoder/all>
#endif
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class T>using vec = vector<T>;
template<class T, class U>using umap = unordered_map<T, U>;
using ll = long long;
using P = pair<ll, ll>;
using vl = vec<ll>;
#define fi first
#define se second
#define el endl
constexpr ll INF = numeric_limits<ll>::max()/2-1;
#pragma endregion

#pragma region IOMacros
template<class T>
istream &operator>>(istream &stream, vec<T>& o){REP(i, o.size())stream >> o[i];return stream;}
template<class T>
ostream &operator<<(ostream &stream, vec<T>& objs){REP(i, objs.size())stream << objs[i] << " ";stream << el;return stream;}

#define I(T, ...) ;T __VA_ARGS__;__i(__VA_ARGS__);
void __i() {}
template<class T, class... Ts> void __i(T&& o, Ts&&... args){cin >> o;__i(forward<Ts>(args)...);}

void O() {cout << el;}
template<class T, class... Ts> void O(T&& o, Ts&&... args){cout << o << " ";O(forward<Ts>(args)...);}
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    I(ll, X);
    ll t = (X+100)/100;
    cout << 100*t-X << el;
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 505;
const int INF = 1e12;

int n,m;
int x[105], y[105], z[105];
int memo[(1<<19)][20];

int solve(int mask, int pos)
{
    // cout<<mask<<" "<<pos<<endl;
    if(pos == n)return 1;
    if(memo[mask][pos] != -1) return memo[mask][pos];
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        if(!((mask>>i)&1LL))
        {
            int ok = 1;
            int new_mask = mask|(1LL<<i);
            for(int j=0;j<m;j++)
            {
                if(x[j]>=pos)
                {
                    int cnt = 0;
                    for(int k=0;k<=y[j];k++) cnt += ((new_mask>>k)&1LL);
                    ok &= (cnt <= z[j]);
                }
            }
            // cout<<new_mask<<endl;
            if(ok) ans += solve(new_mask, pos+1);
        }
    }
    // cout<<mask<<" "<<pos<<" "<<ans<<endl;
    memo[mask][pos] = ans;
    return ans;
}

signed main()
{
  FAST
  int tc=1;
//   cin>>tc;
  for(int ti=1;ti<=tc;ti++)
  {
      cin>>n>>m;
      for(int i=0;i<m;i++) cin>>x[i]>>y[i]>>z[i], x[i]--,y[i]--;
      for(int i=0;i<(1LL<<n);i++)for(int j=0;j<n;j++)memo[i][j] = -1;
      int ans = solve(0, 0);
      cout<<ans<<endl;
  }
  return 0;
}

#include<cstdio>
#define F(i,l,r) for(int i=l,i##_end=r;i<i##_end;++i)
using namespace std;
const int N=20,M=105;
template<typename T>void read(T &x)
{
	bool neg=false;
	unsigned char c=getchar();
	for(;(c^48)>9;c=getchar())if(c=='-')neg=true;
	for(x=0;(c^48)<10;c=getchar())x=(x<<3)+(x<<1)+(c^48);
	if(neg)x=-x;
}
int n,m,x[M],y[M],z[M],pop[1<<N],bit[1<<N][N];
long long f[1<<N];
bool check(int i,int j)
{
	F(k,0,m)if(i==x[k]&&bit[j][y[k]]>z[k])return false;
	return true;
}
int main()
{
	read(n);read(m);
	F(i,0,m)read(x[i]),read(y[i]),read(z[i]);
	F(i,1,1<<n)pop[i]=pop[i^(i&-i)]+1;
	F(i,0,1<<n)F(j,0,n)bit[i][j+1]=bit[i][j]+(i>>j&1);
	f[0]=1;
	F(i,0,n)F(j,0,1<<n)if(pop[j]==i)
	{
		if(i==0||check(i,j))
			F(k,0,n)if((j>>k&1)==0)
			{
				int v=j^1<<k;
				f[v]+=f[j];
			}
	}
	printf("%lld\n",f[(1<<n)-1]);
	return 0;
}


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

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

#define endl '\n'
#define pb push_back
#define fr first
#define sc second
#define ll long long int
#define ld long double
#define bit(idx) idx&(-idx)
#define bin(x) bitset<32>(x).to_string()
#define all(A) A.begin(), A.end()
#define de(x) cout << #x << " = " << x << endl;
#define row vector<ll>
#define row_matrix vector<ll>
#define matrix vector<row_matrix>
#define ordered_set_T ll

using namespace std;
using namespace __gnu_pbds;

typedef tree<ordered_set_T, null_type, less<ordered_set_T>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
/// find_by_order(x) -> x-th element in the set
/// order_of_key(x)  -> how many elements are smaller than x
/// insert(x)		 -> inserts x into the set

int main(){
	/// ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	row A(n);
	for(int i = 0; i < n; i ++) cin >> A[i];
	for(int i = 1; i < n; i ++){
		if(i & 1) A[i] = A[i - 1] - A[i];
		else 	  A[i] = A[i - 1] + A[i];
	}
	unordered_map<ll, ll> mp;
	mp[0] = 1;
	ll ans = 0;
	for(auto x : A) ans += mp[x] ++;
	cout << ans << endl;
}
/**

*/

#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#include<iostream>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}
ll num[524310];
const ll dekai = 1ll << 60;
int kazu[524310];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) | 1;
	while (num[n2]) {
		if (num[n2] == (n | dekai)) return kazu[n2];
		n2 = n2 * 2 % 524309;
	}
	return 0;
}
void add(ll n) {
	int n2 = (n & ma) | 1;
	while (num[n2]) {
		if (num[n2] == (n | dekai)) {
			kazu[n2]++;
			return;
		}
		n2 = n2 * 2 % 524309;
	}
	num[n2] = n | dekai;
	kazu[n2] = 1;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N = getint();

	add(0);
	ll kotae = 0;
	ll ima = 0;
	int pn = 1;
	rep(i, N) {
		ima += pn * getint();
		kotae += query(ima);
		add(ima);
		pn = -pn;
	}

	co(kotae);

	Would you please return 0;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=1;i<=(n);++i)
#define rep3(i,i0,n) for(ll i=i0;i<(n);++i)
#define rrep(i,n) for(ll i=((n)-1); i>=0; --i)
#define rrep2(i,n) for(ll i=(n); i>0; --i)
#define pb push_back
#define mod 1000000007
#define fi first
#define se second
#define len(x) ((ll)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
using Pi = pair< ll, ll >;
using vl = vector<ll>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<Pi>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

const ll INF = 1LL << 60;
const ld PI = 3.1415926535897932385;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
void printb(ll N,ll d=16){
    rep(i,d){
        cout<<(N/(1<<(d-i-1)))%2;
    }
    cout<<endl;

}
void printv(vector<ll>a){
    rep(i,a.size()){
        if(i==a.size()-1){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
}
bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

//const vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1};
//const vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
vvl A;
ll N;
// index が条件を満たすかどうか
bool isOK(ll idx, ll key) {
    vvl B(N,vl(5));

    rep(i,N){
        rep(j,5){
            if(A[i][j]>=idx){
                B[i][j]=1;
            }else{
                B[i][j]=0;
            }
        }
    }

    vl C(N);
    vector<ll>m(1000);
    rep(i,N){
        rep(j,5){
            C[i]+=(B[i][j]<<(5-j-1));
        }
        m[C[i]]=1;
    }

    rep(i,32){
        rep(j,32){
            rep(k,32){
                if(m[i]==1 && m[j]==1 &&m[k]==1){
                    if((i|j|k)==31){
                        return 1;
                    }
                }
            }

        }
    }

    return 0;
}
// 汎用的な二分探索のテンプレ
ll binary_search(ll key) {
    ll ng = INF; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = 0; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {

    cin>>N;
    A=vvl(N,vl(5));

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

    ll ans=binary_search(0);

    cout<<ans<<endl;

    return 0;

}

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    int A[N], B[N];
    rep(i,0,N){
        cin >> A[i] >> B[i];
    }
    int min_time = inf;
    rep(i,0,N){
        rep(j,0,N){
            if(i == j){
                int time = A[i] + B[i];
                min_time = min(time,min_time);
            }else{
                int time = max(A[i], B[j]);
                min_time = min(time,min_time);
            }
        }
    }
    cout << min_time << endl;
}


//Author- Vaibhav Singh

#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
#define vl vector<ll>
#define vc vector<char>
#define ul unordered_map<ll,ll>
#define uc unordered_map<char,ll>
#define vp vector<pair<ll,ll>>
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }

    }
}
  */

  ll powerm(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
  long long lcm(long long a, long long b){//?????????
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
/*
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];

void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}

ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}
*/

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

       int main()
       {
        fast
         ll n,x;
         cin>>n>>x;
         string s;
         cin>>s;
         ll i;
         f(i,n)
         {
             if(s[i]=='o')
             {
                 x++;
             }
             else
             {
                 if(x>0)
                 {
                     x--;
                 }
             }
         }

     o(x)

//?????????
re}

#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=200005;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 17500001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

    int n, x;
    cin >> n >> x;
    string s;
    cin >> s;
    for(auto i : s){
        if(i == 'o') x++;
        else{
            x--;
            x = max(0LL, x);
        }
    }
    cout << x << endl;

return 0;
}


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

#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//insert,find_by_order,order_of_key,lower_bound,upper_bound;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

//////////////////////////////code//////////////////////////////

const int N = 74;

int a,b;
int n;
vector<int> primes;

int dp[N][(1<<20)];

void solve()
{

		cin >> a >> b;

		for(int i = 2; i <= 72 ;i++)
		{
			int ok = 1;

				for(int j = 2; j < i ;j++)
				{
						if(i % j == 0)
							ok = 0;
				}

			if(ok)
				primes.pb(i);
		}

		n = sz(primes);

	    memset(dp,0,sizeof(dp));

	    dp[0][0] = 1;

	    for(int i = 1;i <= (b - a + 1) ;i++)
	    {
	    	   int mask1 = 0,bit = 1;

	    		for(int j = 0;j < n ; j++)
	    		{
	    				if((a + i - 1)%primes[j] == 0)
	    				 mask1 |= bit;

	    				bit<<=1;
	    		}

               for(int mask = 0;mask < (1 << n); mask++)
               {
               			if( ((mask)&(mask1)) == 0)
               			{
               					dp[i][(mask | mask1)] += dp[i-1][mask];
               			}

               			dp[i][mask] += dp[i - 1][mask];
               }
	    }

	    int ans = 0;

	    for(int mask = 0; mask < (1 << n); mask++)
	    {
	    		ans += dp[(b-a+1)][mask];
	    }

	    db(ans)

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

     #ifndef ONLINE_JUDGE
     freopen("INP.txt", "r", stdin);
     freopen("out.txt", "w", stdout);
     #endif

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

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values

#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

using Mask = int;

bool IsPrime(int n) {
    if (n < 2) {
        return false;
    }

    for (int64_t i = 2; i * i <= n; i += 1) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

vector<int> Primes(int limit) {
    vector<int> primes;
    for (int i = 2; i <= limit; i += 1) {
        if (IsPrime(i)) {
            primes.push_back(i);
        }
    }
    return primes;
}

Mask GetMask(int64_t num) {
    Mask mask = 0;

    static const auto kPrimes = Primes(72);
    for (size_t i = 0; i < kPrimes.size(); i += 1) {
        if (num % kPrimes[i] == 0) {
            mask |= (1 << i);
        }
    }
    return mask;
}

int64_t Solve(int64_t l, int64_t r) {
    vector<int64_t> sets(1 << 20, 0);
    sets[0] = 1;

    vector<Mask> masks;
    for (auto i = l; i <= r; i += 1) {
        masks.push_back(GetMask(i));
    }

    for (const auto& mask : masks) {
        for (Mask primes = mask; primes < (1 << 20); primes += 1) {
            if ((primes & mask) == mask) {
                sets[primes] += sets[primes & (~mask)];
            }
        }
    }
    return accumulate(sets.begin(), sets.end(), 0);
}

int main() {
    int64_t l, r;
    cin >> l >> r;

    auto res = Solve(l, r);
    cout << res << "\n";
    return 0;
}


#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(v) for (auto &e : v) { cin >> e; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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; }
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
#pragma endregion

int main() {
  IN(int, X);
  IN(int, Y);
  int mi = min(X, Y);
  int ma = max(X, Y);
  if (mi + 3 > ma) yes();
  else no();

  return 0;
}

// Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <tuple>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cmath>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll infll = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &element : vec) is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (int i = 0, vec_len = (int)vec.size(); i < vec_len; ++i) {
        os << vec[i] << (i + 1 == vec_len ? "" : " ");
    }
    return os;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    int t;
    int n;
    cin >> t >> n;
    --n;
    vector<int> vec(100 + t, 0);
    rep(i, 100) vec[i * (100 + t) / 100] = 1;
    int cnt = 0;
    rep(i, 100 + t) if (vec[i] == 0) ++cnt;
    ll ans = (100LL + t) * (n / cnt);
    n %= cnt;
    rep(i, 100 + t) {
        if (vec[i] == 0) {
            if (n == 0) {
                cout << ans + i << '\n';
                return 0;
            }
            --n;
        }
    }
}