#include <bits/stdc++.h>
#define int long long int
using namespace std;
int power(int x, int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int mod = 1000000007;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    int s= 0 ;
    for(int i = 1;i<= n;i++){
        int z;
        cin>>z;
        s+= z;
    }
    if(m<s ){
        cout<<"0\n";return 0 ;
    }
    int ans = 1;
    for(int i =m - s+1 ;i<=n+m;i++  ){
        ans*= i;
        ans%= mod;
    }
    for(int i = 1;i<= n+s;i++){
        ans = ans*(power(i , mod-2 , mod ) );
        ans%= mod;
    }
    cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(vector<bool>::reference b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
	friend string to_string(const Mint& b) { return to_string(b.val); }
};
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int s = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		scanf("%d", &a);
		s += a;
	}
	m += n;
	s += n;
	Mint ans = 1;
	for (int i = 0; i < s; ++i) {
		ans *= m - i;
		ans /= i + 1;
	}
	printf("%d\n", ans.val);
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
  vector<int64_t> S(N + 1, 0);
  int mod = 998244353;
  int64_t ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  for (int i = N - 1; i >= 0; i--) {
    S.at(i) = (2 * S.at(i + 1) + A.at(i)) % mod;
  }
  for (int j = N; j > 0; j--) {
    ans += (A.at(j - 1) * S.at(j)) % mod;
    ans %= mod;
  }
  for (int j = 0; j < N; j++) {
    ans += (A.at(j) * A.at(j)) % mod;
    ans %= mod;
  }
  cout << ans % mod << endl;
  return 0;
}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif
using namespace std;

//#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef vector<vector<int>> graph;
#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define MOD 998244353
#define MAXX 1.1529215e+18
#define _1 first
#define _2 second
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())

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

template<class t> using vc=vector<t>;

template<class T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

template<class T>
T extgcd(T a, T b, T &x, T &y) {
    T d = a;
    if (b == 0) {
      x = 1;
      y = 0;
    } else {
      d = extgcd(b, a%b, y, x);
      y -= (a/b)*x;
    }
    return d;
}

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p._1<<","<<p._2<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}

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

  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  SORT(A);
  ll tmp = 0;
  ll ans = 0;
  for (ll i = N-1; i >= 0; i--) {
    ans += A[i]*((A[i]+tmp)%MOD)%MOD;
    ans %= MOD;
    tmp *= 2;
    tmp %= MOD;
    tmp += A[i];
    tmp %= MOD;
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const int mod = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x;cin>>n>>x;
    rep(i,n){
        ll a;cin>>a;
        if(a==x)continue;
        cout<<a<<" ";
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
for(auto x: a){
	if(x!=k)cout<<x<<' ';
}
}


#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){

  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
  ll A,B;cin>>A>>B;
  cout<<max(2*A+100-B,0LL)<<endl;

}

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

#define int ll
#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

	int n , C;
	cin >> n >> C;
	vi a(n) , b(n) , c(n);
	fo(i , n) cin >> a[i] >> b[i] >> c[i];
	map<int,int> hm;
	int cur = 0 , prev = 0 , ans = 0;
	fo(i , n){
		hm[b[i] + 1] -= c[i];
		hm[a[i]] += c[i];
	}
	for(auto [k , v] : hm){
		ans += min(cur , C) * (k - prev);
		cur += v;
		prev = k;
	}
	cout << ans << '\n';
    return 0;
}


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

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

  constexpr int64_t MOD= 10;
  if(B==1){
    cout << A% MOD << endl;
    return 0;
  }
  if(B<= MOD and C<= 4){
    int64_t B_C= 1;
    for(int i=0; i<C; i++){
      B_C*= B;
    }

    int64_t calcA= 1;
    for(int i=0; i<B_C; i++){
      calcA*= A;
      calcA%= MOD;
    }
    cout << calcA << endl;
    return 0;
  }

  constexpr int64_t nil= -1;
  vector<int64_t> memo(MOD, nil);
  map<int, int64_t> digit;
  int64_t calcA= A% MOD;
  int i= 1;
  while(memo.at(calcA)==nil){
    memo.at(calcA)= i;
    digit[i]= calcA;
    i++;
    calcA*= A;
    calcA%= MOD;
  }
  int64_t offset= memo.at(calcA);
  int64_t L= i- memo.at(calcA);

  int64_t B_C_MOD_L= 1;
  int64_t powB= B;
  while(C > 0){
    if(C&1){
      B_C_MOD_L*= powB;
      B_C_MOD_L%= L;
    }

    powB*= powB;
    powB%= L;
    C>>= 1;
  }
  int64_t ans= digit.at((B_C_MOD_L+(L- offset))% L+ 1);

  cout << ans << endl;
}

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

#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define em emplaces
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
const ll Mod = 998244353;

int n, m;
ll f[5010];
ll invf[5010];

ll dp[15][5010];

ll inv(ll a) {
    ll b = Mod - 2;
    ll ret = 1;
    while(b) {
        if(b & 1) ret *= a;
        b >>= 1;
        a *= a;
        ret %= Mod;
        a %= Mod;
    }

    return ret;
}

int main() {
    fast;

    f[0] = 1;
    for(int i=1; i<=5000; i++) {
        f[i] = f[i-1] * i % Mod;
    }
    invf[5000] = inv(f[5000]);
    for(int i=5000; i>=1; i--) {
        invf[i-1] = invf[i] * i % Mod;
    }

    cin >> n >> m;

    dp[12][0] = 1;
    for(int i=11; i>=0; i--) {
        for(int j=0; j<=m; j++) {
            for(int k=0; k * (1<<i) <= j && k <= n; k+=2) {
                dp[i][j] += dp[i+1][j - k * (1<<i)] * f[n] % Mod * invf[k] % Mod * invf[n-k] % Mod;
                dp[i][j] %= Mod;
            }
        }
    }

    cout << dp[0][m];
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

void solve(int _rot){
   // printf("Case #%d: ",_rot);
   int n; cin>>n;
   string s[3];
   rep(i,0,3)cin>>s[i];

   string res="0";
   rep(_,0,n)res+='1';
   rep(_,0,n)res+='0';
   cout<<res<<'\n';
}

int main(){
   int t; scanf("%d",&t);
   rep(rot,0,t)solve(rot+1);
   return 0;
}

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

void solve() {
	int n,k; cin>>n>>k;
	int ans=0;
	for (int i=1; i<=n; i++) {
		ans+=i*k*100;
		ans+=k*(k+1)/2;
	}
	cout<<ans;
	return;
}

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


#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  int mp[5010][4];
  mp[0][0]=mp[0][1]=mp[0][2]=mp[0][3]=0;
  cin>>n>>s;
  rep(i,s.size() ){
    rep(j,4){
      mp[i+1][j]=mp[i][j];
    }
    if(s[i]=='A'){
      mp[i+1][0]++;
    }
    if(s[i]=='T'){
      mp[i+1][1]++;
    }
    if(s[i]=='C'){
      mp[i+1][2]++;
    }
    if(s[i]=='G'){
      mp[i+1][3]++;
    }
  }
  /*rep(i,4){
    rep(j,4){
      cout<<mp[i][j]<<" ";
    }
    cout<<endl;
    }*/
  int ans=0;
  rep(i,s.size()+1){
    repi(j,i+1,s.size()+1 ){
      int A=mp[j][0]-mp[i][0],T=mp[j][1]-mp[i][1],C=mp[j][2]-mp[i][2],G=mp[j][3]-mp[i][3];
      if(A==T && C==G){
	ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;

    for(int i = 0; i < n; ++i){
        vector<int> freq(26, 0);
        for(int j = i; j < n; ++j){
            ++freq[s[j]-'A'];
            if(freq['A'-'A']==freq['T'-'A'] && freq['C'-'A']==freq['G'-'A']) ++ans;
        }
    }

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

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


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin, a, b;
    print((a + b) / 2, (a - b) / 2);
    return 0;
}

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

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

    // div2[i]: i = n1 + n2 の組合わせ数 ( 1<= n1, n2 <= N)
    vector<int> div2(2*N+1 , 0);
    for (int i = 2; i <= (N + 1); ++i) { div2[i] = i - 1; }
    for (int i = (N + 2); i <= (2 * N); ++i) { div2[i] = 2 * N - i + 1; }

    // int_div2[i] = div2[0] + .. + div2[i]
    vector<long long int> int_div2(2 * N + 1, 0);
    for (int i = 1; i <= 2*N; ++i) { int_div2[i] = int_div2[i - 1] + static_cast<long long int>(div2[i]); }

    // 合計値の探索
    int sum = 0;
    long long int rank = 0;
    long long int pri_rank = 0;
    for (sum = 3; sum <= (3 * N); ++sum)
    {
        // 2 <= j - i <= 2N and 1 <= j <= N
        int b = max(2, sum - N);
        int e = min(sum - 1, 2 * N);
        long long int div3 = int_div2[e] - int_div2[b-1];     // = div3[i]: i = n1 + n2 + n3 の組合わせ数 ( 1<= n1, n2, n3 <= N)
        if (div3 >= K) { break; }
        else { K -= div3; }
    }

    int first_i = max(1, sum - 2 * N);
    int last_i = min(N, sum - 2);
    int k = 0;
    for (k = first_i; k <= last_i; ++k)
    {
        if (K <= div2[sum - k]) { break; }
        else { K -= div2[sum - k]; }
    }

    int first_o = max(1, sum - k - N);
    int o = first_o + static_cast<int>(K) - 1;
    int n = sum - k -o;

    cout << k << " " << o << " " << n << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(5e5)+10;
int n,a[maxn],b[maxn];
ll ans;
char s[maxn],t[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	scanf("%s",s+1); scanf("%s",t+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'0';
	for (int i=1;i<=n;i++) b[i]=t[i]-'0';
	for (int i=1,j=0;i<=n;i++) {
		if (j<=i) j=i+1;
		if (a[i]!=b[i]) {
			while (j<=n&&a[j]==0) j++;
			if (j>n) { puts("-1"); return 0; }
			ans+=j-i; a[j]=0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?

  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?

  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?

  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,k,n) for(int i=k;i<=n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define newl "\n"
#define vi vector <int>
#define pii pair <int,int>
#define fi first
#define se second
#define st(x) x.begin()
#define en(x) x.end()
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define len(x) x.length()
#define MAX *max_element
#define MIN *min_element
#define int long long int
const int MOD = 1e9 + 7;

template <typename T>
void print(T &x){
	for (auto &ele : x) cout << ele << ' ';
		cout << "\n";
}

void solveforcase(int tc){

	int n;
	cin>>n;
	int a[n];
	rep(i,n) cin>>a[i];
	int count = 0;
	rep(i,n){
		if(a[i]>=10){
			count += a[i]-10;
		}
	}

	cout << count << "\n";

}

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

	int T = 1;

	for(int tc = 1; tc<=T;tc++){
		solveforcase(tc);
	}
}


#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n + 1);
    while (m--) {
        int u, v;
        cin >> u >> v;
        G[u].emplace_back(v);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        vector<bool> vis(n + 1);
        vis[i] = true;
        ++ans;
        queue<int> q;
        q.emplace(i);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int& v : G[u]) {
                if (vis[v]) continue;
                vis[v] = true;
                ++ans;
                q.emplace(v);
            }
        }
    }
    cout << ans << '\n';
}

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
//     using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue
#define printa(a, L, R)         \
    for (int i = L; i < R; i++) \
    cout << a[i] << (i == R - 1 ? '\n' : ' ')
#define printv(a) printa(a, 0, a.size())
#define print2d(a, r, c)            \
    for (int i = 0; i < r; i++)     \
        for (int j = 0; j < c; j++) \
    cout << a[i][j] << (j == c - 1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
#define UB upper_bound
#define LB lower_bound
#define F first
#define S second
#define mem(a, x) memset(a, x, sizeof(a))
#define inf 1e18
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r, n) (int)(log2(n) / log2(r))
#define rev(v) reverse(v.begin(), v.end())
#define srt(v) sort(v.begin(), v.end())
#define grtsrt(v) sort(v.begin(), v.end(), greater<ll>())
#define all(v) v.begin(), v.end()
#define mnv(v) *min_element(v.begin(), v.end())
#define mxv(v) *max_element(v.begin(), v.end())
#define toint(a) atoi(a.c_str())
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)), v.end())
#define fout(x) fixed << setprecision(x)
#define debug(args...)                           \
    {                                            \
        string _s = #args;                       \
        replace(_s.begin(), _s.end(), ',', ' '); \
        stringstream _ss(_s);                    \
        istream_iterator<string> _it(_ss);       \
        deb(_it, args);                          \
    }
void deb(istream_iterator<string> it)
{
}
template <typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << endl;
    deb(++it, args...);
}
const int mod = 1e9 + 7;
const int N = 3e5 + 9;
const ld eps = 1e-9;
const ld PI = acos(-1.0);

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

//random_device rd;
//mt19937 random(rd());

ll gc(ll a, ll b)
{
    while (b)
    {
        ll x = a % b;
        a = b;
        b = x;
    }
    return a;
}
ll lc(ll a, ll b) { return a / gc(a, b) * b; }
ll qpow(ll n, ll k)
{
    ll ans = 1;
    assert(k >= 0);
    n %= mod;
    while (k > 0)
    {
        if (k & 1)
            ans = (ans * n) % mod;
        n = (n * n) % mod;
        k >>= 1;
    }
    return ans % mod;
}

void solve()
{
    ll n, x;
    cin>>n>>x;
    ll f=-1;
    ll tt=0;
    for(int i=1;i<=n;i++)
    {
        ll v, p;
        cin>>v>>p;
        tt+=v*p;
        if(tt>100*x and f==-1) f=i;
    }
    cout<<f<<nl;

}

int main()
{
    BeatMeScanf;
    ll t=1;
    // cin>>t;

    int cs=0;
    while(t--){
        solve();
    }
    return 0;
}


/**
  *    █████╗  ██████╗       ██████╗ ██╗     ███████╗
  *   ██╔══██╗██╔════╝       ██╔══██╗██║     ╚══███╔╝
  *   ███████║██║            ██████╔╝██║       ███╔╝
  *   ██╔══██║██║            ██╔═══╝ ██║      ███╔╝
  *   ██║  ██║╚██████╗▄█╗    ██║     ███████╗███████╗
  *   ╚═╝  ╚═╝ ╚═════╝╚═╝    ╚═╝     ╚══════╝╚══════╝
  *
  *  @Author: TieWay59
  *  @Created: 2020/10/28 15:37
  *  @Link: https://atcoder.jp/contests/arc106/tasks/arc106_c
  *  @Tags:
  *
  *******************************************************/

#include <bits/stdc++.h>

#ifdef DEBUG

#   include "libs59/debugers.h"
//  #define debug(x)  cerr <<#x << " = "<<x<<endl;
#else
#   define endl '\n'
#   define debug(...)
#   define max(x,y) ((x)>(y)?(x):(y))
#   define min(x,y) ((x)>(y)?(y):(x))
#endif

#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
typedef long long ll;
const int MAXN = 2e5 + 59;
const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll llINF = 0x3F3F3F3F3F3F3F3F;
using namespace std;
using pii = pair<int, int>;
using vint = vector<int>;

ll fpow(ll a, ll b, ll mod = MOD) {
    if (a % mod == 0) return 0;
    ll ret = 1;
    a %= mod;
    while (b) {
        if (b & 1)ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}

int n, m;
const int shuff = 1e6;

void solve(int kaseId = -1) {
    cin >> n >> m;
    if (m < 0) {
        cout << -1 << endl;
    } else if (m == 0) {
        for (int i = 1; i <= n; ++i) {
            cout << i * 2 - 1 << " " << i * 2 << endl;
        }
    } else if (m < n - 1) {
        for (int i = 1; i <= m + 1; ++i) {
            cout << shuff + i * 2 - 1 << " " << shuff + i * 2 << endl;
        }
        int l = -1, r = (m + 1) * 2 + 1;
        for (int i = m + 2; i <= n; ++i) {
            cout << shuff + l << " " << shuff + r << endl;
            l--;
            r++;
        }
    } else {
        cout << -1 << endl;
    }
}

void solves() {
    MULTIKASE {
        solve(kase);
    }
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r+", stdin);
#endif
    STOPSYNC;
    solve();
    return 0;
}
/*

 */

/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Solutions
 */

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

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  if (m == 0) {
    for (int i = 1; i <= n; i++)
      printf("%d %d\n", 2 * i - 1, 2 * i);
    return 0;
  }

  if (m >= n - 1 || m < 0) {
    puts("-1");
    return 0;
  }

  printf("1 %d\n", 2 * (m + 2));
  for (int i = 1; i <= m + 1; i++)
    printf("%d %d\n", 2 * i, 2 * i + 1);
  for (int i = m + 3; i <= n; i++)
    printf("%d %d\n", 2 * i - 1, 2 * i);

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
  #define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
  #define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)

int x;

map<int,int> dp;

int rec(int curr)
{
  if(curr <= x)return x-curr;
  if(dp.find(curr) != dp.end())return dp[curr];
  int ans = curr-x;

  if(curr%2 == 0)
  {
    if(curr/2 > x)ans = min(ans,1 + rec(curr/2));
    else ans = min(ans, 1 + x - curr/2);
  }
  else if(curr + 1 == x or curr - 1 == x)return 1;
  else
  {
    ans = min({ans,2 + rec((curr+1)/2),2 + rec((curr-1)/2)});
  }
  return dp[curr] = ans;
}
int32_t main()
{

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

    int y;
    cin >> x >> y;

    cout << rec(y);

    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<complex>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
map<ll,ll>vis,dp;
ll x,y;
ll rec(ll i){
	if(i==1)return abs(i-x);
	if(vis[i])return dp[i];
	vis[i]=1;
	dp[i]=abs(i-x);
	if(i%2==0)dp[i]=min(dp[i],1+rec(i/2));
	else dp[i]=min(dp[i],1+min(rec(i+1),rec(i-1)));
	return dp[i];
}
void solve(){
	cin>>x>>y;
	if(x>=y){cout<<x-y;return;}
	cout<<rec(y);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


// Fearless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long>
#define PI (2.0 * acos(0.0))
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
const long long M = 1e5 + 10, M2 = 1e6 + 10, oo = 1e9 + 7;
int k, n;
string s;
int ara[30][30], ln;
int bigmod (int n, int p) {
	if (p == 0) return 1;
	int ans = bigmod(n, p / 2);
	ans = (ans * ans) % ln;
	if (p % 2 == 1) ans = (ans * n) % ln;
	return ans;
}
char dp[102][102];
char get (int pos, int sz) {
	//cout << pos << " " << sz << endl;
	if (dp[pos][sz] != '?') return dp[pos][sz];
	if (sz == 0) {
		return s[pos];
	}
	char c1, c2;
	int mpos = (pos + bigmod(2, sz - 1)) % n;
	c1 = get(pos, sz - 1);
	c2 = get(mpos, sz - 1);
	if (c1 == c2) return dp[pos][sz] = c1;
	return dp[pos][sz] = ara[min(c1 - 'A', c2 - 'A')][max(c1 - 'A', c2 - 'A')] + 'A';
}
void solve () {
	cin >> n >> k >> s;
	ln = n;
	ara['R' - 'A']['S' - 'A'] = 'R' - 'A';
	ara['P' - 'A']['R' - 'A'] = 'P' - 'A';
	ara['P' - 'A']['S' - 'A'] = 'S' - 'A';
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) dp[i][j] = '?';
	}
	cout << get(0, k) << endl;
}
int main () {
    //freopen("E:/newts/in.txt", "r", stdin);
    //freopen("E:/newts/out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //testcase {
        solve ();
    //}
    return 0;
}


#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<pair<ll, int>> xs, ys;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        xs.push_back({x, i});
        ys.push_back({y, i});
    }
    sort(ALL(xs));
    sort(ALL(ys));
    vector<pair<ll, ll>> ans;
    ans.push_back({xs[xs.size() - 1].first - xs[0].first, xs[xs.size() - 1].second * 100000ll + xs[0].second});
    ans.push_back({xs[xs.size() - 2].first - xs[0].first, xs[xs.size() - 2].second * 100000ll + xs[0].second});
    ans.push_back({xs[xs.size() - 1].first - xs[1].first, xs[xs.size() - 1].second * 100000ll + xs[1].second});

    ans.push_back({ys[ys.size() - 1].first - ys[0].first, ys[ys.size() - 1].second * 100000ll + ys[0].second});
    ans.push_back({ys[ys.size() - 2].first - ys[0].first, ys[ys.size() - 2].second * 100000ll + ys[0].second});
    ans.push_back({ys[ys.size() - 1].first - ys[1].first, ys[ys.size() - 1].second * 100000ll + ys[1].second});

    sort(ALL(ans), greater<pair<ll, ll>>());
    ll id = ans[0].second;
    rep(i, ans.size())
    {
        if (ans[i].second != id)
        {
            cout << ans[i].first << endl;
            return 0;
        }
    }
}

#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
using ll = long long;
void push(vector<pair<ll, ll>> vec, vector<pair<ll, ll>>& aft) {
	aft.at(0) = vec.at(0);
	aft.at(1) = vec.at(1);
	aft.at(2) = vec.at(vec.size() - 2);
	aft.at(3) = vec.at(vec.size() - 1);
}
int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>> x(n);
	vector<pair<ll, ll>> y(n);
	for (int i = 0; i < n; i++) {
		cin >> x.at(i).first >> y.at(i).first;
		x.at(i).second = i;
		y.at(i).second = i;
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	vector<pair<ll,ll>> aftx (4);
	vector<pair<ll, ll>> afty(4);
	push(x, aftx); push(y, afty);
	vector<tuple<ll, ll, ll>> ans;
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			ans.push_back(make_tuple(
				abs(aftx.at(i).first
					- aftx.at(j).first),
				aftx.at(i).second,
				aftx.at(j).second));
		}
	}
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			ans.push_back(make_tuple(
				abs(afty.at(i).first
					- afty.at(j).first),
				afty.at(i).second,
				afty.at(j).second));
		}
	}
	sort(ans.begin(), ans.end());
	//2,3番の要素を整列
	if (get<1>(ans.at(ans.size() - 1))
		< get<2>(ans.at(ans.size() - 1))) {
		swap(get<1>(ans.at(ans.size() - 1)),
			get<2>(ans.at(ans.size() - 1)));
	}
	if (get<1>(ans.at(ans.size() - 2))
		< get<2>(ans.at(ans.size() - 2))) {
		swap(get<1>(ans.at(ans.size() - 2)),
			get<2>(ans.at(ans.size() - 2)));
	}
	if (ans.at(ans.size() - 1)
		== ans.at(ans.size() - 2)) {
		ans.erase(ans.end() - 2);
	}
	cout << get<0>(ans.at(ans.size() - 2)) << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_V 200001 //10^5
int V,E,depth[MAX_V];  //dは開始ノードからの距離=深さ
typedef long long ll;
ll val[MAX_V];

//numは辺番号。消しても良いし、他の用途に使っても良し
struct edge{
    int to,num;
};
vector<edge> G[MAX_V];
struct ED{
  int from,to;
};
ED P[MAX_V];

void input_graph(int E){
    int s,t;
    REP(i,E){
        cin>>s>>t;s--;t--;
        G[s].push_back({t,i});
        G[t].push_back({s,i}); //無向グラフの場合
        P[i]={s,t};
    }
}

//幅優先探索。引数は開始ノード。
void bfs(int root){
  queue<int> q;q.push(root);
  vector<bool> used(V,false);used.at(root)=true;
  depth[root]=0;

  while(!q.empty()){
    int now=q.front();q.pop();
    REP(i,G[now].size()){
      int next=G[now].at(i).to;
      if(!used.at(next)){
        used.at(next)=true;
        depth[next]=depth[now]+1; //距離の追加
        //ここに処理を追加
        q.emplace(next);
      }
    }
  }
}

//幅優先探索。引数は開始ノード。
void bfs2(int root){
  queue<int> q;q.push(root);
  vector<bool> used(V,false);used.at(root)=true;

  while(!q.empty()){
    int now=q.front();q.pop();
    REP(i,G[now].size()){
      int next=G[now].at(i).to;
      if(!used.at(next)){
        used.at(next)=true;
        val[next]+=val[now];
        q.emplace(next);
      }
    }
  }
}

int main(){
  cin>>V;E=V-1;
  input_graph(E);
  bfs(0);

  int q;cin>>q;
  REP(i,q){
    int t,e,x;cin>>t>>e>>x;e--;
    int st,en;
    if(t==1){
      st=P[e].from;
      en=P[e].to;
    }else{
      st=P[e].to;
      en=P[e].from;
    }
    //cout<<"st"<<st<<" "<<en<<endl;
    if(depth[st]<depth[en]){
      val[0]+=(ll)x;
      val[en]-=(ll)x;
    }else{
      val[st]+=(ll)x;
    }
  }

  bfs2(0);
  REP(i,V){
    cout<<val[i]<<endl;
  }
  return 0;
}

#include<iostream>
#include<sstream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<numeric>
#include<queue>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long
#define MOD 1000000007
#define INF 9223372036854775800

using namespace std;

ll int recal(ll int y, ll int x, ll int flag,vector< vector< bool > > bo,ll int A, ll int B,
		ll int H, ll int W){
	ll int ans = 0;
	if( flag == 0 ){
		if( A >= 1 ){
			if( bo[y][x] ){
				if( x != W-1 ){
					ans += recal(y,x+1,flag,bo,A,B,H,W);
					return ans;
				}
				else if( y != H-1 ){
					ans += recal(y+1,0,flag,bo,A,B,H,W);
					return ans;
				}
			}
			else{
				A-=1;
				bo[y][x] = true;
				ll int f=0;
				rep(i,H){
					rep(j,W){
						if( !bo[i][j] ){
							f = 1;
						}
					}
				}
				if( f == 0 ){
					return 1;
				}
			}
			if( x != W-1 ){
				ans += recal(y,x+1,0,bo,A,B,H,W);
				ans += recal(y,x+1,1,bo,A,B,H,W);
				ans += recal(y,x+1,2,bo,A,B,H,W);
			}
			else if( y != H-1 ){
				ans += recal(y+1,0,0,bo,A,B,H,W);
				ans += recal(y+1,0,1,bo,A,B,H,W);
				ans += recal(y+1,0,2,bo,A,B,H,W);
			}
		}
		else{
			return 0;
		}
	}
	else if( flag == 1 ){
		if( B >= 1 ){
			if( x == W-1 ){
				if( !bo[y][x] ){
					return 0;
				}
				else{
					ans += recal(y+1,0,flag,bo,A,B,H,W);
					return ans;
				}
			}
			else{
				if( bo[y][x] ){
					if( x != W-1 ){
						ans += recal(y,x+1,flag,bo,A,B,H,W);
						return ans;
					}
					else if( y != H-1 ){
						ans += recal(y+1,0,flag,bo,A,B,H,W);
						return ans;
					}
				}
				else{
					if( bo[y][x+1] ){
						return 0;
					}
					B -= 1;
					bo[y][x] = true;
					bo[y][x+1] = true;
					ll int f=0;
					rep(i,H){
						rep(j,W){
							if( !bo[i][j] ){
								f = 1;
							}
						}
					}
					if( f == 0 ){
						return 1;
					}

				}
				if( x != W-1 ){
					ans += recal(y,x+1,0,bo,A,B,H,W);
					ans += recal(y,x+1,1,bo,A,B,H,W);
					ans += recal(y,x+1,2,bo,A,B,H,W);
				}
				else if( y != H-1 ){
					ans += recal(y+1,0,0,bo,A,B,H,W);
					ans += recal(y+1,0,1,bo,A,B,H,W);
					ans += recal(y+1,0,2,bo,A,B,H,W);
				}
			}
		}
		else{
			return 0;
		}
	}
	else{
		if( B >= 1 ){
			if( y == H-1 ){
				return 0;
			}
			else{
				if( bo[y][x] ){
					if( x != W-1 ){
						ans += recal(y,x+1,flag,bo,A,B,H,W);
						return ans;
					}
					else if( y != H-1 ){
						ans += recal(y+1,0,flag,bo,A,B,H,W);
						return ans;
					}
				}
				else{
					if( bo[y+1][x] ){
						return 0;
					}
					B -= 1;
					bo[y][x] = true;
					bo[y+1][x] = true;
					ll int f=0;
					rep(i,H){
						rep(j,W){
							if( !bo[i][j] ){
								f = 1;
							}
						}
					}
					if( f == 0 ){
						return 1;
					}

				}
				if( x != W-1 ){
					ans += recal(y,x+1,0,bo,A,B,H,W);
					ans += recal(y,x+1,1,bo,A,B,H,W);
					ans += recal(y,x+1,2,bo,A,B,H,W);
				}
				else if( y != H-1 ){
					ans += recal(y+1,0,0,bo,A,B,H,W);
					ans += recal(y+1,0,1,bo,A,B,H,W);
					ans += recal(y+1,0,2,bo,A,B,H,W);
				}
			}
		}
		else{
			return 0;
		}
	}
	return ans;
}

int main(){

ll int H,W,A,B;
cin >> H >> W >> B >> A;

vector< vector< bool > > bo(H,vector< bool > (W,false) );
ll int ans = 0;

ans += recal(0,0,0,bo,A,B,H,W);
ans += recal(0,0,1,bo,A,B,H,W);
ans += recal(0,0,2,bo,A,B,H,W);

cout << ans << endl;

	return 0;

}


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

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

#include<bits/stdc++.h>
#define int long double
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower)
#define upper_string(s) transform(all(s),s.begin(),::toupper)
#define len(s) (int)s.size()
#define F first
#define S second
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=1e9+7;
void solve()
{
int r,x,y;
cin>>r>>x>>y;
double dist=sqrtl(x*x+y*y);
double k=dist/r;
int ans=ceil(k);
if(dist<r)
cout<<2;
else
cout<<ans;
}
signed main()
{
//code
fastio
int t=1;
//cin>>t;
while(t--)
{
solve();
cout<<endl;
}
}


#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

using namespace std;
vector<ll> a;
int n;
ll x;
map<Pll,ll> memo;
ll dfs(ll val,int k){
    Pll p=make_pair(val,k);
    if(memo.count(p)) return memo[p];
    if(k==n-1){
        return 1;
    }
    if(val%a[k+1]==0){
        return memo[p]=dfs(val,k+1);
    }else{
        val-=val%a[k+1];
        return memo[p]=dfs(val,k+1)+dfs(val+a[k+1],k+1);
    }
}
signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cin >> n >> x;
    a.resize(n);
    rep(i,n){
        cin >> a[i];
    }
    cout << dfs(x,0) << endl;
}
// g++ main.cpp -o main.out && ./main.out

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define rept(i,t,n) for(int64_t i = (int64_t)(t);i < (int64_t)(n);i++)
#define all(vec) vec.begin(), vec.end()
int main(){
  int64_t n;
  int64_t c,m = 0;
  cin >> n;
  int64_t t = n+1;
  rept(i,1,n+2){
    c += i;
    if(c > n+1){
      m = i-1;
      break;
    }
    else if(c == n+1){
      m = i;
      break;
    }
  }
  cout << n+1-m;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
#define lin(x) ll x; cin>>x;
#define stin(x) string x; cin>>x;
#define yn(x)  if(x) {  cout<<"Yes"<<endl;   }    else {    cout<<"No"<<endl;   }
#define YN(x)  if(x) {  cout<<"YES"<<endl;   }    else {    cout<<"NO"<<endl;   }
#define co(x) cout<<x<<endl;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll mod=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}
ll PS(ll a) {
  return a*(a+1);
}

int main() {
  lin(N);
  ll x=N+1;
  ll y=0;
  //meguru
  ll ng=inf*2,ok=0;
    while(ng-ok>1){
        ll mid=(ok+ng)/2;
        if(mid*(mid+1)<=2*x)ok=mid;
        else ng=mid;
    }

  co(N-ok+1);

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
const ll mod = 1e9 + 7;

int main(){
  ll n;
  cin >> n;
  ll k=sqrt(n);
  for(;k>-1;k++){
    ll temp=(k+1)*(k+2)/2;
    if(temp>n+1)break;
  }
  cout << n-(k-1);
}


#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ALL(a) (a).begin(), (a).end()

#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P - 1 + b);
  else {
    long b2 = powP(a, b/2);
    b2*=b2;
    b2%=P;
    return (b2 * powP(a, b%2)) % P;
  }
}

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;

#define INF INT_MAX

int main() {
  int t;
  cin>>t;
  for (int i = 0; i < t; i++) {
    long l, r;
    cin>>l>>r;
    if (r<2*l) cout<<0<<endl;
    else cout<<(r-2*l+1)*(r-2*l+2)/2<<endl;
    //long sum = (r-l+1)*(r-l+1)-r*(r+1)/2;
    //cout<<sum;
  }
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
ll  sum(ll a, ll b)
{
  return ((a+b)*(b-a+1))/2;
}

void solve()
{
    ll l, r;
    cin >> l >> r;
      ll xc=l ;
      ll xm=r-l;
      if(xc>xm)
        cout<<0<<"\n";
      else
        cout<< sum(r-xm-l+1,r-xc-l+1)<< "\n";
}

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


//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define a first
#define b second
#define fi first
#define sc second
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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

template<class t> using vc=vector<t>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fi<<","<<p.sc<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int pr[15]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int v[55];
void solve(){
	int n; cin >> n;
	rep(i, n){
		int p; cin >> p;
		int mask = 0;
		rep(j,15){
			if(p%pr[j] == 0) mask|=(1<<j);
		}
		v[i] = mask;
	}
	ll ans = 1e18, tmp;
	rep(mask,(1<<15)){
		rep(i,n) if( (v[i] & mask) == 0 ) goto fail;
		tmp = 1;
		rep(i,15)if(((mask>>i)&1)) tmp=tmp*pr[i];
		chmin(ans,tmp);
		fail:;
	}
	o(ans);
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	int t; t = 1; //cin >> t;
	while(t--) solve();
}

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

int main(){
  int N; cin >> N;
  ll sum = 0;
  for( int i=0; i<N; i++){
    ll a,b; cin >> a >> b;
    sum += ((a+b)*(b-a+1))/2;
  }
  cout << sum << endl;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("Yes"); return;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

struct Solver {
  void solve() {
    int n,s,d;
    scanf("%d%d%d",&n,&s,&d);
    rep(i,n) {
      int x,y;
      scanf("%d%d",&x,&y);
      if (x >= s) continue;
      if (y <= d) continue;
      dame;
    }
    cout<<"No"<<endl;
  }
};

int main() {
  int ts = 1;
  // scanf("%d",&ts);
  rrep(ti,ts) {
    Solver solver;
    solver.solve();
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    if(a == b){
        cout << a << endl;
    } else {
        cout << 3 - a - b << endl;
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
#define DIV 1000000007
//#define DIV 998244353

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; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

typedef vector<ll> vec;
typedef vector<vec> mat;

vector<ll> to[105];

ll N, M, K;

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

// A*Bの計算
mat mul(mat &A, mat&B) {
	mat C(A.size(), vec(B[0].size()));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++){
			for (int j = 0; j < B[0].size();j++){
				C[i][j] =(C[i][j] + A[i][k] * B[k][j]) % DIV;
			}
		}
	}
	return C;
}

// A^nの計算
mat pow(mat A, ll n) {
	mat B(A.size(),vec(A.size()));
	for (int i = 0;i < A.size(); i++) {
		B[i][i] = 1;
	}
	while (n > 0) {
		if (n & 1) {
			B = mul(B, A);
		}
		A = mul(A,A);
		n >>= 1;
	}
	return B;

}

int main(){
	cin >> N >> M >> K;
	vector<ll> base(N);
	rep(i, N) cin >> base[i];

	rep(i, M) {
		ll x, y;
		cin >> x >> y;
		x--;y--;
		to[x].push_back(y);
		to[y].push_back(x);
	}

	mat A(N, vec(N));

	rep(i, N) {
		ll rest = M - to[i].size();

		//そのまま
		A[i][i] = rest;
		A[i][i] *= modpow(M, DIV-2);
		A[i][i] %= DIV;

		//繋がってるやつから
		for(ll next: to[i]) {
			A[i][next] = modpow(2*M, DIV-2);
			A[i][i] += modpow(2*M, DIV-2);
			A[i][i] %= DIV;
		}
	}
	A = pow(A, K);

	rep(i, N) {
		ll ans = 0;
		rep(j, N) {
			ans += A[i][j] * base[j];
			ans %= DIV;
		}
		cout << ans << endl;
	}
}

#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;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
    int ret = 1; while (b > 0) {
        if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1;
    } return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
typedef vector<int> Vec;
typedef vector<Vec> Mat;
Vec mulMatVec(Mat a, Vec b)
{
    int n = b.size(); Vec ret(n, 0);
    rep(i, 0, n) rep(j, 0, n) ret[i] = add(ret[i], mul(a[i][j], b[j]));
    return ret;
}
Mat mulMatMat(Mat a, Mat b)
{
    int n = a.size(); Mat ret(n, Vec(n, 0));
    rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) ret[i][j] = add(ret[i][j], mul(a[i][k], b[k][j]));
    return ret;
}
Mat fastpow(Mat x, ll n)
{
    Mat ret(x.size(), Vec(x.size(), 0));
    rep(i, 0, x.size()) ret[i][i] = 1;
    while (0 < n) { if ((n % 2) == 0) { x = mulMatMat(x, x); n >>= 1; } else { ret = mulMatMat(ret, x); --n; } }
    return ret;
}
void printVec(Vec a) { cout << "[\t"; rep(i, 0, a.size()) cout << a[i] << "\t"; cout << "]" << endl; }
void printMat(Mat a) { rep(i, 0, a.size()) printVec(a[i]); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, M, K, A[101];
int X[10101], Y[10101];
int cnt[101];
bool E[101][101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> K;
	rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> X[i] >> Y[i], X[i]--, Y[i]--;

    Mat Ma(N, Vec(N));
	rep(i, 0, M) {
        cnt[X[i]]--;
        cnt[Y[i]]--;
        E[X[i]][Y[i]] = E[Y[i]][X[i]] = true;
	}

    rep(to, 0, N) {
        int cnt = M;
        rep(from, 0, N) if (to != from) {
            if (E[to][from]) {
                Ma[to][to] = add(Ma[to][to], mul(modinv(M), modinv(2)));
                Ma[to][from] = add(Ma[to][from], mul(modinv(M), modinv(2)));
                cnt--;
            }
        }
        Ma[to][to] = add(Ma[to][to], mul(cnt, modinv(M)));
    }

    Vec v(N, 0);
    rep(i, 0, N) v[i] = A[i];

    Ma = fastpow(Ma, K);
    v = mulMatVec(Ma, v);
    rep(i, 0, N) cout << v[i] << endl;
}


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

#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pb push_back
#define pii pair<int,int>
const int M=1e9+7;
const int N=200005;

signed main()	{
  FAST_IO
  int t1=1;
  //cin>>t1;
  while(t1--){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];

    sort(a,a+3);

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

  }
}

#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <cstdio>
#include <numeric>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
	int A, B, C,D,E,F,M;
	cin >> A >> B >> C;
	D = A + B;
	E = B + C;
	F = C + A;
	M = max(D, E);
	M = max(M, F);
	cout << M;
}


#include<bits/stdc++.h>
#define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++)
#define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--)
#define ll long long
#define ull unsigned long long
#define db double
#define pii pair<int, int>
#define mkp make_pair
using namespace std;
const int N = 2e5 + 7;
const int K = 18;
inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while('0' <= ch && ch <= '9') x = x * 10 + (ch ^ '0'), ch = getchar();
	return x * f;
}
int n, m, k;
int ans, dis[K][K], dp[K][1 << K], c[N];
vector<int> e[N];
int d[N];
void bfs(int s) {
	memset(d, 0x3f, sizeof(d));
	d[s] = 0;
	queue<int> q;
	q.push(s);
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(int v : e[u])
			if(d[v] > d[u] + 1) d[v] = d[u] + 1, q.push(v);
	}
}
int main() {
	n = read(), m = read();
	L(i, 1, m) {
		int u = read(), v = read();
		e[u].push_back(v);
		e[v].push_back(u);
	}

	k = read();

	L(i, 1, k) c[i] = read();

	L(i, 1, k) {
		bfs(c[i]);
		L(j, 1, k) dis[i][j] = d[c[j]];
	}

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

	L(i, 1, k) dp[i][1 << (i - 1)] = 1;
	L(i, 1, (1 << k) - 1) L(j, 1, k) if(i >> (j - 1) & 1)
		L(t, 1, k) if(! (i >> (t - 1) & 1)) dp[t][i | (1 << (t - 1))] = min(dp[t][i | (1 << (t - 1))], dp[j][i] + dis[j][t]);
	int ans = 1e9;
	L(i, 1, k) ans = min(ans, dp[i][(1 << k) - 1]);
	if(ans > 1e8) puts("-1");
	else printf("%d\n", ans);
	return 0;
}

//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

int n,m,b[li],a[19],k,flag,t,vis[li],dp[19][li],dpp[19][19][(1<<17)+2],us[19];
int cev;
string s;
queue<pair<int,int>> q;
vector<int> v[li];

inline int f(int bir,int son,int mask){
	//~ cout<<mask<
	//~ cout<<bir<<" :: "<<son<<endl;
	int cevv=inf;
	if(mask==(1<<k)-1){
		//~ if(k>2)return dp[a[bir]][a[son]];
		return 0;
	}
	if(~dpp[bir][son][mask])return dpp[bir][son][mask];
	for(int i=0;i<k;i++){
		if((mask&(1<<i)))continue;
		if(mask==0){
			cevv=min(cevv,f(i,i,mask|us[i]));
		}
		else{
			if(dp[son][a[i]]!=inf)
			cevv=min(cevv,f(bir,i,mask|us[i])+dp[son][a[i]]);
		}
	}
	return dpp[bir][son][mask]=cevv;
}

int32_t main(void){
	memset(dpp,-1,sizeof(dpp));
	scanf("%lld %lld",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%lld %lld",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	scanf("%lld",&k);
	for(int i=0;i<k;i++){
		scanf("%lld",&a[i]);
		for(int j=1;j<=n;j++){
			vis[j]=0;
			dp[i][j]=inf;
		}
		q.push({a[i],0});
		while(q.size()){
			int co=q.front().se;
			int node=q.front().fi;
			q.pop();
			if(vis[node])continue;
			vis[node]=1;
			dp[i][node]=co;
			for(auto go:v[node]){
				q.push({go,co+1});
			}
		}
	}
	for(int i=0;i<k;i++)us[i]=(1<<i);
	cev=f(0,0,0)+1;
	if(cev>inf)cev=-1;
	printf("%lld\n",cev);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#define miu 100007
using namespace std;
template<class T>inline T mmin(T x, T y) {
    return x > y ? y : x;
}
int n;
vector<long long> G[3];
char buf[7];
int flag[3], tp = 0;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long ans = inf, lm = inf, rm = inf;
signed main() {
    scanf("%d", &n);
    for(int i = 1; i <= 2 * n; ++i) {
        long long tmp;
        scanf("%lld", &tmp);
        scanf("%s", buf + 1);
        if(buf[1] == 'R')G[0].push_back(tmp);
        if(buf[1] == 'G')G[1].push_back(tmp);
        if(buf[1] == 'B')G[2].push_back(tmp);
    }
    for(int i = 0; i < 3; ++i) {
        if(G[i].size() % 2 == 1) {flag[tp] = i; ++tp;}
    }
    if(tp == 0)return printf("0\n"), 0;
    for(int i = 0; i < 3; ++i) if(G[i].size() % 2 == 0) {flag[tp] = i; ++tp;}
    sort(G[flag[0]].begin(), G[flag[0]].end());
    sort(G[flag[2]].begin(), G[flag[2]].end());
    //printf("%d\n", G[flag[0]].size());
    //for(vector<long long> :: iterator it = G[flag[0]].begin(); it != G[flag[0]].end(); ++it);
    for(vector<long long> :: iterator it = G[flag[1]].begin(); it != G[flag[1]].end(); ++it) {
        vector<long long> :: iterator r = lower_bound(G[flag[0]].begin(), G[flag[0]].end(), *it);
        //printf("%lld %lld %d %d\n", *r, *it, r - G[flag[0]].begin(), it - G[flag[1]].begin());
        if(r != G[flag[0]].end())ans = mmin(ans, (*r) - (*it));
        if(r != G[flag[0]].begin())ans = mmin(ans, (*it) - (*(r - 1)));
    }
    for(vector<long long> :: iterator it = G[flag[1]].begin(); it != G[flag[1]].end(); ++it) {
        vector<long long> :: iterator r = lower_bound(G[flag[2]].begin(), G[flag[2]].end(), *it);
        //printf("%lld %lld %d %d\n", *r, *it, r - G[flag[0]].begin(), it - G[flag[1]].begin());
        if(r != G[flag[2]].end())rm = mmin(rm, (*r) - (*it));
        if(r != G[flag[2]].begin())rm = mmin(rm, (*it) - (*(r - 1)));
    }
    for(vector<long long> :: iterator it = G[flag[0]].begin(); it != G[flag[0]].end(); ++it) {
        vector<long long> :: iterator r = lower_bound(G[flag[2]].begin(), G[flag[2]].end(), *it);
        //printf("%lld %lld %d %d\n", *r, *it, r - G[flag[0]].begin(), it - G[flag[1]].begin());
        if(r != G[flag[2]].end())lm = mmin(lm, (*r) - (*it));
        if(r != G[flag[2]].begin())lm = mmin(lm, (*it) - (*(r - 1)));
    }
    printf("%lld\n", mmin(ans, lm + rm));
    return 0;
}

//{{{
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VLL = vector<LL>;
using vi = vector<int>;
using pii = pair<int, int>;
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

const int N = 2e5 + 10;
int head[N], e;
struct E
{
    int v, next;
} edge[N << 1];

void addedge(int u, int v)
{
    edge[e].v = v, edge[e].next = head[u];
    head[u] = e++;
}

// clang-format off
const int NV = 2e5 + 10;
const LL inf = 0x3f3f3f3f3f3f3f3fll;
LL dis[NV];
bool vis[NV];
queue<int> q;

void bfs(int st) {
    clr(dis, 0x3f), clr(vis, false);
    dis[st] = 0;
    while (!q.empty()) q.pop();
    q.push(st);

    while (!q.empty()) {
        int u = q.front();
        q.pop();

        if (vis[u]) continue;
        vis[u] = true;
        for (int i = head[u]; ~i; i = edge[i].next) {
            int v = edge[i].v;
            if(dis[v] > dis[u] + 1)
            {
                dis[v] = dis[u] + 1;
                q.push(v);
            }
        }
    }
}  // clang-format on

int n, m;
int k;
int c[22];

LL g[22][22];
LL dp[1 << 17][18];

LL dfs(int st, int cur)
{
    assert((1 << cur) & st);
    if (dp[st][cur] != -1) return dp[st][cur];

    LL ret = inf;
    for (int p = 0; p < k; p++)
    {
        if (p == cur) continue;
        if (((1 << p) & st) == 0) continue;
        if (g[p][cur] == inf) continue;

        assert((1 << p) & st);
        int pre_st = st ^ (1 << cur);

        LL predis = dfs(pre_st, p);
        if (predis == inf) continue;
        LL val = predis + g[p][cur];
        ret = min(ret, val);
    }
    return dp[st][cur] = ret;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    while (cin >> n >> m)
    {
        clr(head, -1), e = 0;
        for (int i = 1; i <= m; ++i)
        {
            int u, v;
            cin >> u >> v;
            addedge(u, v);
            addedge(v, u);
        }

        cin >> k;
        assert(k >= 1);
        assert(k <= 17);
        for (int i = 0; i < k; i++) cin >> c[i];

        clr(g, 0x3f);
        for (int i = 0; i < k; i++)
        {
            int st = c[i];
            bfs(st);

            for (int j = 0; j < k; j++)
            {
                int ed = c[j];
                g[i][j] = dis[ed];
            }
        }

        // for (int i = 0; i < k; i++)
        //{
        // for (int j = 0; j < k; j++)
        //{
        // debug(i, j, g[i][j]);
        //}
        //}

        clr(dp, -1);
        for (int i = 0; i < k; i++) dp[1 << i][i] = 1;

        LL ans = inf;
        int lim = 1 << k;

        for (int i = 0; i < k; i++)
        {
            LL v = dfs(lim - 1, i);
            ans = min(ans, v);
        }

        if (ans >= inf) ans = -1;
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	ll aa=0,cc=0,bb=0;
    cout<<setprecision(20);
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    a[i]=abs(a[i]);
	    aa+=a[i];
	    cc=max(a[i],cc);
	    bb+=(a[i]*a[i]);
	}
	//bb=sqrt(bb);
	cout<<aa<<endl;
    cout<<sqrt(bb)<<endl;
	//cout<<bb<<endl;
	cout<<cc<<endl;
	return 0;
}

#include <bits/stdc++.h>
#include <numeric>
using namespace std ;
#define ll long long int
#define ull unsigned long long int
#define s(a) scanf("%lld",&a)
#define S(a) scanf("%ull",&a)
#define For(i,n) for(i=0;i<n;i++)
#define FOR(i,n) for(i=1;i<=n;i++)
#define pie acos(-1.0)
//#define cin std::cin
//#define cout std::cout
ll test, flag,R ,gcd_,temp,temp1,G,B,a,b, n,i,p,q,sum,S,l,r, m,Y,z,XD,j,j_1,k,k1,res ,min_ ,flag1,max_,XD1,count_,s_size ;
char ch ,ch_1 ;
string s,s3;
//char s[100010] ;
char c2[520][520];
ll pl,x,y,mi,c,d, u,v ,ans,ans1;
char garbage,garbage1 ;
struct vox{
   ll a;
   ll index ;
   ll b ;
} ;
bool comp(vox x, vox y) {
   return x.a < y.a ;
}
bool com(vox x, vox y) {
   return x.index < y.index ;
}
ll lcm(ull a, ull b)
{
    return (a / __gcd(a, b)) * b;
}
int main()
{
          //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

            cin >> n ;
            ll arr[100100] ;
            sum = 0 ;
            double answer = 0 ;
            max_ = 0 ;
            for(i=0; i<n;i++) {cin >> arr[i] ;
              sum +=abs(arr[i]) ;
              answer = answer + (double) pow(abs(arr[i]),2);
              if(abs(arr[i])>max_) max_ = abs(arr[i]) ;
            }
            sort(arr,arr+n) ;
            //max_ = arr[n-1] ;
            printf("%lld\n",sum);

            printf("%.15lf\n", sqrt(answer));
            printf("%lld\n",max_);

            return 0;
           }


#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cctype>
#include <cmath>
#include<deque>
#include<map>
#include<algorithm>
#include<iomanip>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,begin,end) for(int i = begin; i < end; i++)
#define all(c) c.begin(), c.end()
#define ll long long
#define INF 2e9
#define INFLL 9223372036854775807
#define cout(n) cout << fixed << setprecision(n)
#define pii pair<int,int>
#define pll pair<long long,long long>

template<typename T>pair<T, T> max_idx(vector<T>& a) { T ans = 0; T index = 0; for (int i = 0; i < a.size(); i++) { if (a[i] > ans) { ans = a[i]; index = i; } }pair<T, T> ret = { ans,index }; return ret; }
template<typename T>pair<T, T> min_idx(vector<T>& a) { T ans = INF; T index = 0; for (int i = 0; i < a.size(); i++) { if (a[i] < ans) { ans = a[i]; index = i; } }pair<T, T> ret = { ans, index }; return ret; }
long long Factorial(int n) { ll sum = 1; for (int i = n; i > 0; i--) { sum *= i; }return sum; }

int main() {
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<int> t(q), a(q), b(q);
	rep(i, q)cin >> t[i] >> a[i] >> b[i];
	rep(i, q) {
		--a[i];
		--b[i];
	}
	bool inv = false;
	int half = n;
	rep(i, q) {
		if (t[i] == 1 && inv) {
			if (a[i] < half && b[i] >= half) {
				swap(s[half + a[i]], s[b[i] - half]);
			}
			else if (a[i] < half && b[i] < half) {
				swap(s[half + a[i]], s[half + b[i]]);
			}
			else if (a[i] >= half && b[i] >= half) {
				swap(s[a[i] - half], s[b[i] - half]);
			}
		}
		else if (t[i] == 1 && !inv) {
			swap(s[a[i]], s[b[i]]);
		}
		else {
			inv = !inv;
		}
	}
	if (inv) {
		string news = s.substr(0, half);
		s.erase(s.begin(), s.begin()+half);
		s += news;
	}
	cout << s << endl;
}

// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    int v, t, s, d;

    cin >> v >> t >> s >> d;

    cout << (v*t <= d && d <= v*s ? "No" : "Yes") << endl;
}


//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    Forn(i,n) for(int i=1;i<=n;i++)
#define    Fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    mod    1e9+7 //1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    YES    printf("YES\n")
#define    NO     printf("NO\n")
#define    Erase(s) s.erase(unique(s.begin(),s.end()),s.end())
//%%%%%%%%%%%%%p%%%a%%%r%%%v%%%e%%%z%%%%%%%%%%%%%//

int main()
{
MP;
    //int T;cin>>T;while(T--)
    {
        int a[4];
        For(i,4) cin >> a[i];
        cout << Min(a);
    }
    cerr<<endl<<(float)clock()/(float)CLOCKS_PER_SEC<<" sec"<<endl;
End;
}

#include<bits/stdc++.h>
#define MAX 2000
#define MOD 998244353
using namespace std;
vector<int> v[MAX+10];
bool visited[MAX+10];
int ans = 0;
void dfs(int x)
{
	visited[x] = true;
	++ans;
	for(int y:v[x])
	{
		if(visited[y])
			continue;
		dfs(y);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
			visited[j] = false;
		dfs(i);
	}
	cout<<ans<<endl;
	return 0;
}


//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);i++)
#define per(i, n) for(int i=(n);i>0;i--)
#define repx(i, n, x) for(int i=(x);i<(n);i++)
#define xper(i, n, x) for(int i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;

int main(){
	int n, x;
	char buf;
	cin >>  n >> x;

	rep(i, n){
		cin >> buf;
		if(buf =='o')++x;
		else if(x <=0);
		else --x;
	}
	cout <<  x << endl;
}

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

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

    int ans = X;
    for(int i=0;i<N;i++){
        if(S[i] == 'o') ans++;
        else{
            if(ans != 0) ans--;
        }
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<ll> type(2*N+1, 0);
    // type.at(i)の値が-1ならi階が始点であること、0なら未確定であること、1なら終点であることを表す
    vector<vector<ll>> p(2*N+1, vector<ll>(2*N+1, 0));
    // p.at(i).at(j)の値が-1ならi階からj階への移動が不可能であること、
    // 0なら可能であること、1なら確定していることを表す
    set<ll> source; // 終点が不明な始点の集合
    set<ll> target; // 始点が不明な終点の集合
    rep(i, N){
        cin >> A.at(i) >> B.at(i);
        if(A.at(i) != -1){
            if(type.at(A.at(i)) != 0){
                cout << "No" << endl;
                return 0;
            }
            type.at(A.at(i)) = -1;
        }
        if(B.at(i) != -1){
            if(type.at(B.at(i)) != 0){
                cout << "No" << endl;
                return 0;
            }
            type.at(B.at(i)) = 1;
        }
        if(A.at(i) != -1 && B.at(i) != -1 && A.at(i) >= B.at(i)){
            cout << "No" << endl;
            return 0;
        }
        if(A.at(i) != -1 && B.at(i) != -1){
            p.at(A.at(i)).at(B.at(i)) = 1;
        }
        if(A.at(i) != -1 && B.at(i) == -1){
            source.insert(A.at(i));
        }
        if(A.at(i) == -1 && B.at(i) != -1){
            target.insert(B.at(i));
        }
    }
    rep2(i, 1, 2*N+1){
        rep2(j, 1, i+1){
            p.at(i).at(j) = -1;
        }
    }
    for(auto i : source){
        for(auto j : target){
            p.at(i).at(j) = -1;
        }
    }
    rep(i, 2*N+1){
        if(type.at(i) == -1){
            rep(j, 2*N+1){
                p.at(j).at(i) = -1;
            }
        }
        if(type.at(i) == 1){
            rep(j, 2*N+1){
                p.at(i).at(j) == -1;
            }
        }
    }
    rep(i, N){
        if(A.at(i) != -1 && B.at(i) != -1){
            rep(k, 2*N+1){
                if(k == B.at(i)){
                    continue;
                }
                p.at(A.at(i)).at(k) = -1;
            }
            rep(k, 2*N+1){
                if(k == A.at(i)){
                    continue;
                }
                p.at(k).at(B.at(i)) = -1;
            }
        }
    }
    vector<bool> dp(N+1, false);
    // dp.at(i)は最後に区切ったのが2*i階であるということが可能かどうかを表す
    dp.at(0) = true;
    bool failure = false;
    rep(i, N){
        rep(j, i+1){
            if(!dp.at(j)){
                continue;
            }
            // i+1-j階分移動することは可能か
            rep(k, i+1-j){
                if(p.at(2*j+1+k).at(j+2+i+k) == -1){
                    failure = true;
                    break;
                }
            }
            if(failure){
                failure = false;
                continue;
            }
            dp.at(i+1) = true;
            break;
        }
    }
    if(dp.at(N)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


    /* Great things never come from comfort zones,
    "whatever the mind of a man can conceive and believe,it can achieve." */

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

    void my_dbg() { cout << endl; }
    template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
    { cout << ' ' << A; my_dbg(B...); }
    #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    #define ll long long
    #define dd double
    #define scf(n) scanf("%d",&n)
    #define lscf(n) scanf("%lld",&n)
    #define lpri(n) printf("%lld ",n)
    #define pri(n) printf("%d ",(int)n)
    #define prin(n) printf("%d\n",(int)n)
    #define lprin(n) printf("%lld\n",n)
    #define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
    #define show(a) for(auto xy: a) pri(xy); printf("\n");

    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define all(x)     x.begin(),x.end()
    #define SET(a,b) memset(a,b,sizeof(a))
    #define tc   int tt; scf(tt); while(tt--)

    #define inf INT_MAX
    #define ninf INT_MIN
    #define gcd __gcd
    #define bitcount(n) __builtin_popcount(n)

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

    int pos[N];

    int main()
    {
        int n; scf(n);

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

        vector<int>ind(n);

        iota(all(ind),0);// iterates and fill with increaing values
                        //0 1 2 3 4.......

        ll A=0,B=0,tmp;

        rep(i,0,n)
        lscf(a[i]),lscf(b[i]);

        sort(all(ind),[&](const int &i , const int &j)
        {
            return (2*a[i]+b[i]>2*a[j]+b[j]);
        }); // net effect 2*a[k] + b[k] in town of speech

        A=accumulate(all(a),0ll);

        int c=0,d=0;

        rep(i,0,n)
        {
            if(B>A)
            break;

            c++;

            int j=ind[i];

            B+=b[j]+a[j];

            A-=a[j];
        }

        prin(c);

    }

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

int main() {

  //Nの入力
  long N=0;
  cin >> N;

  //町の青木派と高橋派を入力
  int64_t A[N],B[N],Total[N];
  int64_t sum_A = 0;
  int64_t sum_B = 0;

  //それぞれの派の合計
  for(long i=0; i<N; ++i){
    cin >> A[i] >> B[i];
    Total[i] = 2*A[i] + B[i];
    sum_A += A[i];
    sum_B += B[i];
  }

  //cout << "sum_A:" << sum_A << endl;
  //cout << "sum_B:" << sum_B << endl;

  long count = 0;

  std::sort(Total, Total+N, std::greater<>());
  //for(long i=0; i<N; ++i) cout << Total[i] << endl;

  long temp_sum = 0;
  for(long i=0; i<N; ++i){
    //cout << A[i] << endl;
    temp_sum += Total[i];
    count++;
    if(sum_A < temp_sum)break;
  }

  cout << count << endl;

}


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

using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef
tree<
  pair<int,int>,
  null_type,
  less<pair<int,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,q;
    cin>>n>>q;
    ordered_set s;
    rep(i,0,n){
        int x; cin>>x;
        s.insert({x,i});
    }
    rep(i,0,q){
        int k;
        cin>>k;
        int L=1,U=2e18+5,ans;
        while(L<=U){
            int m=(L+U)/2;
            int cnt=s.order_of_key({m+1,-1});
            if(m-cnt>=k){
                ans=m;
                U=m-1;
            }else L=m+1;
        }
        cout<< ans << endl;
    }
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);
ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*b/gcd(a,b);}

int main() {
    int H,W; cin >> H >> W;
    vector<string> S(H); REP(i,H) cin >> S[i];
    int ans = 0;
    REP(i,H) REP(j,W) {
        if(i+1 >= H || j+1 >= W) continue;
        int cnt = 0;
        REP(k,2) REP(l,2) {
            if(S[i+k][j+l] == '.') cnt++;
        }
        if(cnt%2 != 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i >-1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

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

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x =(x%p+p)%p;
	}
	ll ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

void solve()
{
	ll t,n;
	cin>>t>>n;
	ll x=(n*100+t-1)/t;
	ll ans=x+(t*x)/100-1;
	cout<<ans;
}

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

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

int main(int argc, char** argv)
{
	unsigned long long int n,res,it, last,price;
	long double nr,t;
	res = 0;
	nr = 1;
	it=0;
	last = 0;
	cin>>t>>n;
	price = ceil((100/t)*n)+(n-1);
	cout<<price<<endl;
	return 0;
}


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

int main(){
    string s; cin >> s;
    bitset<18> bb;
    bool flag = false;
    int ans = 0,cntmin=20;
    for(int ix=0;ix<(1<<(int)s.size());ix++){
        bb = ix;
        int tmp=0,cnt=0;
        for(int jx=0;jx<s.size();jx++){
            if(bb.test(jx)) tmp += (s.at(jx)-'0');
            else cnt++;
        }
        if(tmp%3 == 0 && tmp > 0 && cnt < cntmin){
            flag = true;
            ans = cnt;
            cntmin = cnt;
        }
    }
    if(flag == true) cout << ans << endl;
    else cout << "-1" << endl;
}

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

using ll_t = long long;

using digits_t = vector<int>;

digits_t get_digits(int n) {
  digits_t digits;

  while(n) {
    auto d = n%10;
    digits.push_back(d);
    n /= 10;
  }
  reverse(digits.begin(), digits.end());
  return digits;
}

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

  if(n%3 == 0) {
    cout << 0 << "\n";
  } else {
    digits_t digits = get_digits(n);
    for(int i = 1; i <= digits.size(); ++i) {
      vector<int> num(digits.size(), 0);
      for(int j = 1; j <= i; ++j) {
        num[j-1] = 1;
      }

      sort(num.begin(), num.end());
      do {
        int tmp = n;
        int sum = 0;
        for(int k = num.size(), p = 1; k >= 1; --k, ++p) {
          if(num[k-1] == 1) {
            sum += digits[k-1]*pow(10, p-1);
            //cout << "digit: " << digits[k-1] << "\n";
          }
        }
        //cout << "n: " << tmp << " sum: " << sum << "\n";

        if(tmp-sum == 0) {
          cout << -1 << "\n";
          return 0;
        }
        if((tmp-sum)%3 == 0) {
          cout << i << "\n";
          return 0;
        }
      } while(next_permutation(num.begin(), num.end()));
    }

    cout << -1 << "\n";
  }
  return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define DB double
#define U unsigned
#define P std::pair
#define LL long long
#define LD long double
#define pb emplace_back
#define MP std::make_pair
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

int main(){
    int T;scanf("%d",&T);
    while(T--){
        LL n;scanf("%lld",&n);
        int e = 0;while(!(n&1)) ++e,n >>= 1;
        if(e == 0){
            puts("Odd");
        }
        else if(e == 1){
            puts("Same");
        }
        else puts("Even");
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pii pair<long long, long long>
#define FOR(x, j) for(int x = 0; x < j; x++)
using ll = long long;

const int LEAF = 18;
int tree[2*LEAF];

const int maxN = 2e5+10;
//const ll INF = 1000LL*1000LL*1000LL*1000LL*1000LL*10LL;
const int INF = 2e9;

ll DP[maxN];
ll A[maxN], B[maxN];

void solve(){
    int n; cin >> n;
    FOR(i, n)
        cin >> A[i];
    FOR(i, n)
        cin >> B[i];
    DP[0] = A[0]*B[0];
    ll maxA = A[0];
    for(int i = 1; i < n; i++){
        maxA = max(maxA, A[i]);
        DP[i] = max(DP[i-1], maxA*B[i]);
    }
    FOR(i, n)
        cout << DP[i] << "\n";
}

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

    bool multitest = false;
    //multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
#define E (n+m)
using namespace std; const int N=500010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,m,a[N];
int c[N];
inline int lowbit(int x) { return x&(-x); }
inline void Add(int x,int p)
{
	for(;x<=n;x+=lowbit(x)) c[x]^=p;
}
inline int Ask(int x)
{
	int tt=0;
	for(;x;x-=lowbit(x)) tt^=c[x];
	return tt;
}
signed main()
{
	n=read(), m=read();
	for(ri int i=1;i<=n;i++) a[i]=read(), Add(i,a[i]);
	for(ri int i=1;i<=m;i++)
	{
		int opt,x,y;
		opt=read(), x=read(), y=read();
		if(opt==1)
		{
			Add(x,y);
		}
		else
		{
			printf("%lld\n",Ask(x-1)^Ask(y));
		}
	}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, p; cin >> n >> p;
  cout << modpow(p-2, n-1) * (p-1) % mod << endk;
  return 0;
}


//#include <atcoder/maxflow.hpp>
#include <memory>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <thread>

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

typedef long long ll;

using namespace std;
//using namespace atcoder;

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

int main()   {

    ios_base::sync_with_stdio(false);

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

    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<ll> a;
        forr(i,0,n) {
            readint(aa); a.push_back(aa);
        }
        sort(a.begin(), a.end());
        vector<ll> part_sum; part_sum.push_back(0);
        forr(i,0,n) {
            part_sum.push_back(a[i] + part_sum.back());
        }

        ll sum = 0;
        forr(i,0,n) {
            sum += i*a[i] - part_sum[i];
            sum += part_sum.back() - part_sum[i] - (n-i)*a[i];
        }
        cout << sum/2 << endl;
    }
//        auto stop = chrono::steady_clock::now();
//        auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
//        cout << "Duration: " << duration.count() << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, x, mx; ll s, t;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        s += x, t += s;
        mx = max(mx, x);
        cout << t + 1ll * i * mx << "\n";
    }
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    solve();
    return 0;
}


#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define lsc(a) scanf("%lld",&a)
#define lscc(a,b) scanf("%lld %lld",&a,&b)
#define lsccc(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)

using namespace std;

int main(){
	//fri("gir.txt");
	//fro("cik.txt");
	long long n;
	lsc(n);
	long long n2=2*n;
	long long bas=0;
	while(n%2==0){
		n/=2;
	}
	long long kok=(long long)sqrt(n);
	for(long long i=1;i<=kok;i+=2){
		if(n%i==0){
			bas+=2;
			if(n/i==kok){
				bas--;
			}
		}
	}
	cout<<2*bas<<endl;

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin >> N;
    N *= 2;
    long long count = 0;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            long long j = N / i;
            if (i % 2 != j % 2) {
                count += 2;
            }
        }
    }
    cout << count << '\n';
    return 0;
}