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

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) cin >> s[i];
  vector<vector<int>> L(n, vector<int>(m));
  vector<vector<int>> R(n, vector<int>(m));
  vector<vector<int>> U(n, vector<int>(m));
  vector<vector<int>> D(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') continue;
      L[i][j] = j - 1 >= 0 ? L[i][j - 1] + 1 : 1;
    }
    for (int j = m - 1; j >= 0; --j) {
      if (s[i][j] == '#') continue;
      R[i][j] = j + 1 < m ? R[i][j + 1] + 1 : 1;
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int i = 0; i < n; ++i) {
      if (s[i][j] == '#') continue;
      U[i][j] = i - 1 >= 0 ? U[i - 1][j] + 1 : 1;
    }
    for (int i = n - 1; i >= 0; --i) {
      if (s[i][j] == '#') continue;
      D[i][j] = i + 1 < n ? D[i + 1][j] + 1 : 1;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) sum += s[i][j] == '.';
  }
  vector<int> p2(n * m + 1);
  p2[0] = 1;
  for (int i = 1; i <= n * m; ++i) p2[i] = p2[i - 1] * 2LL % MOD;
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') continue;
      int cnt = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
      trace(i, j, sum, cnt);
      int cur = p2[sum] - p2[sum - cnt];
      if (cur < 0) cur += MOD;
      add(ret, cur);
    }
  }
  cout << ret << '\n';
  return 0;
}

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>

#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}

template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}

using ll=long long;

class mod_ll
{
public:
	ll m_v;
	static const ll m_m=1000000007; // prime value ex. 1000000009
	mod_ll(ll v=0) : m_v(v%m_m) {}
	mod_ll& operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	ll operator ()(){return (m_v+m_m)%m_m;}
	mod_ll& operator += (const mod_ll rhs)
	{
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	const mod_ll operator + (const mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll& operator -= (const mod_ll rhs)
	{
		m_v=(m_v-rhs.m_v+m_m)%m_m;
		return *this;
	}
	const mod_ll operator - (const mod_ll rhs)
	{
		auto ret=*this;
		return ret-=rhs;
	}
	mod_ll& operator *= (const mod_ll rhs)
	{
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	const mod_ll operator * (const mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	const mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll& operator /= (mod_ll rhs)
	{
		mod_ll t=rhs^(m_m-2);
		return *this*=t;
	}
	const mod_ll operator / (const mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};

mod_ll mod_fact(int n)
{
	static vector<mod_ll> memo(1);

	if((int)memo.size()<=n)
	{
		if(memo.size()==1)
		{
			memo[0]=1;
		}
		for(int i=memo.size();i<=n;i++)
		{
			memo.push_back(memo.back()*i);
		}
	}
	return memo[n];
}

mod_ll mod_nCr(int n, int r)
{
	if(n<=0) return 1;
	return mod_fact(n)/(mod_fact(n-r)*mod_fact(r));
}

mod_ll mod_nCr2(int n, int r)
{
	mod_ll bunsi(1);
	mod_ll bunbo(1);
	if(r*2>n) r=n-r;

	for(int i=0;i<r;i++)
	{
		bunsi*=(n-i);
		bunbo*=(i+1);
	}
	return bunsi/bunbo;
}

mod_ll mod_nPr(int n, int r)
{
	return mod_fact(n)/mod_fact(n-r);
}

struct solve
{
	solve(){}
	ll operator()(vector<string>&s) {
		int h=s.size();
		int w=s[0].length();
		vvi cx(h), cy(h);

		for(auto&m:cx) m.assign(w, -1);
		for(auto&m:cy) m.assign(w, -1);

		int n=0;
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				if(s[y][x]!='.') continue;
				cx[y][x]=(x>0)?max(cx[y][x-1]+1, 1):1;
				cy[y][x]=(y>0)?max(cy[y-1][x]+1, 1):1;
				n++;
			}
		}

		vector<mod_ll> beki2(n+1);
		beki2[0]=1;
		for(int i=1;i<=n;i++) beki2[i]=beki2[i-1]*2;

		for(int y=h-1;y>=0;y--)
		{
			int v=cx[y][w-1];
			for(int x=w-1;x>=0;x--)
			{
				max_u(v, cx[y][x]);
				if(cx[y][x]>0) cx[y][x]=v;
				else v=-1;
			}
		}

		for(int x=w-1;x>=0;x--)
		{
			int v=-1;
			for(int y=h-1;y>=0;y--)
			{
				max_u(v, cy[y][x]);
				if(cy[y][x]>0) cy[y][x]=v;
				else v=-1;
			}
		}

		mod_ll t=0;
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				int v=cx[y][x]+cy[y][x]-1;
				if(v>0) t+=beki2[n-v];
			}
		}

		mod_ll ans=(beki2[n]*n);
		ans-=t;
/*
		cout << beki2[n]() << "\n";
		cout << t() << "\n";
*/
		return ans();
	}
};

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

	for(;;)
	{
		int h, w;
		cin >> h >> w;
		if(cin.fail()) break;
		vector<string> s(h);
		for(auto&m:s) cin >> m;

		cout << solve()(s) << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const int MAX = 100010;
ll A[110];

int main() {
    ll R, X, Y;
    cin >> R >> X >> Y;

    ll ans = 0;

    double dis = sqrt(X * X + Y * Y);

    if(dis < R){
        ans = 2;
    }
    else{
        while(dis > 0){
            dis -= R;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (int)(a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using VD = vector<double>;
using VII = vector<VI>;
using VLL = vector<VL>;
using VDD = vector<VD>;
using P = pair<int, int>;
using PL = pair<ll, ll>;

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;
}

void solve(long long R, long long X, long long Y) {
  ll N = 1;
  ll dis = X * X + Y * Y;
  if(dis < R * R) {
    cout << 2 << endl;
    return;
  }
  while(true) {
    ll tmp = R * R * N * N;
    if(dis <= tmp) {
      break;
    }
    N += 1;
  }
  cout << N << endl;
}

int main() {
  long long R;
  scanf("%lld", &R);
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  solve(R, X, Y);
  return 0;
}


#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using str = string;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<str>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vpi = vector<pair<int,int>>;
#define rsz resize
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) begin(x),end(x)
#define sor(x) sort(begin(x),end(x));
#define FOR(i,a,b) for(ll i=a; i<(ll)b; ++i)
#define ROF(i,a,b) for(ll i=a-1; i>=b; --i)
#define TRAV(a, x) for(auto& a:x)
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define u_map unordered_map
#define u_set unordered_set
#define u_multiset unordered_multiset
void setPrec() { cout << fixed << setprecision(15); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void setIO(str s = "") {
    unsyncIO(); setPrec();
    if(sz(s)) setIn(s+".in"), setOut(s+".out");
}

int main() {
	setIO();
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll cyan = a, red = 0;
	FOR(i,1,a+1) {  // no more than A
		// A+Bx <= D * Cx --> x = A/(CD-B) -> no more than a
		cyan += b;
		red += c;
		if(cyan <= d*red) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

template<typename T>
vector<T> dijkstra(int s,vector<vector<pair<int,T>>> &G){
    const T TINF=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n=G.size();
    vector<T> d(n,TINF);
    vector<int> b(n,-1);//previous point
    priority_queue<P,vector<P>,greater<P>> q;
    d[s]=0;
    q.emplace(d[s],s);
    while(!q.empty()){
        P p=q.top();q.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.first;
            T c=e.second;
            if(d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                q.emplace(d[u],u);
            }
        }
    }
    return d;
}

template<typename T>
struct edge{
    int src,to;//src source
    T cost;
    edge(int to,T cost):src(-1),to(to),cost(cost){}
    edge(int src,int to,T cost):src(src),to(to),cost(cost){}
};

//空を返したら負のループ
template<typename T>
vector<T> BellmanFord(vector<edge<T>> &edges,int V,int s){
    const auto TINF=numeric_limits<T>::max();
    vector<T> dist(V,TINF);
    dist[s]=0;
    for(int i=0;i<V-1;i++){
        for(auto &e:edges){
            if(dist[e.src]==TINF) continue;
            dist[e.to]=min(dist[e.to],dist[e.src]+e.cost);
        }
    }
    for(auto &e:edges){
        if(dist[e.src]==TINF) continue;
        if(dist[e.src]+e.cost<dist[e.to]) return vector<T>();
    }
    return dist;
}

signed main(){
    int n,m;cin>>n>>m;
    vector<ll> w(n);
    cin>>w;
    vector<pair<ll,ll>> b(m);
    rep(i,m){
        ll l,v;cin>>l>>v;
        b[i]={v,l};// weight, length
        for(auto &a:w){
            if(a>v){
                cout<<-1<<endl;
                return 0;
            }
        }
    }

    sort(ALL(b),[](pair<ll,ll> lhs,pair<ll,ll> rhs){
        if(lhs.first==rhs.first) return lhs.second>rhs.second;
        return lhs.first<rhs.first;
    });
    vector<pair<ll,ll>> bridge;
    rep(i,m){
        if(bridge.empty() or bridge.back().second<b[i].second) bridge.push_back(b[i]);
    }

    ll res=LINF;
    vector<int> ord(n);
    iota(ALL(ord),0);
    do{
        vector<vector<pair<int,ll>>> g(n);
        rep(i,n){
            int u=ord[i];
            ll wsum=w[u];
            for(int j=i+1;j<n;j++){
                int v=ord[j];
                wsum+=w[v];
                auto ite=lower_bound(ALL(bridge),make_pair(wsum,-LINF));
                ll cost=(ite==bridge.begin()?0ll:prev(ite)->second);
                g[i].push_back({j,cost});
            }
        }
        vector<ll> d(n,0);
        d[0]=0;
        rep(i,n){
            for(auto [to,c]:g[i]){
                chmax(d[to],d[i]+c);
            }
        }
        chmin(res,d[n-1]);
    }while(next_permutation(ALL(ord)));
    cout<<res<<endl;
    return 0;
}


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

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma comment(linker, "/stack:200000000")

using namespace std;
using namespace __gnu_pbds;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define F first
#define S second
#define gcd __gcd
#define lcm(a, b) (ull(a) / gcd(a, b) * b)
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define mkp make_pair
#define mkt make_tuple
#define mem(x) memset(x, 0, sizeof(x))
#define deci(x) fixed << setprecision(x)
#define zero(x) setw(x) << setfill('0')
#define EACH(v, u) for(auto& v : u)
#define lowbit(x) (x & -x)
#define dbg(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef uint32_t uint;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
#define vt vector
#define Q queue
#define pq priority_queue
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define ar array
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vt<T>, greater<T>>;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U> ostream& operator<<(ostream& os, pair<T, U> p) { return os << p.F << " " << p.S; }
template<class T> ostream& operator<<(ostream& os, vt<T> v) { EACH(u, v) os << u << " "; return os; }

template<class T> void read(T& x) { cin >> x; }
template<class T, class... U> void read(T& a, U&... b) { read(a), read(b...); }
template<class T> void write(T x) { cout << x;}
template<class T, class... U> void write(T a, U... b) { write(a), write(" "), write(b...), write("\n"); }

string operator*(string a, int x) { string ret = a; for(int i = 1; i < x; ++i) ret += a; return ret; }
string& operator*=(string& a, int x) { return a = a * x; }

ull fpm(ull a, ull b, ull m) { ull ret = 1;	while(b) { if(b & 1) ret = ret * ret % m; a = a * a % m; b >>= 1; } return ret; }

const int INF(1e9);
const ll LINF(1e17);
const ld pi(3.141592653589793238);

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, d8j[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
	fastio;
	int a, b, c;
	cin >> a >> b;
	if(a == b)
		cout << a << "\n";
	else {
		c = 0 ^ 1 ^ 2 ^ a ^ b;
		cout << c << "\n";
	}

	return 0;
}

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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

ll mono[3001][3001];
ll total[3001][3001];
const ll p = 998244353LL;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	total[0][0]=1LL;
	mono[0][0]=1LL; // really??

	int n,k;
	cin>>k>>n;

	for(int length = 1; length <= k; length++)
	{
		for(int value = 3000; value >= 1; value--)
		{
			mono[length][value] = total[length-1][value-1];

			int val2 = value;

			while(val2 <= 3000)
			{
				total[length][value] += mono[length][val2];
				total[length][value] %= p;

				val2*=2;
			}

			//if(total[length][value]) cout << length << " " << value << " " << total[length][value] << " " << mono[length][value] << endl;
		}
	}

	cout << total[k][n] << "\n";
}


/* Simplicity and Goodness */

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

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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 scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 1e6+2;

int main()
{
   int n;
   scn(n);

   vi a(n);

   for(int& it : a)
      scn(it);

   int k = -1, cnt = 0;

   rep(i, 2, 1001) {
      int c = 0;
      rep(j, 0, n) {
         if(a[j] % i == 0)
            c++;
      }
      if(c > cnt) {
         cnt = c;
         k = i;
      }
   }

   prin(k);

   return 0;
}

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=long long>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class T>auto comp_pairs_by_second(){return[](const T&p1,const T&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);};}

int main()
{
    ll n=in();
    map<ll,ll>gcddo;
    for(ll i=0;i<n;++i){
        ll a=in();
        for(ll j=1;j*j<=a;++j){
            if(a%j==0){
                if(j!=1)++gcddo[j];
                if(j*j!=a)++gcddo[a/j];
            }
        }
    }
    ll ans,g=0;
    for(auto gg:gcddo){
        if(gg.second>g){
            g=gg.second;
            ans=gg.first;
        }
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    vector<string> S(3);
    for (auto &s: S)
        cin >> s;

    string C = "";
    for (const auto &s: S)
        C += s;

    sort(C.begin(), C.end());
    C.erase(unique(C.begin(), C.end()), C.end());

    if (C.size() > 10){
        puts("UNSOLVABLE");
        return 0;
    }

    vector<char> A;
    for (int i = 0; i < 10; i++)
        A.push_back('0' + i);

    do {
        vector<string> T = S;
        unordered_map<char, char> f;
        for (int i = 0; i < C.size(); i++)
            f[C[i]] = A[i];

        for (int i = 0; i < 3; i++){
            for (auto &t: T[i])
                t = f[t];
        }

        vector<int64_t> B(3);
        bool flag = true;
        for (int i = 0; i < 3; i++){
            B[i] = stoll(T[i]);
            flag &= T[i] == to_string(B[i]);
            flag &= B[i] > 0;
        }

        if (!flag)
            continue;

        if (B[0] + B[1] == B[2]){
            for (const auto &b: B)
                cout << b << endl;
            return 0;
        }
    } while (next_permutation(A.begin(), A.end()));

    puts("UNSOLVABLE");
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

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

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

bool check(vector<string> &s, map<char,int> &cnv, set<char> &head){

  REP(i,3)if(cnv[s[i][0]] == 0)return false;

  ll s1=0;
  ll s2=0;
  ll s3=0;
  for(auto c: s[0]){
    s1 *= 10;
    s1 += cnv[c];
  }
  for(auto c: s[1]){
    s2 *= 10;
    s2 += cnv[c];
  }
  for(auto c: s[2]){
    s3 *= 10;
    s3 += cnv[c];
  }

  if(s1+s2==s3){
    cout << s1 << " " << s2 << " " << s3 << endl;
    return true;
  }

  return false;
}

int main(){
  vector<string> s(3);
  REP(i,3)cin >> s[i];

  set<char> head;
  head.insert(s[0][0]);
  head.insert(s[1][0]);
  head.insert(s[2][0]);

  map<char,int> mp;
  REP(i,3){
    for(auto c: s[i])mp[c]++;
  }

  if(mp.size() > 10){
    cout << "UNSOLVABLE" << endl;
    return 0;
  }

  vi p(10);
  REP(i,10)p[i]=i;

  do{
    int i=0;
    map<char,int> cnv;
    for(auto v: mp){
      cnv[v.first] = p[i++];
    }
    if(check(s,cnv,head))return 0;

  }while(next_permutation(ALL(p)));

  cout << "UNSOLVABLE" << endl;
}


/*
the vast starry sky,
bright for those who chase the light.
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mk make_pair
const int inf=(int)1e9;
const ll INF=(ll)5e18;
const int MOD=1e9+7;
int _abs(int x){return x<0 ? -x : x;}
int add(int x,int y){x+=y; return x>=MOD ? x-MOD : x;}
int sub(int x,int y){x-=y; return x<0 ? x+MOD : x;}
#define mul(x,y) (ll)(x)*(y)%MOD
void Add(int &x,int y){x+=y; if(x>=MOD) x-=MOD;}
void Sub(int &x,int y){x-=y; if(x<0) x+=MOD;}
void Mul(int &x,int y){x=mul(x,y);}
int qpow(int x,int y){int ret=1; while(y){if(y&1) ret=mul(ret,x); x=mul(x,x); y>>=1;} return ret;}
void checkmin(int &x,int y){if(x>y) x=y;}
void checkmax(int &x,int y){if(x<y) x=y;}
void checkmin(ll &x,ll y){if(x>y) x=y;}
void checkmax(ll &x,ll y){if(x<y) x=y;}
#define out(x) cerr<<#x<<'='<<x<<' '
#define outln(x) cerr<<#x<<'='<<x<<endl
#define sz(x) (int)(x).size()
inline int read(){
    int x=0,f=1; char c=getchar();
    while(c>'9'||c<'0'){if(c=='-') f=-1; c=getchar();}
    while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
const int N=105;
struct matrix{
    int a[N][N],n,m;
    matrix(){memset(a,0,sizeof(a));}
    matrix(int n,int m):n(n),m(m){memset(a,0,sizeof(a));}
    void init(){
        for(int i=1;i<=n;i++) a[i][i]=1;
    }
};
matrix operator * (matrix A,matrix B){
    matrix ret(A.n,B.m);
    for(int i=1;i<=A.n;i++){
        for(int k=1;k<=A.m;k++){
            for(int j=1;j<=B.m;j++)
                Add(ret.a[i][j],mul(A.a[i][k],B.a[k][j]));
        }
    }
    return ret;
}
matrix qpow(matrix A,int y){
    matrix ret(A.n,A.n); ret.init();
    while(y){
        if(y&1) ret=ret*A;
        A=A*A;
        y>>=1;
    }
    return ret;
}

int inv[N*N];
int n,m,k,a[N];
struct Edge{int x,y;}E[N*N];
vector<int> v[N];
matrix ans,trans;
void init(){
    n=read(); m=read(); k=read();
    inv[1]=1; for(int i=2;i<=10000;i++) inv[i]=mul(MOD-MOD/i,inv[MOD%i]);
    ans.n=1; ans.m=n; trans.n=n; trans.m=n;
    for(int i=1;i<=n;i++) ans.a[1][i]=read();
    for(int i=1;i<=n;i++) trans.a[i][i]=1;
    for(int i=1;i<=m;i++){
        int x=read(),y=read();
        Sub(trans.a[x][x],inv[m]);
        Add(trans.a[x][x],mul(inv[m],inv[2]));
        Add(trans.a[y][x],mul(inv[m],inv[2]));
        Sub(trans.a[y][y],inv[m]);
        Add(trans.a[y][y],mul(inv[m],inv[2]));
        Add(trans.a[x][y],mul(inv[m],inv[2]));
    }
}
void solve(){
    trans=qpow(trans,k);
    ans=ans*trans;
    for(int i=1;i<=n;i++) printf("%d\n",ans.a[1][i]);
}

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

#include <bits/stdc++.h>

using namespace std;
using i128 = __int128_t;
using u128 = __uint128_t;
using u64 = uint64_t;

//define
#define int long long
#define ll int
#define trav(i,v)   for(auto i: v)
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()
#define itn int
#define sz(x) (int)x.size()

//typedef
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< std::vector<int> > vvi;
typedef std::vector< std::pair < pii, int > > vpp;

const long long MOD = 1000000007;
// const long long MOD = 998244353;
const long double PI = 3.141592653589793238;
const long long pi = 31415926;
const long long inf = 1000000000000000000;
const long long small_inf = INT_MAX;

int modpow(int x, int n, int mod = MOD){ int res=1; while(n>0){ if(n&1) res=res*x%mod; x=x*x%MOD; n>>=1;} return res;}
int power(int x, int n){ int res=1; while(n>0){ if(n&1) res=res*x; x=x*x; n>>=1; } return res;}

int n, m, k;

vvi matmul(vvi &res, vvi &mat){
    // repu(i,1,n){
    //     repu(j,1,n){
    //         cout<<mat[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    vvi res1(n+1,vi(n+1,0));
    repu(i,1,n){
        repu(j,1,n){
            repu(k,1,n){
                res1[i][j] += res[i][k]*mat[k][j];
                res1[i][j] %= MOD;
            }
        }
    }
    // repu(i,1,n){
    //     repu(j,1,n){
    //         cout<<res1[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    return res1;
}

vvi matpow(vvi mat, int k){
    vvi res(n+1,vi(n+1,0));
    repu(i,1,n)
        res[i][i] = 1;
    while(k>0){
        if(k&1)
            res=matmul(res,mat);
        mat=matmul(mat,mat);
        k>>=1;
    }
    return res;
}

void init(){

}

void solve()
{
/*Don't hurry, nothing good comes if you rush*/
    cin>>n>>m>>k;
    vi a(n+1,0);
    repu(i,1,n){
        cin>>a[i];
    }
    vi v[n+1];
    repu(i,1,m){
        int x, y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    vi num(n+1,0), den(n+1,1);
    vvi mat(n+1,vi(n+1,0));
    repu(i,1,n){
        mat[i][i] = 2*m-sz(v[i]);
        trav(y,v[i]){
            mat[i][y] = 1;
        }
    }
    repu(i,1,n){
        repu(j,1,n){
            // cout<<mat[i][j]<<" ";
            mat[i][j] *= modpow(2*m,MOD-2);
            mat[i][j] %= MOD;
        }
        // cout<<endl;
    }

    mat = matpow(mat,k);

    vi ans(n+1,0);
    repu(i,1,n){
        repu(j,1,n){
            ans[i] += a[j]*mat[i][j];
            ans[i]%=MOD;
        }
    }
    repu(i,1,n){
        cout<<ans[i]<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t23 = 1, tt23 = 1;
    // cin>>t23;
    init();
    while(tt23<=t23)
    {
        // cout<<"Case #"<<tt23<<": ";
        solve();
        tt23++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

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

      mint inv() const { return pow(mod-2);}
      mint& operator/=(const mint a) { return *this *= a.inv();}
      mint operator/(const mint a) const { return mint(*this) /= a;}
     };
      istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
      ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
      struct combination {
      vector<mint> fact, ifact;
      combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
      }
      mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
      }
     } c(2000005);

    int main() {
      int N,K;
      cin>>N>>K;
      vector<ll>A(N);
      rep(i,N){cin>>A[i];}
      vector<mint>sum(K+1);//sum[k]=A[0]^k+A[1]^k+A[2]^k+...
      rep(i,N){
        mint now=1;
        rep(j,K+1){
          sum[j]+=now;
          now*=A[i];
        }
      }
      for(int i=1;i<=K;i++){
        mint ans=0;
        for(int j=0;j<=i;j++){
          ans+=c(i,j)*sum[j]*sum[i-j];
          ans-=sum[i]*c(i,j);
        }
        ans/=2;
        cout<<ans<<endl;
      }
      return 0;
    }

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e6 + 5;

bool isnp[MAXN];
int pri[MAXN], pcnt = 0, mu[MAXN];
void sieve(int n)
{
	isnp[0] = isnp[1] = 1; mu[1] = 1;
	for(int i=2; i<=n; ++i)
	{
		if(!isnp[i]) pri[++pcnt] = i, mu[i] = -1;
		for(int j=1; j<=pcnt && (ll)i*pri[j] <= n; ++j)
		{
			isnp[i*pri[j]] = 1;
			if(i%pri[j]) mu[i*pri[j]] = -mu[i];
			else{ mu[i*pri[j]] = 0; break;}
		}
	}
}

inline ll get_cop(int n,int m)
{
	ll res = 0;
	for(int d=1; d<=n && d<=m; ++d)
		res += (ll)mu[d] * (n / d) * (m / d);
	return res;
}

int main(void)
{
	sieve(MAXN-1);

	int l,r;
	scanf("%d%d",&l,&r);

	ll ans = (ll)(r - l + 1) * (r - l + 1);

	ans -= get_cop(r, r) - get_cop(r, l-1) * 2 + get_cop(l-1, l-1);

	for(int i=max(l,2); i<=r; ++i)
		ans -= (r / i) * 2 - 1;

	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
#define PI 3.141592653589793238462
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdd;
int main(){
    ll x,y,a,b;cin>>x>>y>>a>>b;
    ll now=0;
    while(x<(x+b)/a){
        if(x>=y/a) break;
        x*=a;now++;
    }
    if(x<y) now+=(y-x-1)/b;
    cout<<now<<endl;
}

#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
//#define N

int f(int x,int y,int m)// x^y%m
{
	int ans=1;
//	int n=1;
	while(y)
	{
		if(y&1)
		{
			ans=ans*x%m;
		}
		x=x*x%m;
		y=y>>1;
	}
	return ans;
}

int a,b,c;
int h[25],mark[10];

int main()
{
	scanf("%d%d%d",&a,&b,&c);

	a=a%10;
	memset(mark,-1,sizeof mark);
	h[0]=a;mark[a]=0;
	int mod,j;
	for(int i=1;i<=10;++i)
	{
		h[i]=h[i-1]*a%10;
//		printf("		%d\n",h[i]);
		if(mark[h[i]]<0)mark[h[i]]=i;
		else{
			j=mark[h[i]];
			mod=i-mark[h[i]];
//			printf("		%d %d\n",i,j);
			break;
		}
	}
	//b^c
	int e=f(b%mod,c,mod)-1;
	if(e<0)e+=mod;
//	printf("	%d %d\n",mod,e);
	printf("%d",h[e]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
int32_t main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l!=m) v.pb(l);
    }
    for(int x:v) cout<<x<<" ";
    return 0;
}

#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))

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

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

const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int x,y;
  cin >> x >> y;
  if(x == 0 && y == 0) {
    cout << 0 << endl;
  }
  if(x == 0 && y == 1) {
    cout << 2 << endl;
  }
  if(x == 0 && y == 2) {
    cout << 1 << endl;
  }
  if(x == 1 && y == 0) {
    cout << 2 << endl;
  }
  if(x == 1 && y == 1) {
    cout << 1 << endl;
  }
  if(x == 1 && y == 2) {
    cout << 0 << endl;
  }
  if(x == 2 && y == 0) {
    cout << 1 << endl;
  }
  if(x == 2 && y == 1) {
    cout << 0 << endl;
  }
  if(x == 2 && y == 2) {
    cout << 2 << endl;
  }
}


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

int main(){
  int x,y;
  cin >> x >> y;

  if(x==y){
    cout << x <<endl;
    return 0;
  }
  if(x+y==1) cout << 2 << endl;
  if(x+y==3) cout << 0 << endl;
  if(x+y==2) cout << 1 << endl;

}

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

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

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

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

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

//素因数分解vector<pair<素因数, 個数>>
vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while(n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

struct UnionFind {
    vector<int> par, siz;

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

    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        par[y] = x;
        siz[x] += siz[y];
        return true;
    }

    int size(int x) {
        return siz[root(x)];
    }
};

vector<int> BFS(const Graph &G, int s) {
    int n = (int)G.size();
    vector<int> p(n, -1);
    queue<int> que;
    p[0] = 0;
    que.push(0);

    while(!que.empty()) {
        int v = que.front();
        que.pop();

        for (int x : G[v]) {
            if (p[x] != -1) continue;
            if (p[v] == 0) p[x] = 1;
            if (p[v] == 1) p[x] = 0;
            que.push(x);
        }
    }
    return p;
}

vector<vector<ll> > comb(ll n, ll r) {
    vector<vector<ll> > v(n + 1, vector<ll> (n + 1, 0));
    rep(i, v.size()) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = v[j - 1][k - 1] + v[j - 1][k];
        }
    }
    return v;
}

int main() {
    int x, y;
    cin >> x >> y;
    if (x != y) {
        cout << 3 - x - y << endl;
    }
    else {
        cout << x << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using LL = uint64_t;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a,b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100
#define MAX6 1001001
#define MAX7 10010010
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define MAX_LL LLONG_MAX
#define CLR(mat) memset(mat, 0, sizeof(mat))
template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }
#define MOD 1000000007
//const ll inf=1e18;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

inline void chadd(ll &a, ll b){a+=b;if(a>=MOD)a-=MOD;}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}

int main(){
   ll N,M;cin>>N>>M;
   cout << mod_pow(10, N, M * M) / M % M << endl;
}

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

inline ll fpow(reg ll x,reg ll exp,reg ll mod){
	reg ll res=1;
	x%=mod;
	while(exp){
		if(exp&1)
			res=res*x%mod;
		x=x*x%mod;
		exp>>=1;
	}
	return res;
}

ll n;
int m;

int main(void){
	scanf("%lld%d",&n,&m);
	printf("%lld\n",fpow(10,n,m*m)/m);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
#define to_digit(c) c-'0';
int main()
{

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

    ll a, b; cin >> a >> b;
    if(b >= 8 && a+b >= 15)
    {
        cout << 1;
    }
    else if(b >= 3 && a+b >= 10)
    {
        cout << 2;
    }
    else if(a+b >= 3)
    {
        cout << 3;
    }
    else
    cout << 4;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b>=15&&b>=8)
	cout<<"1";
	else if(a+b>=10&&b>=3)
	cout<<"2";
	else if(a+b>=3)
	cout<<"3";
	else cout<<"4";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)    \
    vl v;               \
    rep(i, n)           \
    {                   \
        ll x;           \
        cin >> x;       \
        v.push_back(x); \
    }
const ll INF = 999999999999999;
const ll MOD = 998244353;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
struct segtree
{
    ll N;
    vl dat;
    void init(ll n)
    {
        N = 1;
        while (N < n)
            N *= 2;
        dat = vl(N * 2 + 1);
        for (ll i = 0; i < 2 * N - 1; i++)
            dat[i] = 0;
    }
    // update k th element
    void add(ll k, ll a)
    {
        k += N - 1; // leaf
        dat[k] += a;
        while (k > 0)
        {
            k = (k - 1) / 2;
            dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
        }
    }
    // sum of [a, b)
    ll query(ll a, ll b) { return query(a, b, 0, 0, N); }
    ll query(ll a, ll b, ll k, ll l, ll r)
    {
        if (r <= a or b <= l)
            return 0;
        if (a <= l and r <= b)
            return dat[k];
        ll m = (l + r) / 2;
        return (query(a, b, k * 2 + 1, l, m) + query(a, b, k * 2 + 2, m, r));
    }
};
int main()
{
    cin >> n;
    vl A(n);
    vl B(n);
    rep(i, n)
    {
        cin >> x;
        A[x] = i;
        B[i] = x;
    }
    reverse(all(A));
    segtree seg;

    seg.init(n);
    rep(i, n)
    {
        ans += seg.query(0, A[i]);
        seg.add(A[i], 1);
    }

    rep(i, n)
    {
        cout << ans << endl;
        ans += (n - 1) - B[i] * 2;
    }
}

#include<bits/stdc++.h>

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define Grep(u) for(int i=head[u];i;i=e[i].nxt)

#define clear(a) memset(a,0,sizeof(a))
#define setinf(a) memset(a,0x3f,sizeof(a))
#define setninf(a) memset(a,0xcf,sizeof(a))
#define setneg1(a) memset(a,-1,sizeof(a))

#define pb push_back
#define mp std::make_pair
#define fi first
#define se second

#define yes {puts("YES");return;}
#define no {puts("NO"),return;}

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;

const int N=5e5;
const int M=1e6;
const int P=998244353;
const int inf=0x3f3f3f3f;
const int ninf=0xcfcfcfcf;
const ll llinf=0x3f3f3f3f3f3f3f3f;
const ll llninf=0xcfcfcfcfcfcfcfcf;

struct Edge{int to,nxt;}e[M*2+10];int head[N+10],tote;
inline void addEdge(int u,int v){e[++tote].to=v;e[tote].nxt=head[u];head[u]=tote;}

//struct Edge{int to,nxt,w;}e[M*2+10];int head[N+10],tote;
//inline void addEdge(int u,int v,int w){e[++tote].to=v;e[tote].w=w;e[tote].nxt=head[u];head[u]=tote;}

#define gc() char(getchar())

template<typename T>inline T read(){
	T x=0;bool f=0;char c=gc();
	while(c<'0'||c>'9')f|=c=='-',c=gc();
	while(c>='0'&&c<='9')x=x*10+c-48,c=gc();
	return f?-x:x;
}
inline int ri(){return read<int>();}
inline ll rl(){return read<ll>();}
inline ui ru(){return read<ui>();}
inline ull rul(){return read<ull>();}
inline int rstr(char*& str){
	char c=gc();int res=0;
	while(c!='\n'&&c!='\r'&&c!=' ')str[++res]=c,c=gc();
	return res;
}
inline int rline(char*& str){
	char c=gc();int res=0;
	while(c!='\n'&&c!='\r')str[++res]=c,c=gc();
	return res;
}

#undef gc

template<typename T1,typename T2>inline void chkmax(T1& a,T2 b){if(a<b)a=b;}
template<typename T1,typename T2>inline void chkmin(T1& a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2,typename T3>inline void chkmax(T1& a,T2& b,T3 c){if(c>a){b=a;a=c;}else if(c>b)b=c;}
template<typename T1,typename T2,typename T3>inline void chkmin(T1& a,T2& b,T3 c){if(c<a){b=a;a=c;}else if(c<b)b=c;}
template<typename T1,typename T2,typename T3>inline void add(T1& x,T2 y,T3 p=P){(x+=y)>=p&&(x-=p);}
template<typename T1,typename T2,typename T3>inline void mul(T1& x,T2 y,T3 p=P){x=1LL*x*y%P;}

template<typename T1,typename T2,typename T3>inline T1 qpow(T1 x,T2 y,T3 p=P){
	T1 res=T1(1);
	while(y){if(y&1)mul(res,x,p);y>>=1;mul(x,x,p);}
	return res;
}
template<typename T1,typename T2,typename T3>inline T1 qmul(T1 x,T2 y,T3 p=P){
	T1 res=T1(0);
	while(y){if(y&1)add(res,x,p);y>>=1;add(x,x,p);}
	return res;
}
template<typename T1,typename T2>inline T1 gcd(T1 x,T2 y){return !y?x:gcd(y,T2(x%y));}
template<typename T1,typename T2,typename T3>inline T1 exgcd(T1 a,T2 b,T3& x,T3& y){
	if(b==0)return x=T3(1),y=T3(0),void();
	T1 res=exgcd(b,a%b,x,y);
	T3 tmp=x;x=y;y=tmp-(a/b)*y;
	return res;
}

void solve();
int main(){
	int T;
	T=1;
//	T=ri();
	while(T--)solve();
	return 0;
}

int n,a[N+10];
int c[N+10];
ll ans=0;

#define lowbit(x) (x&(-x))
inline void modify(int i,int x){for(;i<=n;i+=lowbit(i))c[i]+=x;}
inline int query(int i){int res=0;for(;i;i-=lowbit(i))res+=c[i];return res;}
#undef lowbit

void solve(){
	n=ri();
	rep(i,1,n)a[i]=ri(),a[i]++;
	rep(i,1,n){
		ans+=query(n)-query(a[i]);
		modify(a[i],1);
	}
	printf("%lld\n",ans);
	rep(i,1,n-1){
		ans=ans+(n-a[i])-(a[i]-1);
		printf("%lld\n",ans);
	}
}


/*
 * Author: Moon-light
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define sz(x) ((int)x.size())
#define fr(x) freopen(x,'r',stdin)
#define fw(x) freopen(x,'w',stdout)
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define bitcnt(x) (__builtin_popcountll(x))
#define rep(i,a,b) for(int i = (a);i<=(b); ++i)
#define per(i,a,b) for(int i = (a);i>=(b); --i)
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VB;
typedef double db;

template <class T> void clear(T& a) { T().swap(a);}
template <class T,class S>
inline bool upmin(T& a,const S&b){ return a>b ? a=b,1:0;}
template <class T,class S>
inline bool upmax(T&a, const S&b){ return a<b? a=b,1:0;}

//fast read(improved by fread)
char buf[1<<21],*p1=buf,*p2=buf;
inline int getc(){
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
}
inline int redi() {
    int ret = 0,f = 0;char ch = getc();
    while (!isdigit (ch)) {
        if (ch == '-') f = 1;
        ch = getc();
    }
    while (isdigit (ch)) {
        ret = ret * 10 + ch - 48;
        ch = getc();
    }
    return f?-ret:ret;
}

//global variable
const int N = 1;
const int mod = 1e9+7;
vector<PII> a;
int n;
//functions
LL qmi(LL a,LL k,LL mod){
    LL res = 1;
    while(k){
        if(k&1) res = res*a%mod;
        k >>= 1;
        a = a*a%mod;
    }
    return mod;
}
int gcd(int a,int b) {
    return b==0? a:gcd(b,a%b);
}
//

//code from here! Come on! Have a pleasant experience~
int main()
{
    IO;
    cin>>n;

    int x;
    n = pow(2,n);
    rep(i,1,n){
        cin>>x;
        a.push_back({x,i});
    }
    vector<PII> t = a;

    while(t.size()>2){
        vector<PII> b;
        for(int i = 0; i<n-1; i+=2){
            if(t[i].first > t[i+1].first){
                b.push_back(t[i]);
            }else{
                b.push_back(t[i+1]);
            }
            // cout<<t[i].first<<" "<<t[i+1].first<<endl;
        }
        t = b;
        n = t.size();
    }

    if(t[0].first > t[1].first){
        cout<<t[1].second<<endl;
    }else{
        cout<<t[0].second<<endl;
    }
    return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define sz(x)                 (int)(x).size()
#define all(x)                (x).begin(), (x).end()
#define tr(x, it)             for(auto (it) = (x).begin();it != (x).end();it++)
#define fo(i, k, n)           for(int i = (k);i < (n);i++)
#define Fo(i, k, n)           for(int i = (k);i >= (n);i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)
#define deb(x)                cout<<#x<< " = "<< (x)<<"\n";

void solve(){
	int n, x;
	cin>>n>>x;
	int ar[n];
	fo(i, 0, n){
		cin>>ar[i];
	}
	fo(i, 0, n){
		if(ar[i] != x) cout<<ar[i]<<" ";
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
		cout<<el;
	}
	return 0;
}
	// int n, m;
	// cin>>n>>m;
	// int a[n], b[n], c[m];
	// fo(i, 0, n) cin>>a[i];
	// fo(i, 0, n) cin>>b[i];
	// fo(i, 0, m) cin>>c[i];
	// int idxa = -1, idxc = -1, i = m-1;
	// bool bb = false;
	// fo(j, 0, n){
	// 	if(c[i]==b[j] && b[j]!=a[j]){
	// 		idxa = j;
	// 		idxc = i;
	// 		bb = true;
	// 		// deb(i)
	// 		// deb(j)
	// 		break;
	// 	}
	// }
	// if(!bb){
	// 	fo(j, 0, n){
	// 		if(c[i]==b[j]){
	// 			idxa = j;
	// 			idxc = i;
	// 			// deb(i)
	// 			// deb(j)
	// 			bb = true;
	// 			break;
	// 		}
	// 	}
	// }

	// if(!bb){
	// 	cout<<"NO";
	// 	return;
	// }
	// vector<int> v;
	// fo(i, 0, m){
	// 	if(i == idxc) continue;
	// 	bool bbb = false;
	// 	fo(j, 0, n){
	// 		if(j == idxa) continue;
	// 		if(c[i] == b[j] && b[j] != a[j]){
	// 			v.pb(j+1);
	// 			a[j] = c[i];
	// 			bbb = true;
	// 			break;
	// 		}
	// 	}
	// 	if(!bbb){
	// 		a[idxa] = c[i];
	// 		v.pb(idxa+1);
	// 	}
	// }
	// a[idxa] = c[idxc];
	// v.pb(idxa+1);
	// fo(i, 0, n){
	// 	if(a[i] != b[i]){
	// 		cout<<"NO";
	// 		return;
	// 	}
	// }
	// cout<<"YES"<<el;
	//


/* Author: rrrr_wys
 **/

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
typedef double db;
typedef long long ll;
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int N = 2000110;
const int P = 998244353;

int p[N], prime[N], tot, psize;
ll phi[N], mu[N];

ll cal(int n) {
  ll ans = 0;
  rep(g, 2, n) { ans += phi[n / g] * 2ll - (n / g) * 2ll; }
  return ans;
}
ll cal(int n, int m) {
  ll ans = 0;
  if (n < m)
    swap(n, m);
  rep(g, 2, m) {
    for (int dr, dl = 1; dl <= m / g; dl = dr + 1) {
      dr = min((m / g) / ((m / g) / dl), (n / g) / ((n / g) / dl));
      dr = min(dr, m / g);
      ans += (mu[dr] - mu[dl - 1]) * ((n / g) / dl) * ((m / g) / dl);
    }
    ans -= (n / g);
    ans -= (m / g);
    ans += 1;
  }
  return ans;
}

void prime_table() {
  int i, j, tot, t1;
  for (i = 1; i <= psize; i++)
    p[i] = i;
  phi[1] = 1;
  mu[1] = 1;
  for (i = 2, tot = 0; i <= psize; i++) {
    if (p[i] == i)
      prime[++tot] = i, phi[i] = i - 1, mu[i] = -1;
    for (j = 1; j <= tot && (t1 = prime[j] * i) <= psize; j++) {
      p[t1] = prime[j];
      if (i % prime[j] == 0) {
        phi[t1] = phi[i] * prime[j];
        break;
      }
      phi[t1] = phi[i] * (prime[j] - 1);
      mu[t1] = -mu[i];
    }
  }
  rep(i, 1, psize) phi[i] += phi[i - 1], mu[i] += mu[i - 1];
}

void init(int ps) {
  psize = ps;
  prime_table();
}
signed main() {
  int L, R;
  cin >> L >> R;
  init(N - 1);
  cout << cal(R, R) - cal(L - 1, R) - cal(R, L - 1) + cal(L - 1, L - 1) << "\n";
}

#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
#include <string>
#include <map>
#include <cmath>
#include <random>
#include <tuple>
#include <set>
#include <queue>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

struct Edge {
    long long to;
    long long c;
  ll d;
};
using Graph = vector<vector<Edge>>;
using P = pair<long, int>;
const long long INF = 1LL << 60;

ll dijkstra(const Graph &G, vector<long long> &dis) {
    int N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq;
    dis[0] = 0;
    pq.emplace(dis[0], 0);
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (auto &e : G[v]) {
          ll cost;
          ll d = e.d;
          ll cc = e.c;
          if(dis[v] > sqrt(d)-1){
            cost = cc +(d)/(dis[v]+1) + dis[v];
          }else{
            cost = sqrt(d) + (d)/(sqrt(d)+1);
            if(d/(sqrt(d)) + sqrt(d)-1 < cost){
              cost = d/(sqrt(d)) + sqrt(d)-1;
            }
            cost += cc;
          }
            if (dis[e.to] > cost) {
                dis[e.to] = cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
  if(dis[N-1] == INF){
    dis[N-1] = -1;
  }
  return dis[N-1];
}

int main(){

  ll n,m;
  cin >> n >> m;
  Graph G(n);
  rep(i,m){
    ll b,c,d,e;
    cin >> b >> c >> d >> e;
    G[b-1].push_back({c-1,d,e});
    G[c-1].push_back({b-1,d,e});
  }
  vector<ll> dis(n,INF);
  cout << dijkstra(G,dis) << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> P(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i].first >> P[i].second;
  }
  sort(P.begin(), P.end());
  set<int> st;
  st.insert(N);
  for (int l = 0; l < M;) {
    int r = l;
    vector<int> A, B;
    for (; r < M && P[l].first == P[r].first; r++) {
      if (st.find(P[r].second + 1) != st.end() || st.find(P[r].second - 1) != st.end()) {
        A.emplace_back(P[r].second);
      } else {
        B.emplace_back(P[r].second);
      }
    }
    for (int a : A) {
      st.insert(a);
    }
    for (int b : B) {
      auto it = st.find(b);
      if (it != st.end()) st.erase(it);
    }
    l = r;
  }
  cout << st.size() << '\n';
  return 0;
}

#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,m;
  cin>>n>>m;
  map<pair<int,int>,int> M;
  rep(i,m){
    int x,y;
    cin>>x>>y;
    M[{x,y}]=1;
  }

  map<int,int> A;
  map<pair<int,int>,int> B;
  A[n]=1;
  for(auto t:M){
    int x=t.first.first;
    int y=t.first.second;
    if(A[y]==1) B[{x-1,y}]=1;
    A[y]=0;
    if(A[y+1]==1) A[y]=1;
    else if(B[{x-1,y-1}]==1) A[y]=1;
    else if(A[y-1]==1 && M[{x,y-1}]!=1) A[y]=1;
   /* cout<<x<<" "<<y<<" ";
    rep(i,2*n+1) cout<<A[i];
    cout<<endl;*/
  }
  int cnt=0;
  for(auto t:A){
    if(t.second==1){
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}


#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

int main(){
   int n;
   cin>>n;
   ll cnt[200]={};
   rep(i,0,n){
      int x;
      cin>>x;
      cnt[x%200]++;
   }
   ll res=0;
   rep(x,0,200)res+=cnt[x]*(cnt[x]-1)/2;
   cout<<res<<'\n';
   return 0;
}

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

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

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

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

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

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

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

    int main(){
        lint n;
        cin>>n;
        vector<lint> x(n);
        rep(i,n)cin>>x[i];
        vector<lint> g;
        rep(i,51)if(primary(i))g.push_back(i);
        lint t=g.size();
        lint ans=INF;
        rep(bit,1<<t){
            bool isu[t];
            fill(isu,isu+t,false);
            rep(i,t)if((1<<i)&bit)isu[i]=true;
            lint comp=1;
            bool isok=true;
            rep(i,n){
                bool isp=false;
                rep(j,t){
                    if(isu[j]&&x[i]%g[j]==0)isp=true;
                }
                if(!isp)isok=false;
            }
            if(!isok)continue;
            rep(i,t)if(isu[i])comp*=g[i];
            chmin(ans,comp);

        }
      cout<<ans<<endl;

      }


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

int main() {
    int a,b,c;
  cin>>a;
  cin>>b;
  cin>>c;

    if(a-(2*b)+c == 0){
         cout << "Yes" << endl;
    }
      else if(a-(2*c)+b == 0){
         cout << "Yes" << endl;
    }
      else if(a-(2*b)+c == 0){
         cout << "Yes" << endl;
    }
        else if(b-(2*a)+c == 0){
         cout << "Yes" << endl;
    }
        else if(b-(2*c)+a == 0){
         cout << "Yes" << endl;
    }
          else if(c-(2*a)+b == 0){
         cout << "Yes" << endl;
    }
          else if(c-(2*b)+a == 0){
         cout << "Yes" << endl;
    }
    else{
         cout << "No" << endl;
    }

}

#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int INF=1e16+1;
const int mod=1000000007;
//const int mod=998244353;
int custom_ceil(int Nr,int Dr){
    if(Nr%Dr==0)return Nr/Dr;
    else return Nr/Dr+1;
}
void solve(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    do{
        if(a[1]-a[0]==a[2]-a[1]){
            cout<<"Yes\n";
            return;
        }
    }while(next_permutation(a,a+3));
    cout<<"No\n";
}
int32_t main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

const int maxn = 2e5+8, inf  = 1e18+9, mod  = 998244353;

int n, m;

void solve() {
    int i, j, ans = 0, pre = 0;
    map<int, int> mp; mp[pre]++;
    cin >> n;
    for (i = 1; i <= n; i++) {
        int v; cin >> v;
        if (i & 1) pre -= v;
        else pre += v;
        ans += mp[pre]++;
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); //cout << fixed << setprecision(15);
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}

/*
problem :
algorithm :
created : Programmer_juruo
*/

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

#define int long long
#define N 2000005
#define M 2005
#define lowbit(x) x & (-x)
#define F1(i, n) for(int i = 1; i <= n; i++)
#define F(i, a, n) for(int i = a; i <= n; i++)
#define F0(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define se second
#define fi first
#define y1 juruo
#define mp make_pair
#define pb push_back
#define arr vector<int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

typedef pair <int, int> pii;
typedef priority_queue <int> pq;
typedef long long ll;

const int inf = 0x3f3f3f3f;
const int p = 107;
const int P = 100007;
const int Mod = 1e9+7;

int n, m;

int S[N];
map<int, int> Map;
int Ans = 0;

void Go(int x) {
	Ans += Map[x];
	++Map[x];
}

void work() {
	cin >> n;
	for(int i = 3; i <= n+2; i++) cin >> S[i];
	for(int i = 5; i <= n+2; i++) {
		S[i] += S[i-2];
	}
	n += 2;
	for(int i = 2; i <= n; i += 2) {
		Go(S[i] - S[i-1]);
		if(i+1 <= n) Go(S[i] - S[i+1]);
	}

	cout << Ans << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  //cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}


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

int main()
{
  double ans;
  double A;
  double B;

  cin >> A >> B;
  ans = A/100 * B;

   cout << ans << endl;
}

#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
const double PI=acos(-1);
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    char s,t;cin >> s >> t;
    if(s=='Y')cout << (char)(t+'A'-'a') << endl;
    else cout << t << endl;
}


/*
	I love the sound you make when you shut up.
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
/*-------typedefs------*/
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update> ;
using ll = long long;
using pi = pair<int, int>;
/*-----in and out--------*/
#define pf(a) cout << a << endl
#define forIn(arr, num) for(int i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(int i = 0; i < int(ans.size()); i++) cout << ans[i] << (i + 1 < int(ans.size()) ? ' ' : '\n');
/*---useful defines------*/
#define sz(x) (int)(x).size()
#define pb push_back
#define mem(a, b) memset(a,(b), sizeof(a))
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
/*----- the binary answer of life-----*/
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
/*---checking and pushing-----*/
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
/*---- FAST I/O and file read ---*/
void go() {
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#endif
}
/*-------- test-case stuff--------------*/
#define ssolve solve();
#define msolve int T;cin >> T;while(T--) {solve();}
#define mcsolve int T;cin >> T;for(int tt = 1;tt <= T;tt++) {cout << "Case #" << tt << ": ";solve();}
/*-------- movement in a 2D array ------*/
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
/*----------------------------------------------------------------*/
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
/*-------------- Push your limits here ---------------------------*/
void solve() {
    int n, x;
    cin >> n >> x;

    vector<int> v(n);
    forIn(v, n);

    vector<int> store;
    for(int i = 0;i < n;i++) {
        if(v[i] != x) store.pb(v[i]);
    }

    vpnt(store);
}

int main() {
    //go();
    ssolve
    return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int c[a];
    for(int i=0;i<a;i++){
        cin>>c[i];
    }
    for(int i=0;i<a;i++){
        if(c[i]!=b){
            cout<<c[i]<<' ';
        }
    }
}


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

#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1

#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    li n,k,m;
    cin>>n>>k>>m;
    li sum=0;
    rep(i,n-1){
        li x;
        cin>>x;
        sum+=x;
    }
    li rest = m*n-sum;
    if(rest>k){
        puts("-1");
    }else {
        cout<<max(0ll, rest)<<endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define p(x,y) pair<x,y>
#define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define scan(a) for(auto &it:a)cin>>it;
#define print(a) {for(auto it:a)cout<<it<<" ";cout<<endl;}
#define out(x) cout<<((x)?"YES":"NO")<<endl;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define int ll
#define prime (int)(1e9+7)
void solve()
{
    int n;
    cin>>n;
    vector<vector<p(int,int)>> g(n+1,vector<p(int,int)>());
    rep(i,1,n)
    {
        int u,v,we;
        cin>>u>>v>>we;
        g[u].push_back({v,we});
        g[v].push_back({u,we});
    }
    vector<int> dist(n+1,-1),kbit(61,0);
    queue<int> q;
    q.push(1LL);
    dist[1]=0;
    while(!q.empty())
    {
        int p=q.front();
        q.pop();
        for(p(int,int) ch:g[p])
        {
            if(dist[ch.first]==-1)
            {
                q.push(ch.first);
                dist[ch.first]=dist[p]^ch.second;
                for(int i=0LL;i<61LL;i++)
                {
                    if(dist[ch.first]>>i&1)
                        kbit[i]++;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<61;i++)
    {
        int t=(((1LL<<i)%prime)*(n-kbit[i]))%prime;
        t=(t*kbit[i])%prime;
        ans=(t+ans)%prime;
    }
    cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1;
    //init();
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
signed main()
{
    int a,b,c,d,n;
    cin>>n;

        if(n%100>0)
         cout<<n/100+1;
         else cout<<n/100;

    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    long lim;
    long wei;
    long total=0;
    cin>>lim;
    cin>>wei;
    for(long i=wei;i<=lim;i+=wei){
        total++;
    }
    cout<<total;
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(c * d - b == 0){
        cout << -1 << endl;
    }
    else{
    long long int ans = a / (c * d - b);
    if(ans < 0){
        cout << -1 << endl;
    }
    else{
        if(a % (c * d - b) != 0){
            cout << ans + 1 << endl;
        }
        else{
            cout << ans << endl;
        }
    }
    }

}

#include<cstdio>
#include<algorithm>
#define int long long
const int Q=100005;
const int INF=(1<<30);
using namespace std;
typedef long long ll;
#define rg register int
char buf[1<<21],*p1=buf,*p2=buf;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline bool ig(char c){return c>=48&&c<=57;}
inline void read(int &oi){char c;int f=1,res=0;while(c=gc(),(!ig(c))&&c^'-');c^'-'?res=(c^48):f=-1;while(c=gc(),ig(c))res=res*10+(c^48);oi=f*res;}
inline void print(int oi){if(oi<0)putchar('-'),oi=~oi+1;if(oi>9)print(oi/10);putchar(oi%10+48);}
inline void write(int oi,char c){print(oi);putchar(c);}
int a,b,c,d,res;
signed main(){
	read(a);read(b);read(c);read(d);
	c*=d;c-=b;if(c>0)res=(a-1)/c+1;else res=-1;write(res,'\n');
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec a(N), t(N);
    REP(i,0,N) cin >> a[i] >> t[i];
    ll Q;
    cin >> Q;
    vec x(Q);
    REP(i,0,Q) cin >> x[i];

    ll l = -INF, u = INF, b = 0;;
    REP(i,0,N) {
        if(t[i] == 1) {
            if(l > -INF) l = MAX(l+a[i],-INF);
            if(u < INF) u = MIN(u+a[i],INF);
            b += a[i];
        }
        else if(t[i] == 2) {
            l = MAX(l,a[i]);
            if(l > u) u = l;
        }
        else {
            u = MIN(u,a[i]);
            if(l > u) l = u;
        }
    }

    REP(i,0,Q) {
        if(x[i] <= l - b) PR(l);
        else if(x[i] <= u - b) PR(x[i]+b);
        else PR(u);
    }

    return 0;
}

/*

*/

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9;
int N, Q;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll mi = INF, mx = -INF, a = 0;
    cin >> N;
    for(int i=0;i<N;++i) {
        ll x, t; cin >> x >> t;
        if(t == 1) {
            mi += x;
            mx += x;
            a += x;
        }
        else if(t == 2) {
            mi = max(mi, x);
            mx = max(mx, x);
        }
        else {
            mi = min(mi, x);
            mx = min(mx, x);
        }
    }
    cin >> Q;
    for(int i=0;i<Q;++i) {
        ll x; cin >> x;
        cout << max(mx, min(mi, a+x)) << '\n';
    }
    return 0;
}


//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
// static const ll MOD = (1LL << 61LL) - 1LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s)
{
	ll v;
	istringstream sin(s);
	sin >> v;
	return v;
}
template <class t>
inline string tostring(t x)
{
	ostringstream sout;
	sout << x;
	return sout.str();
}

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a); (i) < (ll)(b); (i)++)
#define REPD(i, a, b) for (ll i = (ll)(a); (i) < (ll)(b); (i)++)
#define REPI(v, vs) for (auto &v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" \
					  << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807LL

template <ull N, class T, class... Args, std::enable_if_t<N == 0, int> = 0>
auto make_multiple_vector(Args... args)
{
	return T(args...);
}

template <ull N, class T, class... Args, std::enable_if_t<N != 0, int> = 0>
auto make_multiple_vector(ull size, Args... args)
{
	using value_type = std::decay_t<decltype(make_multiple_vector<N - 1, T>(args...))>;
	return vector<value_type>(size, make_multiple_vector<N - 1, T>(args...));
}

template <class Integer>
class BinaryIndexedTree
{
private:
	ull maxSize_;
	vector<Integer> values_;

public:
	BinaryIndexedTree(ull maxSize) : maxSize_(maxSize), values_(maxSize_, 0) {}

	void update(ll index, Integer increment)
	{
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		while (index <= maxSize_)
		{
			values_[index - 1] += increment;
			index += index & -index;
		}
	}

	Integer query(ll index)
	{
		if (index < 0LL)
			return 0;
		if (maxSize_ <= index)
		{
			throw invalid_argument("Index should be less than maxSize.");
		}
		++index;

		Integer res = 0;
		while (index > 0)
		{
			res += values_[index - 1];
			index -= index & -index;
		}
		return res;
	}
};
using BIT = BinaryIndexedTree<ll>;

int solve()
{
	ll n;
	cin >> n;

	vector<ll> as(n);
	REPD(i, 0, n)
	cin >> as[i];

	ll res = n * (n - 1) / 2;
	BIT bit(n);
	REPD(i, 0, n)
	{
		res -= bit.query(as[i]);
		bit.update(as[i], 1);
	}

	REPD(i, 0, n)
	{
		cout << res << endl;
		res += n - as[i] * 2 - 1;
	}

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}

#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n;
int a[600005];
int loga[300005];
int desno[600005];
int lijevo[600005];

void update(int x, int y) {
	x++;
	for (; x <= n; x += x & -x) loga[x] += y;
}

int query(int x) {
	int out = 0;
	x++;
	for (; x > 0; x -= x & -x) out += loga[x];
	return out;
}

int main () {

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

	for (int i = 2*n-1; i >= 0; i--) {
		desno[i] = query(a[i]-1);
		update(a[i], 1);
	}

	ll sol = 0;
	memset(loga, 0, sizeof loga);
	for (int i = 0; i < n; i++) {
		lijevo[i] = query(n-1)-query(a[i]);
		update(a[i], 1);
		sol += lijevo[i];
	}

	cout << sol << "\n";

	for (int i = n; i < 2*n-1; i++) {
		lijevo[i] = query(n-1)-query(a[i]);
		update(a[i], 1);

		sol += lijevo[i];
		sol -= lijevo[i-n];
		sol -= desno[i-n];
		sol += desno[i];

		cout << sol << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 200+5;
#define esp 1e-19
#define ll long long
#define inf 0x3f3f3f3f

int a[N][N],b[N];
struct node {
    int x,y;
}c[N];
int n,m,k;
int ret;
int vis[N][N];
void DFS(int r) {
    if(r==k) {
        int cnt = 0;
        memset(vis,0,sizeof vis);
        for(int i = 0;i < k;i++) {
            for(int j = 0;j < k;j++) {
                if(vis[b[i]][b[j]]==0) {
                    cnt+=a[b[i]][b[j]];
                    vis[b[i]][b[j]] = 1;
                }
            }
        }
        ret = max(ret,cnt);
        return;
    }
    b[r] = c[r].x;
    DFS(r+1);
    b[r] = c[r].y;
    DFS(r+1);
}
int main() {
    cin>>n>>m;
    for(int i = 0,u,v;i < m;i++) {
        cin>>u>>v;
        a[u][v]++;
    }
    cin>>k;
    for(int i = 0;i < k;i++) {
        cin>>c[i].x>>c[i].y;
    }
    DFS(0);
    cout<<ret<<endl;
}

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

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ll,ll> pll;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_set tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update>

#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)
#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(arr) arr.begin(),arr.end()
//#define sort(vec) sort(vec.begin(),vec.end())
//#define reverse(vec) reverse(vec.begin(),vec.end())

ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a);
        a = (a*a);
        b = b/2;
    }
    return ans;
}

ll Lpow(ll a,ll b,ll M)
{
	ll ans = 1;
	while(b > 0)
	{
		if(b%2)
			ans = (ans*a)%M;
		a = (a*a)%M;
		b = b/2;
	}
	return ans;
}

int main()
{
    fastio;

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

    vector<int> arr(m),brr(m);

    F(i,m)
        cin >> arr[i] >> brr[i];

    int k;
    cin >> k;

    vector<int> crr(k),drr(k);
    F(i,k)
        cin >> crr[i] >> drr[i];

    int ma = (1<<k)-1;
    int ans = 0;

    for(int i = 0;i<=ma;i++)
    {
        vector<int> tmp(n+1,0);

        int o = i;
        for(int u = 0;u < k;u++)
        {
            if((o&(1<<u)) >= 1)
                tmp[drr[u]]++;
            else
                tmp[crr[u]]++;
        }

        int curr = 0;
        for(int j = 1;j<=m;j++)
        {
            if(tmp[arr[j-1]] >= 1 && tmp[brr[j-1]] >= 1)
                curr++;
        }

        ans = max(ans,curr);
    }

    cout << ans << endl;

	return 0;
}


//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2

#include <bits/stdc++.h>
#include <cstdio>
#include <iterator>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vll vector<long long int>
#define vb vector<bool>
#define pb push_back
#define ll long long int
#define endl '\n'
#define pii pair<int,int>
#define pill pair<int,ll>
#define plli pair<ll,int>
#define plli pair<ll,int>
#define tlli tuple<ll,ll,int>
#define till tuple<int,ll,ll>
#define forn(b) for(int i = 0; i<b ;i++)
#define MAX 4005

int main(){
    int n;
    cin>>n;
    string ans = n%2?"Black":"White";
    cout<<ans<<endl;
}

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

#define int long long

int32_t main() {

    int n;
    cin >> n;
    vector<int> div;
    for(int i=2; n > 1; ) {
        if(n%i == 0) {
            div.push_back(i);
            n /= i;
            continue;
        }
        i++;
        if(i*i > n) i = n;
    }

    set<int> ans;
    ans.insert(1);

    for(int x : div) {
        vector<int> now;
        for(int y : ans) now.push_back(y);
        for(int y : now) ans.insert(x * y);
    }

    for(int x : ans) cout << x << endl;

    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")

#include <bits/stdc++.h>

using namespace std ;

#define int int64_t //be careful about this
#define endl "\n"
#define f(i,a,b) for(int i=int(a);i<int(b);++i)

#define pr pair
#define ar array
#define fr first
#define sc second
#define vt vector
#define pb push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue

#define sz(x) ((int)(x).size())
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))

template<class A> void rd(vt<A>& v);
template<class T> void rd(T& x){ cin >> x; }
template<class H, class... T> void rd(H& h, T&... t) { rd(h) ; rd(t...) ;}
template<class A> void rd(vt<A>& x) { for(auto& a : x) rd(a) ;}

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

template<typename T>
void __p(T a) {
  cout<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}\n";
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}\n"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}

void setIO(string s = "") {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin.exceptions(cin.failbit);
	cout.precision(15);	cout << fixed;
  #ifdef ONLINE_JUDGE
  if(sz(s)){
  	freopen((s+".in").c_str(),"r",stdin);
  	freopen((s+".out").c_str(),"w",stdout);
  }
  #endif
}
const int inf = 1e9, A = 26;
signed main(){
  setIO() ;
  int n,m; rd(n,m);
  int dp[n][n];
  f(i,0,n) f(j,0,n) dp[i][j] = inf ;
  f(i,0,n) dp[i][i] = 0;
  vt<int> g[n][A];
  f(_,0,m){
  	int u,v; char c;
  	rd(u,v,c);
  	--u,--v;
  	ckmin(dp[u][v],int(1));
  	ckmin(dp[v][u],int(1));
  	g[u][c-'a'].pb(v);
  	g[v][c-'a'].pb(u);
  }
  PQ<ar<int,3>> q;
  f(i,0,n) f(j,0,n) q.push({-dp[i][j],i,j});
  while(sz(q)){
  	auto a = q.top(); q.pop();
  	int v = -a[0], i = a[1], j = a[2];
  	if(dp[i][j] != v) continue;
  	f(k,0,A){
  		for(auto x : g[i][k]){
  			for(auto y : g[j][k]){
  				if(ckmin(dp[x][y],v + 2)){
  					q.push({-dp[x][y],x,y});
  				}
  			}
  		}
  	}
  }
  cout << (dp[0][n-1] == inf ? int(-1) : dp[0][n-1]);
}

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

const int inf = 1 << 29;
const int N = 1100;
vector<int> edge[N][26];
vector<int> edge2[N * N];
int dist[N * N];

void bfs(int s)
{
    queue<int> q;
    fill(dist, dist + N * N, inf);
    q.push(s);
    dist[s] = 0;
    while (q.size())
    {
        int v = q.front();
        q.pop();
        for (auto to : edge2[v])
        {
            if (dist[to] != inf)
                continue;
            dist[to] = dist[v] + 1;
            q.push(to);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        char c;
        cin >> a >> b >> c;
        a--, b--;
        c -= 'a';
        edge[a][c].push_back(b);
        edge[b][c].push_back(a);
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
        {
            int from = i * N + j;
            for (int c = 0; c < 26; c++)
                for (int ito : edge[i][c])
                    for (int jto : edge[j][c])
                    {
                        int to = ito * N + jto;
                        edge2[from].push_back(to);
                    }
        }

    int start = 0 * N + (n - 1);
    bfs(start);

    int ans = inf;
    for (int i = 0; i < n; i++)
    {
        ans = min(ans, dist[i * N + i] * 2);
        for (int c = 0; c < 26; c++)
            for (int to : edge[i][c])
                ans = min(ans, dist[i * N + to] * 2 + 1);
    }

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


#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

// UnionFind Tree (0-indexed), based on size of each disjoint set
struct UnionFind
{
    std::vector<int> par;
    vector<unordered_map<int, int>> cou;
    UnionFind(int N = 0) : par(N), cou(N) {
        iota(par.begin(), par.end(), 0);
    }
    int find(int x) { return (par[x] == x) ? x : (par[x] = find(par[x])); }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (cou[x].size() < cou[y].size()) std::swap(x, y);
        par[y] = x;
        for (auto [a, b] : cou[y]) {
            cou[x][a] += b;
        }
        cou[y].clear();
        return true;
    }
};

int main()
{
    cin.tie(nullptr), ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    vector<int> C(N);
    for (auto &x : C) {
        cin >> x;
        x--;
    }

    REP(i, N) {
        uf.cou[i][C[i]] = 1;
    }

    while (Q--) {
        int q, x, y;
        cin >> q >> x >> y;
        x--, y--;
        if (q == 1) {
            uf.unite(x, y);
        } else {
            cout << uf.cou[uf.find(x)][y] << '\n';
        }
    }
}

#include <bits/stdc++.h>
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
#define ll long long
using namespace std;

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

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

// look for  all edge cases
//search for a pattern

const int nax = 2e5 + 2;
int n,q;
vector<int> section;
vector<int> parent;
map<int,int> m[nax];
vector<int> si;
void solve();

void merge(int a , int b){
	while(parent[a] != a){
		a = parent[a];
	}
	while(parent[b] != b){
		b = parent[b];
	}

	if(a == b){
		return;
	}

	if(si[b] > si[a]){
		swap(a , b);
	}

	si[a] += si[b];
	parent[b] = a;
	for(auto it : m[b]){
		m[a][it.x] += m[b][it.x];
	}
	m[b].clear();

}

signed main(){

	cin >> n >> q;
	section.resize(n+1);
	si.assign(n+1,0);
	parent.assign(n+1, 0);
	for(int i =1 ;i <= n;i++){
		cin >> section[i];
	}

	for(int i=1 ; i <=n ;i++){
		si[i] = 1;
		parent[i] = i;
		m[i][section[i]] += 1;
	}

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

	return 0;

}

void solve(){
	int type;
	cin >> type;
	int a,b;
	cin >>a >> b;

	if(type == 1){
		merge(a , b);
	}
	else{
		while(a != parent[a]){
			a = parent[a];
		}
		cout << m[a][b] << "\n";

	}

}


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

struct Edge{
    int to;
    ll weight;
    ll bias;
    Edge(int to, ll weight, ll bias):to(to), weight(weight), bias(bias){}
};
using Graph = vector<vector<Edge>>;

const ll INF = 1LL<<60;

vector<ll> Dijkstra(Graph &G, int start){
    int graph_size = (int)G.size();
    vector<ll> distance(graph_size, INF);
    priority_queue<pair<ll, int>,
                    vector<pair<ll, int>>,
                    greater<pair<ll, int>>> que;
    distance[start] = 0;
    que.push(make_pair(distance[start], start));
    while(!que.empty()){
        auto [dist ,visit] = que.top();
        que.pop();
        if (distance[visit] != dist) continue;
        for(Edge& next_edge : G[visit]){
            ll x = sqrt(next_edge.bias) - dist;
            ll next_dist = dist + next_edge.weight;
            if(x > 0)
                next_dist += min(next_edge.bias / (dist+1),
                                    min(x + (next_edge.bias / (dist + x + 1)),
                                        x + 1 + (next_edge.bias / (dist + x ))
                                        )
                                );
            else
                next_dist += next_edge.bias / (dist+1);
            if(distance[next_edge.to] <= next_dist) continue;
            distance[next_edge.to] = next_dist;
            que.push(make_pair(distance[next_edge.to], next_edge.to));
        }
    }
    return distance;
}

int main(){
    int n, m;    cin >> n >> m;
    Graph G(n+1);
    rep(i, m){
        ll a,b,c,d; cin >> a >> b >> c >> d;
        if(a==b)    continue;
        G[a].push_back(Edge(b, c, d));
        G[b].push_back(Edge(a, c, d));
    }
    auto dis = Dijkstra(G, 1);
    if(dis[n] == 1LL<<60)  dis[n] = -1;
    cout << dis[n] << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

vector<pll> z;
int main(){
  ll n,k;
  cin>>n>>k;
  rep(i,0,n){
    ll x,y;
    cin>>x>>y;
    z.pb(mp(x,y));
  }
  sort(z.begin(),z.end());
  ll pos=0,ans=0;
  ll pt =k;
  rep(i,0,z.size()){
    if(pt-z[i].first+pos>=0){
      pt-=z[i].first-pos;
      pt+=z[i].second;
      pos=z[i].first;
    }
    else{
      break;
    }
  }
  ans=pos+pt;
  cout<<ans;
}


#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 LINF 9223372036854775807
#define cout(n) cout << fixed << setprecision(n)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mod 1000000007;

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;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		cnt += i;
		if (cnt >= n) {
			cout << i << endl;
			break;
		}
	}
}

//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353

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

ll a[300000] = {}, t[300000] = {}, x;

int main() {
	ll ans = 0;
	ll tmp = 0;
	int n; cin >> n;
	REP(i, n) cin >> a[i] >> t[i];
	ll l = -1000000000, h = 1000000000;
	ll off = 0;
	//ll lo = 0, mo = 0, ho = 0;
	REP(i, n){
		if(t[i] == 1){
			off += a[i];
			h += a[i];
			l += a[i];
		}
		if(t[i] == 2){
			l = max(l, a[i]);
			h = max(h, a[i]);
		}
		if(t[i] == 3){
			l = min(l, a[i]);
			h = min(h, a[i]);
		}
		//cout << l << " " << h << " " << off << endl;
	}
	int q; cin >> q;
	REP(i, q){
		cin >> x;
		if(x + off <= l) cout << l << endl;
		else if(x + off >= h) cout << h << endl;
		else cout << x + off << endl;
	}
	///cout << ans << endl;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define int long long
bool vis[101];
int c[101];
signed main()
{
	int t,n;scanf("%lld%lld",&t,&n);
	for(int i=1;i<=100;i++)vis[(t+100)*i/100]=1;
	int cnt=0,r=100+t;
	for(int i=1;i<=100+t;i++)if(!vis[i])c[++cnt]=i;
//	for(int i=1;i<=cnt;i++)printf("%lld ",c[i]);
//	int ans=n/cnt*r+c[n%cnt];
//	printf("%lld",ans);
	int ans=0;
	if(n%cnt==0)ans=(n/cnt-1)*r+c[cnt];
	else ans=n/cnt*r+c[n%cnt];
	printf("%lld",ans);
	return 0;
}

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

int main() {
  double t,N;
  cin >>t>>N;
  // cout << "------------" << endl;
  //double ans = (((100+t)*N+1)/t-1);
  double ans = (N*100/t)*((100+t)/100);
  cout << std::fixed << std::setprecision(0) << ceil(((100+t)*N)/t-1) << endl;
}