#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, p, b=0; cin >> N; int A[200001]={};
REP(i, N){
  cin >> p; A[p]=1;
  for(int j=b; j<=200000; j++){ if(A[j]==0){ cout << j << "\n"; b=j; break; } }
  }
}

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

    using namespace std;
    using namespace __gnu_pbds;

    #define endl "\n" //interactive
    #define fi first
    #define se second
    #define pb push_back
    #define int long long
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    typedef vector<int> vi;

    #define read(t) ll t;cin>>t;
    #define all(value) value.begin(),value.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define F(i,n) for(ll i=0;i<n;i++)

    #define deb(value) cerr << #value << " is =" << value << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;

    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset; // store ind on sec
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1; // decreasing
   /* member functions :
                1. order_of_key(k) : number of elements strictly lesser than k
                2. find_by_order(k) : k-th element in the set (counting from zero)*/

    //a.erase(unique(a.begin(),a.end()),a.end());

    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

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

    long long binpow(int a,int b,int m)
    {
        a %= m;int res = 1;
        while (b > 0)
        {
            if (b & 1)res=(res*a)%m;
            a=(a*a)%m  ;    b/=2;
        }
        return res;
    }
    int modinv(int n,int m) {return binpow(n,m-2,m);}

    const int man=2e5+5;

/*

    $ don't apply unnecessary operations
    $ do check boundary cases (i==1/n-1/n)

    $ change approach / use pen ? paper
    $ Don't stuck! :- * re-solve
                      * check for another sol
                      * check function , cal

*/
/*......................................................................................................................*/

void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int a=(2*i)%n;
        if(a==0)a=n;
        int b=(2*i+1)%n;
        if(b==0)b=n;
        cout<<a<<" "<<b<<endl;
    }

}

signed main()
{
    fast;

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

    return 0;
}


#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
#include <cmath>
#include <map>
#include <utility>
#define ll long long
using namespace std;

int mul(int n){
  int ans = 1;
  for(int i = 0;i < n;i ++)ans *= 2;
  return ans;
}

int main(){
  int num,mem;
  cin >> num;
  cin >> mem;
  vector<vector<int>> sat(mem,vector<int>(2));
  for(int i = 0;i < mem;i ++){
    for(int j = 0;j < 2;j ++){
      int a;
      cin >> a;
      sat[i][j] = a-1;
    }
  }
  int pep;
  cin >> pep;
  vector<vector<int>> loc(pep,vector<int>(2));
  for(int i = 0;i < pep;i ++){
    for(int j = 0;j < 2;j ++){
      int a;
      cin >> a;
      loc[i][j] = a-1;
    }
  }
  int ans = 0;
  for(int i = 0;i < mul(pep);i ++){
    vector<int> dish(num,0);
    for(int j = 0;j < pep;j ++){
      int f = (i/mul(j)) % 2;
      dish[loc[j][f]] = 1;
    }
    int sum = 0;
    for(int j = 0;j < mem;j ++){
      if(dish[sat[j][0]] == 1 and dish[sat[j][1]] == 1) sum++;
    }
    if(sum > ans)ans = sum;
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define itn int
#define fi first
#define se second
signed  main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  int a[105][105],sum=0,m;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(i==0&&j==0) m=a[i][j];
    }
  }
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) m=min(m,a[i][j]);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      sum+=(a[i][j]-m);
    }
  }
  cout<<sum<<"\n";
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define yes "Yes"
#define no "No"
#define rep(i, n) for( int i=0; i<(n); i++)
const long long INF = 1LL << 60;

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i,n) rep(j,n) cin >> a[i][j];
    int L = (k*k/2)+1;

    ll wa=-1, ac = 1001001000;
    while (wa+1 < ac)
    {
        ll wj = (wa + ac)/2;
        bool ok = false;
        vector<vector<int>> s((n+1), vector<int>(n+1));
        rep(i, n) rep(j ,n) s[i+1][j+1] = a[i][j]>wj?1:0;
        rep(i, n+1) rep(j, n) s[i][j+1] += s[i][j];
        rep(i, n) rep(j, n+1) s[i+1][j] += s[i][j];
        rep(i, n-k+1)rep(j, n-k+1){
            int now=s[i+k][j+k];
            now -= s[i][j+k];
            now -= s[i+k][j];
            now += s[i][j];
            if(now < L) ok = true;
        }
        if(ok) ac = wj; else wa = wj;
    }

    cout << ac << endl;
}

#include<bits/stdc++.h>
using namespace std;
const int N=3000;
int n,k;
int a[N][N],sum[N][N];
bool check(int x)
{
	memset(sum,0,sizeof sum);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];

			if(a[i][j]<=x) sum[i][j]--;
			else sum[i][j]++;
		}
	}

	for(int i=k;i<=n;i++)
	{
		for(int j=k;j<=n;j++)
		{
			if(sum[i][j]-sum[i-k][j]-sum[i][j-k]+sum[i-k][j-k]<=0) return true;
		}

	 }

	 return false;

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

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int l =0,r=1e9;
	while(l<r)
	{
		int mid = l+r>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}

	printf("%d\n",r);
 }


// Why Stop Now...
#include "bits/stdc++.h"
using ll = long long;
using namespace std;
#define el "\n"
#define n_l "\n"
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); }
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
clock_t time_p=clock();
void TLL() {
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

template<typename T>
void print(T v){
  for(auto i:v){
    cout<<i<<" ";
  }
  cout<<el;
}

int main(){
int t=1; //cin>>t;
while (t--){
    string a,b; cin>>a>>b;
    ll x1=0,x2=0;
    for(auto i:a) x1+=i-'0';
    for(auto i:b) x2+=i-'0';
    cout<<max(x1,x2)<<el;

}

}

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

int dp[1<<18];
int n,m;
int edge[20];

void init(){
	for(int i=0;i<n;i++)
		edge[i] = edge[i] | (1<<i);
}

int main(){
	cin>>n>>m;
	init();
	while(m--){
		int a,b,a1,b1;
		cin>>a>>b;
		a1=a-1 ,b1=b-1;        //二进制从 0 开始 ,点的序列号改为:0~n-1
		edge[a1] = edge[a1] | (1<<b1);  //将 b-1位改成 1
		edge[b1] = edge[b1] | (1<<a1);
	}

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

	dp[0] = 0;

	for(int state = 1; state < (1<<n) ; state++){
		//判定集合state是否是完全图
		int complete = 1;
		for(int j=0;j<n;j++){
			if( state>>j&1 && (edge[j]&state) != state){
				complete = 0;
			}
		}

		//完全图，则强连通分量为 1
		if(complete) dp[state] = 1;

		//枚举当前集合的所有子集
		//state二进制位上为 0的，j该位必须为 0
		for(int j=state; j>0; j=(j-1)&state){
			dp[state] = min(dp[state] , dp[state-j]+dp[j]);
		}
	}

	cout<<dp[(1<<n)-1]<<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;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N, A[205], mem[205][205][205][2][2][2];

bool dp(int n, int a, int b, bool c, bool d, bool e) {
	if (n == 0) return a == b && c && d && e;
	if (mem[n][a][b][c][d][e] != -1) return mem[n][a][b][c][d][e];
	mem[n][a][b][c][d][e] = (dp(n - 1, (a + A[n]) % 200, b, 1, d, 1) || dp(n - 1, a, (b + A[n]) % 200, c, 1, 1) || dp(n - 1, a, b, c, d, e) || dp(n - 1, (a + A[n]) % 200, (b + A[n]) % 200, 1, 1, e));
	return mem[n][a][b][c][d][e];
}

main() {
	memset(mem, -1, sizeof mem);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		A[i] %= 200;
	}
	if (dp(N, 0, 0, 0, 0, 0)) {
		cout << "Yes\n";
		vector<int> fst, snd;
		for (int a = N, b = 0, c = 0, d = 0, e = 0, f = 0; a; ) {
			if (dp(a - 1, (b + A[a]) % 200, c, 1, e, 1)) {
				fst.pb(a);
				b = (b + A[a]) % 200;
				a--;
				d = f = 1;
			} else if (dp(a - 1, b, (c + A[a]) % 200, d, 1, 1)) {
				snd.pb(a);
				c = (c + A[a]) % 200;
				a--;
				e = f = 1;
			} else if (dp(a - 1, b, c, d, e, f)) {
				a--;
			} else {
				assert(dp(a - 1, (b + A[a]) % 200, (c + A[a]) % 200, 1, 1, f));
				snd.pb(a);
				fst.pb(a);
				b = (b + A[a]) % 200;
				c = (c + A[a]) % 200;
				a--;
				d = e = 1;
			}
		}
		sort(fst.begin(), fst.end());
		sort(snd.begin(), snd.end());
		cout << fst.size() << ' ';
		for (int i : fst) cout << i << ' ';
		cout << '\n';
		cout << snd.size() << ' ';
		for (int i : snd) cout << i << ' ';
		cout << '\n';
	} else {
		cout << "No\n";
	}
}

#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define pii pair<int, int>
#define lson (o << 1)
#define rson (o << 1 | 1)
#define mp make_pair
#define fi first
#define se second
using namespace std;
template <class T> T gi() {
    T x = 0; bool f = 0; char c = getchar();
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    if (c == '-') f = 1, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f ? -x : x;
}
const int N = 5010, Mod = 998244353;
void pls(int &x, int y) { x += y; if (x >= Mod) x -= Mod; }
int fpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % Mod)
		if (b & 1) res = 1ll * res * a % Mod;
	return res;
}
int pw[N];
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>(), m = gi<int>();
	int ans = 1ll * fpow(m, n) * n % Mod;
	pw[0] = 1; for (int i = 1; i <= n; i++) pw[i] = 1ll * pw[i - 1] * m % Mod;
	for (int j = 1; j <= m; j++)
		for (int i = 0, t = 1; i <= n - 2; i++, t = 1ll * t * (m - j) % Mod)
			pls(ans, Mod - 1ll * (n - i - 1) * t % Mod * pw[n - i - 2] % Mod);
	printf("%d\n", ans);
	return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 505
#define ll long long
#define mo 998244353
using namespace std;

int n,m,i,j,k,a[maxn][maxn],c[3];

int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		char ch=getchar();
		while (ch!='R'&&ch!='B'&&ch!='.') ch=getchar();
		for(j=1;j<=m;j++) a[i][j]=(ch=='.')?0:((ch=='R')?1:2),ch=getchar();
	}
	ll ans=1;
	for(i=2;i<=n+m;i++){
		c[0]=c[1]=c[2]=0;
		for(j=1;j<i;j++) if (j>=1&&j<=n&&i-j>=1&&i-j<=m)
			c[a[j][i-j]]++;
		if (c[1]&&c[2]) printf("0\n"),exit(0);
		if (!c[1]&&!c[2]) ans=ans*2%mo;
	}
	printf("%lld\n",ans);
}

//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int gcd(int x, int y) {
    int m = min(x, y);
    for(int d=m; d>0; d--) {
        if(x % d == 0 && y % d == 0) {
            return d;
        }
    }
}

signed main(){
    //小数の桁数の出力指定
    //cout<<fixed<<setprecision(10);
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int  n,max,maxnum;
    std::vector<int> a(100),b(1000,0);
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    max = 0;
    maxnum = 2;
    FOR(i,2,1000){
        REP(j,n){
            if(a[j]>=i){
                if(a[j]%i==0){
                    b[i]++;
                }
            }
        }
        if(max<b[i]){
            max = b[i];
            maxnum = i;
        }
    }
    cout << maxnum << endl;
    return 0;
}


#include <iostream>
#define ll long long int
#define MN (int)200100
using namespace std;
ll md = 998244353;

ll ncr[MN+2][55];
ll minP[MN+2];
ll sol[MN+2];

int main(){
	minP[1] = 1;
	//eratosten;
	for(int i=2; i<MN; i++)
		if(!minP[i]) for(int j=1; j*i<MN; j++) if(!minP[i*j]) minP[i*j]=i;

	//ncr
	for(int i=1; i<MN; i++)
		for(int j=0; j <=min(i, 55); j++){
			if(j==0 or j==i) ncr[i][j] = 1;
			else ncr[i][j] = (ll)(ncr[i-1][j] + ncr[i-1][j-1]) % md;
		}

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

	sol[1] = 1;
	for(ll i=2; i<MN; i++){
		sol[i] = 1;

		ll ii = i;
		while(ii > 1){
			ll j = 0;
			ll p = minP[ii];
			while(ii%p==0) ii/=p, j++;
			sol[i] *= ncr[n - 2 + j][j];
			sol[i] = sol[i] % md;
		}

		sol[i] = (sol[i]+sol[i-1]) % md;
	}

	ll ans = 0;
	for(int i=1; i<=m; i++){
		int max = m/i;
		ans = ans + sol[max];
		ans = ans % md;
	}

	cout << ans << endl;
}

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

typedef long long ll;

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

#define mp make_pair
#define fr first
#define sc second

int lg(ll n) {
    assert(n > 0);
    int ans = -1;
    while (n) {
        ans++;
        n >>= 1;
    }
    return ans;
}

void solve() {
    int A, B;
    cin >> A >> B;
    if (A > B)
        B--;
    else
        A--;
    for (int i = 0; i < A; i++) {
        cout << i + 1 << ' ';
    }
    for (int i = 0; i < B; i++) {
        cout << -(i + 1) << ' ';
    }
    cout << (B * (B + 1) - A * (A + 1)) / 2 << '\n';
}

int main() {
    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

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

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	double A, B; cin >> A >> B;
	cout.precision(10);
	cout << A * B * 0.01 << "\n";
}

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int A, B;

int main(int argc, const char * argv[]) {
    // insert code here...
    scanf("%d %d", &A, &B);

    double ans = (double)(A * B) / 100;

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


#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<ll> w(n);
    ll max_w = 0LL;
    for(int i=0;i<n;++i) {
        cin >> w[i];
        max_w = max(max_w, w[i]);
    }

    vector<Pll> wl(m); // {重さ制限, 長さ}
    ll min_lim_w = LINF;
    for(int i=0;i<m;++i) {
        cin >> wl[i].second >> wl[i].first;
        min_lim_w = min(min_lim_w, wl[i].first);
    }
    sort(wl.begin(), wl.end());

    if(max_w > min_lim_w) {
        cout << -1 << endl;
        return 0;
    }

    set<Pll> st; // {長さ, 重さ制限}
    set<Pll> st2; // {重さ制限, 長さ}
    // 重さ制限はは今見てる奴が1番緩いはずなので、今まで見た長さで最長だった場合だけ入れる。
    st.emplace(wl[0].second, wl[0].first);
    st2.insert(wl[0]);
    for(int i=1;i<m;++i) {
        if(wl[i].second <= 0LL) continue;
        ll l_max = st.rbegin()->first;
        if(l_max < wl[i].second) {
            st.emplace(wl[i].second, wl[i].first);
            st2.insert(wl[i]);
        }
    }

    vector<int> v(n);
    for(int i=0;i<n;++i) v[i] = i;

    ll ans = LINF;
    do {
        vector<ll> ws(n+1, 0LL);
        ws[0] = 0LL;
        for(int i=0;i<n;++i) {
            ws[i+1] = ws[i] + w[v[i]];
        }

        vector<ll> xs(n, -1LL);
        xs[0] = 0LL;
        for(int i=1;i<n;++i) {
            ll ng = xs[i-1]-1LL, ok = LINF;
            while(ok - ng > 1LL) {
                ll mid = (ok + ng) / 2;
                bool isok = true;
                for(int j=0;j<i;++j) {
                    auto itr = st.lower_bound(Pll(mid - xs[j] + 1, -LINF));
                    if(itr == st.end()) continue;
                    if(ws[i+1] - ws[j] > (itr->second)) {
                        isok = false;
                        break;
                    }
                }
                if(isok) {
                    ok = mid;
                } else {
                    ng = mid;
                }
            }
            xs[i] = ok;
        }
        // for(int i=0;i<n-1;++i) cerr << xs[i] << " ";
        // cerr << xs[n-1] << endl;
        ans = min(ans, xs[n-1]);
    } while(next_permutation(v.begin(), v.end()));

    cout << ans << endl;
}

// First of all Naste "_"
// Always check the fast IO is there or not
// always write functions for little things coz u repeat the variables

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

typedef long long int ll;

#define endline '\n'
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define pb push_back
#define fr(i,a,b) for(ll i=a;i<(ll)b;i++)
#define rfr(i,a,b) for(int i=a;i>=(int)b;i--)
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
const int N = 29;
const ll mod=1e9+7;

ll mod_exp(ll x,ll y)
{
    if(y<=0)
        return(1);
    else if(y%2==0)
        return(mod_exp((x*x),y/2));
    else
        return((x*mod_exp((x*x),(y-1)/2)));
}

int visi[N];
vi v[N];
int col[N];
int lvl[N];
int dfs(int node)
{
	visi[node]=1;
	int ans1=1;
	for(int it:v[node])
	{
		if(lvl[it]!=0&&lvl[it]!=lvl[node]+1)
		{
			if(col[it]==col[node])
			{
				ans1=0;
			}
			continue;
		}
		lvl[it]=lvl[node]+1;
		ll temp=0;
		fr(i,1,4)
		{
			if(i!=col[node])
			{
				col[it]=i;
				temp+=dfs(it);
				col[it]=0;
			}
		}
		ans1*=temp;
	}
	return ans1;
}
void clear()
{
	fr(i,0,N)
	{
		v[i].clear();
		visi[i]=0;
		col[i]=0;
		lvl[i]=0;
	}
}
int main()
{
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    // freopen("debug.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
    	clear();
    	int n,m; cin>>n>>m;
    	if(m==0)
    	{
    		cout<<mod_exp(3,n);
    		return 0;
    	}
    	while(m--)
    	{
    		int x,y; cin>>x>>y;
    		v[x].pb(y),v[y].pb(x);
    	}
    	// ll c=0;
    	ll ans=1;
    	fr(i,1,n+1)
    	{
    		if(visi[i]==0)
    		{
    			col[i]=1;lvl[i]=1;
    			ans*=3*dfs(i);
    		}
    	}
    	cout<<ans<<endline;
    }

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

}


/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com
	> Blog: https://blog.csdn.net/Pig_cfbsl
	> Created Time: 2020/10/11 22:45:26
 ************************************************************************/
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define pb push_back
#define pr pair<int,int>
#define fi first
#define se second
#define LL long long
#define mk(a,b) make_pair(a,b)
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=1e5+10;
int n,m,sum=0,cnt=0,mx;
int w[10],tmp[10],s[10],dis[10],v[maxx],l[maxx];
int p[10]={0,1,2,3,4,5,6,7,8};
pr a[maxx];
bool cmp(pr x,pr y){
	if(x.fi!=y.fi) return x.fi<y.fi;
	return x.se>y.se;
}
int iso(int x){
	x=lower_bound(v+1,v+cnt+1,x)-v-1;
	return l[x];
}
int solve(){
	s[0]=0;
	For(i,1,n){ tmp[i]=w[p[i]]; s[i]=s[i-1]+tmp[i];  dis[i]=0;}
	For(i,2,n) For(j,1,i-1) dis[i]=max(dis[i],dis[j]+iso(s[i]-s[j-1]));
//	cout<<dis[3]<<endl;
	return dis[n];
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int u1,u2;
	n=read(); m=read();
	For(i,1,n){ w[i]=read(); mx=max(w[i],mx);}
	For(i,1,m){
		u1=read(); u2=read();
		a[i]=mk(u2,u1);
		if(u2<mx){ printf("-1\n"); return 0; }
	}
	sort(a+1,a+m+1,cmp);
	v[++cnt]=a[1].fi; l[cnt]=a[1].se;
	For(i,2,m)
		if(a[i].se>l[cnt]){
			v[++cnt]=a[i].fi;
			l[cnt]=a[i].se;
		}
	int ans=1e9;
	do{
		ans=min(ans,solve());
//		return 0;
	}while(next_permutation(p+1,p+n+1));
	printf("%d\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

vector<vector<P>> g;
ll a[100 * 100], b[100 * 100];
bool use[100 * 100], ans[100 * 100], usev[100];

void dfs(ll at){
    usev[at] = true;

    zep(i, 0, g[at].size()){
        auto nx = g[at][i];
        if(!usev[nx.first]){
            if(!use[nx.second]){
                use[nx.second] = true;
                ans[nx.second] = (a[nx.second] == at);
            }
            dfs(nx.first);
        }else{
            if(!use[nx.second]){
                use[nx.second] = true;
                ans[nx.second] = (a[nx.second] == at);
            }
        }
    }
}

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

    ll n, m; cin >> n >> m;
    zep(j, 0, m){cin >> a[j] >> b[j]; a[j]--; b[j]--;}
    ll c[n]; zep(i, 0, n)cin >> c[i];

    g.resize(n);
    zep(j, 0, m){
        if(c[a[j]] > c[b[j]]){
            ans[j] = true;
        }else if(c[a[j]] < c[b[j]]){
            ans[j] = false;
        }else{
            g[a[j]].push_back(P(b[j], j));
            g[b[j]].push_back(P(a[j], j));
        }
    }

    zep(i, 0, n)dfs(i);

    zep(j, 0, m){
        print(ans[j]? "->" : "<-")
    }

    return 0;
}


//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
//#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <random>
#include<iomanip>
#include <cassert>
#include <cstring>
#include <sstream>
#include <complex>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

//debug..........
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

//............ignore it..................//
#define F first
#define S second
#define Pi atan(1)*4
#define mp make_pair
#define pb  push_back
const int M	= 1e9 + 7;
#define ld  long double
#define ll  long long int
#define happy cin.tie(0);
#define point(x) cout<<fixed<<setprecision(x)
int length(string s){return (int)s.size();}
#define mem(a)  memset(a , 0 ,sizeof a)
#define memn(a) memset(a , -1 ,sizeof a)
#define coding ios::sync_with_stdio(false);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

int length(long long x){int l = 0;for(long long i=x;i;i/=10)l++;return l;}
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};

#define rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))

long long Inv_pow(long long a,long long n){ll res = 1;while(n){if(n&1) res = ((res%M)*(a%M))%M;a = ((a%M)*(a%M))%M;n>>=1;}return res%M;}
// suffix_prefix....
std::vector<ll> prefix_sum(std::vector<ll> a){int n = a.size();std::vector<ll> prf(n,0);for(int i=0;i<n;i++){
if(i == 0){prf[i] = a[i];}else{prf[i] = prf[i-1]+a[i];}}return prf;}
std::vector<ll> suffix_sum(std::vector<ll> a){int n = a.size();std::vector<ll>suf(n,0);for(int i=n-1;i>=0;i--){
if(i == n-1){suf[i] = a[i];}else{suf[i] = suf[i+1]+a[i];}}return suf;}

long long Lcm(long long a,long long b){return (((a)*(b)))/__gcd(a,b);}

#define Test cout<<"Case #"<<tc++<<": ";
int tc = 1;

inline void read(std::vector<int> &v){for(int i=0;i<(int)v.size();i++){cin>>(v[i]);}}
inline void readl(std::vector<ll> &v){for(int i=0;i<(int)v.size();i++){cin>>(v[i]);}}

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

inline void read(int v[],int n){for(int i=0;i<n;i++){cin>>(v[i]);}}
inline void readl(ll v[],int n){for(int i=0;i<n;i++){cin>>(v[i]);}}

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (ll)a * b % mod ;}

#define   pr 	pair<int, int>
#define   vpr 	vector<pr>
#define   vi   	std::vector<int>
#define   vll  	std::vector<ll>
#define   all(n) n.begin(),n.end()

const int Inf           = (int)2e9 + 5;
const ll  Lnf           = (ll)2e18 + 5;
const int N             = 5e5 + 5;
const int NN            = 1e6 + 5;

int solve()
{

	//Test

	int a[3];
	cin>>a[0]>>a[1]>>a[2];

	sort(a,a+3);

	if((a[0]+a[2]) == 2*a[1]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
	//error();
}
int main(){

	happy coding
	int test = 1;
	//cin>>test;
	while (test--)solve();return 0;
}

/*
Age doesn't make you mature Responsibility makes.
*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define powr(x,n,p) for(int axy=0 ; axy<p ; axy++){x=x*n;}
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nl printf("\n")
#define fr0(n,q) for(q=0 ; q<n ; q++)
#define fr1(n,q) for(q=1 ; q<=n ; q++)
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define lst(x) x[x.size()-1]
#define llst(x) x[x.size()-2]
#define md 1000000007
#define check(x,y) (x&(1LL<<y))
#define set(x,y) x=x|(1<<y)
#define pi acos(-1)
#define inf (1<<30)
#include <stdio.h>
using namespace std;
vector < pair<int,int> > sum[5000005];
vector <set<int>> st;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,k,i,j;
    cin>>n>>m>>k;
    vector < pair<int,int> > arr;
    fr0(n,i){
        int x,y;
        cin>>x>>y;
        arr.pb({y,x});
    }
    sort(arr.begin(),arr.end());
    reverse(arr.begin(),arr.end());
    int box[m+1];
    for(i=1 ; i<=m ; i++) cin>>box[i];
    while(k--){
        int l,r;
        cin>>l>>r;
        multiset <int> tmp;
        for(i=1 ; i<=m ; i++){
            if(i>=l && i<=r) continue;
            tmp.insert(box[i]);
        }
        //sort(tmp.begin(),tmp.end());
        int ans=0;
        for(i=0 ; i<n ; i++){
            auto it=tmp.lower_bound(arr[i].second);
            if(it==tmp.end()) continue;
            ans+=arr[i].first;
            tmp.erase(it);
        }
        cout<<ans;
        nl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
#define num_l(a,v) POSL(a,v) //v未満の要素数
#define num_eql(a,v) POSU(a,v) //v以下の要素数
#define num_h(a,v) (a.size() - POSU(a,v)) //vより大きい要素数
#define num_eqh(a,v) (a.size() - POSL(a,v)) //v以上の要素数
// static_cast< long long ll >

int main(){

	ll H,W,X,Y;
	cin >> H >> W >> X >> Y;
	X--;Y--;

	vector<string> S(H);
	FOR(i,0,H){
		cin >> S[i];
	}

	ll ans = 0;
	for(int h = X; h>=0;h--){
		if(S[h][Y] == '#')break;
		ans++;
	}
	for(int h = X+1; h<H;h++){
		if(S[h][Y] == '#')break;
		ans++;
	}

	for(int w = Y-1; w>=0;w--){
		if(S[X][w] == '#')break;
		ans++;
	}

	for(int w = Y+1; w<W;w++){
		if(S[X][w] == '#')break;
		ans++;
	}

	cout << ans << endl;

}

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

template<int M>
struct static_mint {
	static_assert(0 < M, "Module must be positive");

	int val;

	static_mint() : val() {}

	static_mint(long long x) : val(x % M) { if (val < 0) val += M; }

	static_mint pow(long long n) const {
		static_mint ans = 1, x(*this);
		for (; n > 0; n /= 2) {
			if (n & 1) ans *= x;
			x *= x;
		}
		return ans;
	}

	static_mint inv() const {
		return pow(M - 2);
	}

	static_mint operator+() const {
		static_mint m;
		m.val = val;
		return m;
	}

	static_mint operator-() const {
		static_mint m;
		m.val = (val == 0 ? 0 : M - val);
		return m;
	}

	static_mint &operator+=(const static_mint &m) {
		if ((val += m.val) >= M) val -= M;
		return *this;
	}

	static_mint &operator-=(const static_mint &m) {
		if ((val -= m.val) < 0) val += M;
		return *this;
	}

	static_mint &operator*=(const static_mint &m) {
		val = (long long) val * m.val % M;
		return *this;
	}

	static_mint &operator/=(const static_mint &m) {
		val = (long long) val * m.inv().val % M;
		return *this;
	}

	friend static_mint operator+(const static_mint &lhs, const static_mint &rhs) {
		return static_mint(lhs) += rhs;
	}

	friend static_mint operator-(const static_mint &lhs, const static_mint &rhs) {
		return static_mint(lhs) -= rhs;
	}

	friend static_mint operator*(const static_mint &lhs, const static_mint &rhs) {
		return static_mint(lhs) *= rhs;
	}

	friend static_mint operator/(const static_mint &lhs, const static_mint &rhs) {
		return static_mint(lhs) /= rhs;
	}

	friend bool operator==(const static_mint &lhs, const static_mint &rhs) {
		return lhs.val == rhs.val;
	}

	friend bool operator!=(const static_mint &lhs, const static_mint &rhs) {
		return lhs.val != rhs.val;
	}

	static_mint &operator++() {
		return *this += 1;
	}

	static_mint &operator--() {
		return *this -= 1;
	}

	static_mint operator++(int) {
		static_mint result(*this);
		*this += 1;
		return result;
	}

	static_mint operator--(int) {
		static_mint result(*this);
		*this -= 1;
		return result;
	}

	template<typename T>
	explicit operator T() const {
		return T(val);
	}

	friend std::ostream &operator<<(std::ostream &os, const static_mint &m) {
		return os << m.val;
	}

	friend std::istream &operator>>(std::istream &is, static_mint &m) {
		long long x;
		return is >> x, m = x, is;
	}
};

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

	using mint = static_mint<1000000007>;

	int n;
	cin >> n;

	vector<long long> a(n);
	for (auto &x : a) cin >> x;

	vector<mint> dp(n + 1);
	dp[0] = 1;

	mint ans = 0;
	for (int i = 1; i <= n; i++) {
		vector<mint> new_dp(n + 1), sum_dp(i);

		long long sum = 0;
		sum_dp[0] = dp[0];
		for (int j = 1; j <= n; j++) {
			sum += a[j - 1];
			new_dp[j] = sum_dp[sum % i];
			sum_dp[sum % i] += dp[j];
		}
		dp.swap(new_dp);
		ans += dp.back();
	}
	cout << ans << '\n';
	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;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = -1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]); //経路圧縮
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        // 要素数を片寄する
        int sx = par[rx];
        int sy = par[ry];

        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        par[ry] = sx + sy;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { // データxが属する木の根の要素数
		return -par[root(x)];
	}
};

int main(){
  int N;
  cin >> N;
  vll A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vll B,C;

  ll M = N;
  if(M % 2 == 1) M = (M - 1) /2;
  else M /= 2;
  B.resize(M);
  C.resize(M);

  set<ll> S;

  repll(i, M){
    B[i] = A[i];
    C[i] = A[N - 1 - i];
    if(B[i] != C[i]) {
      S.insert(B[i]);
      S.insert(C[i]);
    }
  }

  map<ll, ll> bcmap;
  ll cnt = 0;
  fore(x, S) {
    bcmap[x] = cnt;
    cnt++;
  }

  ll size = S.size();
  UnionFind uf(size);
  repll(i, M){
    if(B[i] != C[i]){
      uf.unite(bcmap[B[i]], bcmap[C[i]]);
    }
  }

  map<ll, ll> rmap;
  set<ll> root;
  repll(i, size){
    rmap[uf.root(i)]++;
    root.insert(uf.root(i));
  }

  ll ans = 0;
  fore(x, root) {
    ans += rmap[x] - 1;
  }

  cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define int long long int
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vpi vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define inf 1e18
#define ff first
#define ss  second
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(x) x.begin(),x.end()
#define endl "\n"
const int maxn = 1e5;
void runcases(int T)
{

     int n;
     cin >> n;
     string s;
     cin >> s;
     vi v(2 * n, 0);
     for (int i = 0; i < 2 * n; i++) {
          v[i] = i;
     }
     int q;
     cin >> q;
     int cnt = 0;
     for (int i = 0; i < q; i++) {
          int t, a, b;
          cin >> t;
          if (t == 1)
          {    cin >> a >> b;
               a--;
               b--;
               if (cnt)
               {
                    if (a + n >= 2 * n)
                    {
                         a -= n;
                    } else {
                         a += n;
                    }
                    if (b + n >= 2 * n)
                    {
                         b -= n;
                    } else {
                         b += n;
                    }

               }
               swap(v[a], v[b]);

          } else if (t == 2)
          {
               cin >> a >> b;
               cnt = (cnt + 1) % 2;
          }
     }

     // fo
     string s1, s2;

     for (int i = 0; i < n; i++)
     {
          s1.push_back(s[v[i]]);
     }
     for (int i = n; i < 2 * n; i++)
     {
          s2.push_back(s[v[i]]);
     }
     if (cnt)
     {
          cout << s2 << s1 << endl;
     } else cout << s1 << s2 << endl;

     //cout<<"Case #"<<T<<": ";
}

int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int T = 1;
     //cin >> T;
     for (int t = 1; t <= T; t++) {
          runcases(t);
     }

     return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define rep(i,n) for(int i=0;i<(n);i++)
#define drep(i,n) for(int i=(n)-1;i>=0;i--)
template<class T> void print(vec<T>& v){rep(i,v.size()) cout << v[i] << (i+1!=(int) v.size()? " ":"\n");}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int M = 200;
    vec<ll> cnt(M);
    rep(i,N){
        int a;
        cin >> a;
        cnt[a%200]++;
    }
    ll ans = 0;
    rep(i,M) ans += cnt[i]*(cnt[i]-1)/2;
    cout << ans << "\n";
}

#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int MOD2 = 998'244'353;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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

int main(){
    int N; std::cin >> N;
    for(int i(0); i < N; ++i){
        int a(2*i % N + 1), b((2*i+1) % N + 1);
        std::cout << a << " " << b << "\n";
    }
    return 0;
}


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

int k;
int n;
string s;

const int mod = 1e9 + 7;
inline int ch2dig(char ch)
{
    if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10;
    return ch - '0';
}

const int N = 2e5 + 10;
LL dp[N][20];
LL cnt[N];

LL dfs(int pos, int st, bool bound, bool zeros)
{
    if (pos == -1) return __builtin_popcount(st) == k;

    LL ret = 0;
    if (bound && zeros)
    {
        int ed = bound ? ch2dig(s[pos]) : 15;
        for (int i = 0; i <= ed; i++)
        {
            int new_st = st;
            if (i) new_st |= (1 << i);

            ret += dfs(pos - 1, new_st, bound && i == ed, zeros && i == 0);
            ret %= mod;
        }
        debug(pos, st, bound, zeros, ret);
        return ret;
    }

    if (bound && !zeros)
    {
        int ed = bound ? ch2dig(s[pos]) : 15;
        for (int i = 0; i <= ed; i++)
        {
            int new_st = st | (1 << i);

            ret += dfs(pos - 1, new_st, bound && i == ed, 0);
            ret %= mod;
        }
        debug(pos, st, bound, zeros, ret);
        return ret;
    }

    if (!bound && zeros)
    {
        for (int i = 0; i <= 15; i++)
        {
            int new_st = st;
            if (i) new_st |= (1 << i);

            ret += dfs(pos - 1, new_st, 0, zeros && i == 0);
            ret %= mod;
        }
        debug(pos, st, bound, zeros, ret);
        return ret;
    }

    if (dp[pos][__builtin_popcount(st)] != -1) return dp[pos][__builtin_popcount(st)];
    if (!bound && !zeros)
    {
        for (int i = 0; i <= 15; i++)
        {
            int new_st = st | (1 << i);

            ret += dfs(pos - 1, new_st, 0, 0);
            ret %= mod;
        }
    }
    debug(pos, st, bound, zeros, ret);
    return dp[pos][__builtin_popcount(st)] = ret;
}

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

    while (cin >> s >> k)
    {
        clr(dp, -1);
        n = sz(s);
        reverse(all(s));

        LL ans = dfs(n - 1, 0, 1, 1);
        cout << ans << endl;
    }

    return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)

const int P = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int N = 3e6 + 10;

int main()
{
	IOS;
	int n;
	string str;
	vector<int> v;
	cin >> str >> n;

	for(auto x : str)
		if(x >= '0' && x <= '9') v.push_back((int)(x - '0'));
		else v.push_back((int)(10 + x - 'A'));

	vector<vector<int> > f(str.size() + 1, vector<int>(18, 0));

	int state = 0;
	for(int i = 0; i < (int)str.size(); ++ i)
	{
		for(int j = 1; j <= 16; ++ j)
		{
			f[i + 1][j] = (f[i + 1][j] + (LL)f[i][j] * j % P) % P;
			f[i + 1][j + 1] = (f[i + 1][j + 1] + (LL)f[i][j] * (16 - j) % P) % P;
		}
		f[i + 1][1] = (f[i + 1][1] + (LL)f[i][0] * 15 % P) % P;
		f[i + 1][0] = (f[i + 1][0] + f[i][0]) % P;
		for(int j = 0; j < v[i]; ++ j)
		{
			int nstate = state;
			if(i || j) nstate |= (1 << j);
			f[i + 1][__builtin_popcount(nstate)] += 1;
		}
		state |= (1 << v[i]);
	}

	int res = f[str.size()][n] + (__builtin_popcount(state) == n);
	cout << res << endl;

	return 0;
}


/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';

ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}

void solve(){
    //clock_t time;
    ll n; cin>>n;
    vll v(n);
    for(ll &i: v)cin>>i;
    ll md=0;
    for(ll i: v) md+=abs(i);
    ll ed=0;
    for(ll i: v) ed+=(i*i);
    ll cd=INT_MIN;
    for(ll i=0; i<n; i++){
        ll tmp=abs(v[i]);
        cd=max(cd, tmp);
    }
    cout<<md<<nl;
    cout<<sqrt(ed)<<nl;
    cout<<cd;
}

int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(15);

    //int t; cin>>t; while(t--) solve();
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define repe(a, b) for (auto&(a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define mp(a, b) make_pair((a), (b))
#define Push_back(a, b) push_back( mp( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

const int inf = 0x3fffffff;
const int64_t INF = 0x3fffffffffffffff;
const int64_t MOD = 1e9+7;

int main() {
    int64_t n;
    cin >> n;
    std::vector<int64_t> x(n);
    int64_t man = 0, t = 0;
    long double euclid = 0;
    rep(i, n) {
        cin >> x[i];
        man += abs(x[i]);
        euclid += abs(x[i])*abs(x[i]);
        chmax(t, abs(x[i]));
    }
    euclid = sqrt(euclid);
    cout << man << endl;
    cout << setprecision(20) << euclid << endl;
    cout << t << endl;
    return 0;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define For(i, a, b) for (ll i = (a); i <= (b); i++)
#define Forx(i, a, b, x) for (ll i = (a); i <= (b); i+=x)
#define debug(x) cout <<" || "<< #x << " is= " << x <<endl; //use for debug
#define read(a) ll a; cin >> a;
#define Ford(i, a, b) for (ll i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define pr         pair<ll,ll>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).size())
#define cut(x) {cout<<x<<"\n"; continue;}
#define setprec(x) cout << fixed << showpoint << setprecision(15)<<x<<"\n";
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl '\n';
#define mod  1000000007
#define mod1 998244353
#define pi 3.141592653589793238
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef tree<pr,null_type,less<pr>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

//*s.find_by_order() ->returns an iterator to the k-th largest element (counting from zero);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
//sort(a+1,a+n+1,[](ll x,ll y){return abs(x)>abs(y);});
//sort(v.begin(), v.end(), greater<int>()); -> not sure work for first also if second are equal;
//q=lower_bound(all(v[a[i]]),i)-v[a[i]].begin()+1;
// s.substr(start_ind,length);
// vpll shift={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}} ->shift operator;
//bool comp(pr a,pr b){return a.second<b.second;} // use for differentiate order of comparision;
// cntbit(x) __builtin_popcount(x); -> no. of bits in given no.;
// true false; memset(dp,-1,sizeof(dp));
// std::random_shuffle(all(vec));

//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
const ll MAXN=1e4+5;
const ll inf=1e18;

int main()
{
  fast_io;
  //“Don’t wish it were easier. Wish you were better.” – Jim Rohn;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  ll n,k; cin>>n>>k;
  ll dp[4][3*n+5];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  // dp[i][j]=valid ways of sum j by choosing i no's. from 1 to n;
  For(j,1,3*n) dp[0][j]+=dp[0][j-1];
  For(i,1,3)
  {
    For(j,1,3*n)
    {
      dp[i][j]=dp[i-1][j-1];
      if(j>n) dp[i][j]-=dp[i-1][j-n-1]; // as limit is n;
    }
    For(j,1,3*n) dp[i][j]+=dp[i][j-1];
  }

  // now we can fix sum for given k;
  ll sum;
  For(i,1,3*n) if(dp[3][i]>=k)
  {
    sum=i;
    break;
  }
  ll a,b,c;
  ll rem=k-dp[3][sum-1];
  For(value,1,n) // now fixing  beauty find rem.;
  {
    ll p=dp[2][sum-value]-dp[2][sum-value-1];
    if(p<rem) rem-=p;
    else
    {
      a=value;
      b=1,c=sum-value-1;
      while(c>n) c--,b++;
      rem--;
      while(rem--)
      {
        b++;
        c--;
      }
      break;
    }
  }
  cout<<a<<' '<<b<<' '<<c;
 }

#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>

using namespace std;
typedef string::const_iterator State;
const long double Ma_PI = 3.1415926535897932384626433832795028841971L;
#define eps 1e-7
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
typedef struct BigInt{
    string s = "0";
    BigInt operator +(BigInt obj) {
        string c;
        while (max(obj.s.length(), this->s.length()) + 1 > c.length()) {
            c.pb('0');
        }
        for (int q = 0; q < obj.s.length(); ++q) {
            c[c.length() - 1 - q] = obj.s[obj.s.length() - q - 1];
        }
        for (int q = 0; q < this->s.length(); ++q) {
            c[c.length() - 1 - q] += this->s[this->s.length() - 1 - q] - '0';
            if (c[c.length() - 1 - q] > '9') {
                c[c.length() - 2 - q]++;
                c[c.length() - 1 - q] -= 10;
            }
        }
        if (c.front() == '0') {
            c.erase(c.begin());
        }
        return BigInt{ c };
    }
    BigInt operator *(BigInt obj) {
        BigInt ans;
        for (int i = this->s.length() - 1; i >= 0; --i) {
            REP(q, this -> s[i] - '0') {
                ans = ans + obj;
            }
            obj.s.pb('0');
        }
        return ans;
    }
}BigInt;

void solve() {
    int n, k, m;
    cin >> n >> k >> m;
    int a = 0;
    REP(i, n - 1) {
        int b;
        cin >> b;
        a += b;
    }
    a = (n) * m - a;
    a = max(a, 0);
    if (a > k) {
        cout << -1 << endl;
    }
    else {
        cout << a << endl;
    }
}

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


#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
set<int> U;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	for(int i=0;i<=200010;i++){
		U.insert(i);
	}
	REP(i,N){
		U.erase(A[i]);
		cout<<*U.begin()<<endl;
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
	ll N, a;
	cin >> N;
	ll sum = 0, mx = 0, add = 0;
	for (ll i = 1; i <= N; i++) {
		cin >> a;
		sum += a;
		mx = max(mx, a);
		cout << sum + i * mx + add << endl;
		add += sum;
	}
}


#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    vector<ll> B(K);
    rep(i, K) {
        B[i] = (double)((ll)A[i] * M) / N;
    }

    ll Bsum = accumulate(all(B), 0LL);
    if (Bsum != M) {
        vector<pair<ll, int>> x(K);
        rep(i, K) {
            x[i] = { abs((ll)B[i] * N - (ll)A[i] * M), i };
        }
        sort(all(x));
        reverse(all(x));
        rep(i, K) {
            B[x[i].second]++;
            Bsum++;
            if (Bsum == M) break;
        }
    }
    rep(i, K) {
        cout << B[i] << (i == K - 1 ? "\n" : " ");
    }
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template <typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++; else
if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << s.substr(0, i) << " = " << x << " | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}

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

    int k;
    long long n, m;
    cin >> k >> n >> m;
    vector<int> a(k);
    for (int i=0; i<k; i++)
        cin >> a[i];

    long long l = 0, r = 2e18;
    while (l < r) {
        long long x = (l + r) / 2, lo = 0, hi = 0;
        for (int i=0; i<k; i++) {
            lo += (max(a[i] * m - x, 0LL) + n - 1) / n;
            hi += (a[i] * m + x) / n;
        }
        if (lo <= m && m <= hi)
            r = x;
        else
            l = x + 1;
    }

    vector<long long> lo(k), hi(k);
    for (int i=0; i<k; i++) {
        lo[i] = (max(a[i] * m - l, 0LL) + n - 1) / n;
        hi[i] = (a[i] * m + l) / n;
    }
    m -= accumulate(lo.begin(), lo.end(), 0LL);
    for (int i=0; i<k; i++) {
        long long change = min(m, hi[i] - lo[i]);
        lo[i] += change;
        m -= change;
        cout << lo[i] << " ";
    }
    cout << "\n";

    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    string s;
    cin >> s;

    reverse(ALL(s));

    string ans = "";
    for (char c : s) {
        // 0 を 0 に、1 を 1 に、6 を 9 に、8 を 8 に、9 を 6 に変換する。
        if (c == '0') ans += "0";
        else if (c == '1') ans += "1";
        else if (c == '6') ans += "9";
        else if (c == '8') ans += "8";
        else if (c == '9') ans += "6";
    }

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

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  for(auto c : s) {
    if(c == '6')      cout << '9';
    else if(c == '9') cout << '6';
    else              cout << c;
  }
  cout << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Pint pair<int,int>
#define Pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
ll modpow(ll a,ll b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    ll memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<ll>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(ll i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
ll inv(ll x){
    x=modpow(x,mod-2);
    return x;
}

int main(){
    int n;
    string t;
    string a="110";
    cin>>n>>t;
    if(n==1){
        if(t=="0")cout<<10000000000<<endl;
        else cout<<20000000000<<endl;
    }
    else{
        int s=0;
        if(t[0]=='0'){
            if(t[1]=='0'){
                cout<<0<<endl;
                return 0;
            }
            else{
                //01
                s=2;
            }
        }
        else{
            if(t[1]=='0'){
                //10
                s=1;
            }
            else{
                //11
                s=0;
            }
        }
        rep(i,n){
            if(a[(s+i)%3]!=t[i]){
                cout<<0<<endl;
                return 0;
            }
        }
        int p=s+n-1;
        p/=3;
        cout<<10000000000ll-p<<endl;
    }
    return 0;
}


#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<chrono>
#include<random>
#include<iterator>
#include<map>
#include<list>
#include<algorithm>
#include<fstream>
#include<unordered_map>
#include<set>
#include<queue>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define FF  first
#define SS  second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define mod 1e9+7
#define all(v) (v).begin(),(v).end()
#define ps(x,y) fixed<<setprecision(y)<<x

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef map<ll,ll> mll;

ll gcd(ll a,ll b){  //gives gcd of a,b (a<b)
  if(a==0)  return b;   //Base Case
  return gcd(b%a,a);
}

ll lcm(ll a,ll b){  //gives lcm of a,b by (a*b)/gcd(a,b)
  return a/gcd(a,b)*b;
}

ll gcd_ext(ll a,ll b,ll&x,ll&y){  //Extended Euclidean Algorithm
  if(a==0){   //Base Case
    x=0;    y=1;
    return b;
  }
  ll x1,y1;   //To store recursive call
  ll gcd=gcd_ext(b%a,a,x1,y1);
  x=y1-(b/a)*x1;    //Updating x,y from recursive call
  y=x1;
  return gcd;
}

ll power_mod(ll a,ll b,ll c=mod){
	ll res=1;
	while(b){
		if(b&1){    //Checking last bit 1
			res=(res*a)%c;
			b--;
		}
		a=(a*a)%c;    //Updating a
		b=b>>1;     //Right shift b by 1
	}
	return res;
}

ll multi_mod_inv(ll a,ll m){
  ll x,y;
  ll gcd=gcd_ext(a,m,x,y);
  if(gcd!=1)  return -1;
  x=(x%m+m)%m;
  return x;
}

ll mod_div(ll a,ll b,ll m){ //(a/b)mod m?
  if(multi_mod_inv(b,m)!=-1)  return (a%m*multi_mod_inv(b,m)%m)%m;
  else  return -1;
}

bool str_pall(string str){
  ll sz=str.size();
  loop(i,0,sz/2)  if(str[i]!=str[sz-1-i])  return 0;
  return 1;
}

signed main()
{
    IOS;
    ll test=1;
    //cin>>test;
    while(test--)
    {
      ll n;
      cin>>n;
      vll v(n);
      loop(i,0,n) cin>>v[i];
      mll m;
      m[0]++;
      ll sum=0,order=1;
      loop(i,0,n){
        sum+=order*v[i];
        m[sum]++;
        order*=-1;
        //cout<<"m["<<sum<<"] = "<<m[sum]<<endl;
      }
      //cout<<endl<<endl;
      mll:: iterator it;
      ll ans=0;
      for(it=m.begin();it!=m.end();it++){
        //cout<<"m["<<it->FF<<"] = "<<it->SS<<endl;
        ll temp=it->SS;
        ans+=(temp*(temp-1)/2);
      }
      cout<<ans<<endl;
    }
}

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

long long N, Answer = 0;
long long A[1 << 19], B[1 << 19], C[1 << 19];
map<long long, long long> D;

int main() {
	// Step #1. 入力
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];

	// Step #2. 累積和を取る
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) B[i] = A[i];
		if (i % 2 == 0) B[i] = -A[i];
		C[i] = C[i - 1] + B[i];
	}

	// Step #3. 答えを計算する
	for (int i = 0; i <= N; i++) {
		Answer += D[C[i]];
		D[C[i]] += 1;
	}
	cout << Answer << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    bool flag = true;

    for(int i = 0; i < s.length(); i++){
        if ( i % 2 == 0){   //奇数番目
            if(isupper(s[i])){ //小文字
                flag = false;
            }
        }else{
            if(!isupper(s[i])){
                flag = false;
            }
        }
    }
    if(flag){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
}

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

char bool_ans(ll A, ll B){
    if(A == B) return '=';
    else if(A < B) return '<';
    else return '>';
}

int main(){
    ll A, B, C;
    char ans;
    cin >> A >> B >> C;

    if(A >= 0 && B >= 0){
        ans = bool_ans(A, B);
    }
    else if(A < 0 && B >= 0){
        if(C%2 == 0){
            ans = bool_ans(abs(A), B);
        }
        else{
            ans = '<';
        }
    }
    else if(A >= 0 & B < 0){
        if(C%2 == 0){
            ans = bool_ans(A, abs(B));
        }
        else{
            ans = '>';
        }
    }
    else{
        if(C%2 == 0){
            ans = bool_ans(abs(A), abs(B));
        }else{
            ans = bool_ans(A, B);
        }
    }

    cout << ans << endl;
}


#include<cstdio>
#include<queue>
#include<utility>
#include<vector>
#include<cmath>

using namespace std;

int n, m;
vector<pair<int, pair<int, int>>> v[100005];
long long dis[100005];
priority_queue<pair<long long, int>> pq;

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    v[a].push_back({b, {c, d}});
    v[b].push_back({a, {c, d}});
  }
  for (int i = 2; i <= n; i++) {
    dis[i] = 1e18;
  }
  pq.push({-dis[1], 1});
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    int u = p.second;
    if (p.first != -dis[u]) {
      continue;
    }
    for (auto x: v[u]) {
      int w = x.first;
      int c = x.second.first;
      int d = x.second.second;
      int t = max(0., floor(sqrt(d) - dis[u] - 1));
      if (1 + d / (dis[u] + t + 2) < d / (dis[u] + t + 1)) {
        t++;
      }
      if (dis[w] > dis[u] + t + c + d / (dis[u] + t + 1)) {
        dis[w] = dis[u] + t + c + d / (dis[u] + t + 1);
        pq.push({-dis[w], w});
      }
    }
  }
  if (dis[n] == 1e18) {
    printf("-1\n");
  } else {
    printf("%lld\n", dis[n]);
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007

void __print(int 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");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
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

// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;
int dis[gf];
vector<pair<int, pii>> adj[gf];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, m;
	cin >> n >> m;
	zip(i, 0, m)
	{
		int a, b, t, k;
		cin >> a >> b >> t >> k;
		adj[a].pb({b, {t, k}});
		adj[b].pb({a, {t, k}});
	}
	set<pii>s;
	rep(i, 0, gf - 1)dis[i] = INF;
	dis[1] = 0;
	s.insert({0ll, 1});
	while (sz(s))
	{
		pii temp = *s.begin();
		s.erase(temp);
		int u = temp.ss;
		for (auto x : adj[u])
		{
			int v = x.ff;
			int t = temp.ff;
			int lol = sqrt(x.ss.ss);
			int var = max(0ll, lol - t - 1ll);
			vi a;
			a.pb(var); a.pb(var + 1); a.pb(var + 2);
			if (var >= 1)
				a.pb(var - 1);

			int wt = min(max(0ll, x.ss.ss - t) + x.ss.ff, x.ss.ff + x.ss.ss / (t + 1));
			zip(i, 0, sz(a))
			{
				wt = min(wt, x.ss.ff + a[i] + x.ss.ss / (a[i] + t + 1));
			}
			debug(wt);
			if (dis[v] > wt + t)
			{
				if (dis[v] != INF)
					s.erase({dis[v], v});
				dis[v] = wt + t;
				s.insert({dis[v], v});
			}
		}
	}
	if (dis[n] == INF)
		cout << -1 << en;
	else
		cout << dis[n] << en;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll t,n;
int main(){
    cin>>t>>n;
    ll ans=(n*100+t-1)/t+n-1;
    cout<<ans;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = n;
    string s;
    cin >> s;
    list<char> l;
    rep(i,n) {
        l.push_back(s[i]);
    }
    auto l_itr = l.begin();
    while(l_itr != l.end()) {
        auto l_itr2 = l_itr;
        l_itr2++;
        if(l_itr2 == l.end()) break;
        auto l_itr3 = l_itr2;
        l_itr3++;
        if(l_itr3 == l.end()) break;

        if(*l_itr == 'f' && *l_itr2 == 'o' && *l_itr3 == 'x') {
            ans-=3;
            if(l_itr == l.begin()) {
                auto l_itr1 = l_itr;
                l_itr = l_itr3;
                l_itr++;
                l.erase(l_itr1);
                l.erase(l_itr2);
                l.erase(l_itr3);
            } else {
                auto l_itr1 = l_itr;
                l_itr--;
                if(l_itr != l.begin()) {
                    l_itr--;
                }
                l.erase(l_itr1);
                l.erase(l_itr2);
                l.erase(l_itr3);
            }
            continue;
        }
        l_itr++;
    }

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

ll n, k;
ll yama[800][800];
vector<ll> heights;
ll centerNum;
ll num[800][800];

int main()
{
	cin >> n >> k;
	for (ll y = 0; y < n; y++) {
		for (ll x = 0; x < n; x++) {
			cin >> yama[x][y];
			heights.push_back(yama[x][y]);
		}
	}
	sort(heights.begin(), heights.end());

	centerNum = (k * k + 1) / 2;

	if (k == 1) {
		cout << heights[0] << endl;
		return 0;
	}

	ll l = 0;
	ll r = n * n - 1;

	while (r - l > 1) {
		ll center = (l + r) / 2;
		ll height = heights[center];
		for (ll y = 0; y < n; y++) {
			for (ll x = 0; x < n; x++) {
				if (yama[x][y] <= height) {
					num[x][y] = 1;
				}
				else {
					num[x][y] = 0;
				}
			}
		}

		for (ll y = 0; y < n; y++) {
			for (ll x = 0; x < n; x++) {
				if (0 < y) {
					num[x][y] += num[x][y - 1];
				}
				if (0 < x) {
					num[x][y] += num[x - 1][y];
				}
				if ((0 < x) && (0 < y)) {
					num[x][y] -= num[x - 1][y - 1];
				}

			}
		}

		bool isExist = false;
		for (ll y = 0; y + k <= n; y++) {
			if (isExist) break;
			for (ll x = 0; x + k <= n; x++) {
				ll areaNum = num[x + k - 1][y + k - 1];
				if (0 < x) {
					areaNum -= num[x - 1][y + k - 1];
				}
				if (0 < y) {
					areaNum -= num[x + k - 1][y - 1];
				}
				if ((0 < x) && (0 < y)) {
					areaNum += num[x - 1][y - 1];
				}

				if (centerNum <= areaNum) {
					isExist = true;
					break;
				}
			}
		}

		if (isExist) {
			r = center;
		}
		else {
			l = center;
		}

	}

	cout << heights[r] << endl;
}

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void*wmem;
char memarr[96000000];
inline int my_getchar(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char*buf = (char *)wmem;
  rd(buf);
  x = buf;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar('-');
  }
  while(s--){
    my_putchar(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int dp[100000+10];
int hist[128];
int n;
string s;
int main(){
  int i;
  wmem = memarr;
  memset(dp, 0x7f, sizeof(dp));
  memset(hist, 0x7f, sizeof(hist));
  rd(n);
  rd(s);
  if(n == 1){
    wt_L(-1);
    wt_L('\n');
    exit(0);
  }
  dp[0] = 0;
  hist[s[0]] = 0;
  for(i=(1);i<(n);i++){
    int j;
    for(j=('a');j<('z' + 1);j++){
      if(j == s[i]){
        continue;
      }
      chmin(dp[i], hist[j]+1);
    }
    if(i+1 < n){
      chmin(hist[s[i+1]], dp[i]);
    }
  }
  if(dp[n-1] <= 100000){
    wt_L(dp[n-1]);
    wt_L('\n');
  }
  else{
    wt_L(-1);
    wt_L('\n');
  }
  return 0;
}
// cLay version 20210405-1

// --- original code ---
// //no-unlocked
// int dp[1d5+10];
// int hist[128];
// int n;
// string s;
// {
//     memset(dp, 0x7f, sizeof(dp));
//     memset(hist, 0x7f, sizeof(hist));
//
//     rd(n,s);
//     if(n == 1){
//         wt(-1);
//         exit(0);
//     }
//     dp[0] = 0;
//     hist[s[0]] = 0;
//     rep(i, 1, n){
//         rep(j, 'a', 'z' + 1){
//             if(j == s[i]) continue;
//             dp[i] <?= hist[j]+1;
//         }
//         if(i+1 < n) hist[s[i+1]] <?= dp[i];
//     }
//     if(dp[n-1] <= 1d5){
//         wt(dp[n-1]);
//     }else{
//         wt(-1);
//     }
// }


#include <bits/stdc++.h>

// 1. dp
typedef long double ld;
#define int long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
using namespace std;

void solve() {
    int n;
    cin>>n;
    int val=1;
    int start=1;
    for(int i=n-11;i<=n-1;i++)
    {
        val*=i;
        while(val%start==0 && start<=11)
        {
            val=val/start;
            start++;
        }
    }
    cout<<val<<endl;
}

int32_t main() {
    nitin;

    solve();
}

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

int main() {
    int n;
    cin >> n;
    long long ans = 1;
    for (int i = 1; i < 12; i++) {
        ans *= (n-i);
        ans /= i;
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep0(n) rep(i,0,n)
#define rep1(n) rep(i,1,n+1)
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define mem(x,i) memset((x),(i),sizeof((x)))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define Bint __int128
#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int lcm(int aaa,int bbb){
	return (aaa/__gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**

double a,b,c,d;

void solve(){
	cin >> a >> b >> c >> d;
	if(a>c){
		swap(a,c);
		swap(b,d);
	}
	double aa = c-a;
	cout << fixed << setprecision(7) << a+aa/(b+d)*b << '\n';
}

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

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

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

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

const ll INF = 1e9+10;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;
const ll LINF = 1e18;

// どの2数も共通の約数をもつ
// 全ての約数は
// gcd(A)=1
// n個の素数があれば作れるが10000までには1200個程度しかない n<=2500なので足りない
// 素因数は3つあればよい？
// ac ab ab ab ab bc
// こんな感じでサイクルを作れば良さそう
// 2*3331 2*3 2*3*2 ... 3*3331
// 2*3 2*3*2 2*3*3 ... これだと15000くらいになる
// サイクルではなく1個の頂点からの木のようなグラフを考える => 2数が共通の約数をもたない
// 4頂点の完全グラフ => 2190個で足りない
// ad, ab, abc, bcd
// 5頂点 ae ab abc abcd bcde 1973

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

  int n; cin>>n;

  int a,b,c;
  a=2;
  b=3;
  c=5;
  int ac=a*c, ab=a*b, bc=b*c;
  vc<int> B;
  B.push_back(ac);
  B.push_back(ab);
  B.push_back(bc);

  set<int> s;
  s.insert(ac);
  s.insert(ab);
  s.insert(bc);

  int now, x;
  now=ac, x=2;
  while(now*x<=10000){
    while(x%b==0 or s.count(now*x)){
      x++;
    }
    if(now*x>10000) break;
    s.insert(now*x);
    B.push_back(now*x);
  }
  now=ab, x=2;
  while(now*x<=10000){
    while(c%2==0 or s.count(now*x)){
      x++;
    }
    if(now*x>10000) break;
    s.insert(now*x);
    B.push_back(now*x);
  }
  now=bc, x=2;
  while(now*x<=10000){
    while(x%a==0 or s.count(now*x)){
      x++;
    }
    if(now*x>10000) break;
    s.insert(now*x);
    B.push_back(now*x);
  }

  // cout<<ngcd(b)<<endl;

  if(B.size()<n or B.back()>10000){
    cout<<B.size()<<' '<<B.back()<<endl;
    exit(-1);
  }

  rep(i,n){
    cout<<B[i]<<endl;
  }

}


#include <iostream>
using namespace std;

long long cnt[200001];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    n <<= 1;
    for(int i = 2; i <= n; i++) {
        cnt[i] = min(i - 1, n - i + 1);
    }
    k = abs(k);
    long long result = 0;
    for(int i = k; i <= n; i++) {
        result += cnt[i] * cnt[i - k];
    }
    cout << result;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 60 + 6;
ll memo[MAX][2];
string arr[MAX];
int n;

ll roll(int i, bool result) {
    if (i == 0) return 1;
    ll &ans = memo[i][result];
    if (~ans) return ans;

    if (arr[i - 1][0] == 'O') {
        if (!result) ans = roll(i - 1, false);
        else {
            ll a = roll(i - 1, false);
            ll b = 2 * roll(i - 1, true);
            ans = a + b;
        }
    }
    else {
        if (!result) {
            ll a = 2 * roll(i - 1, false);
            ll b = roll(i - 1, true);
            ans = a + b;
        }
        else ans = roll(i - 1, true);
    }

    return ans;
}

void solve() {
    cin >> n;
    fori (i, 0, n) cin >> arr[i];
    memset(memo, -1, sizeof memo);
    cout << roll(n, true) << endl;
}

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


#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <climits>
//#include "stdc++.h"
using namespace std;

// Q1
int main()
{
	long lA, lB, lC;
	cin >> lA >> lB >> lC;

	if (0 == lC)
	{
		if (lA - lB > 0)
			cout << "Takahashi";
		else
			cout << "Aoki";
	}
	else
	{
		if (lB - lA > 0)
			cout << "Aoki";
		else
			cout << "Takahashi";
	}

	return 0;
}

#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h>
#include <cmath>
#include <functional>
#include <cassert>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
// constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const char eol = '\n';
// --------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A,B,C;
  cin >> A >> B >> C;
  while(1){
    if(C){
      B--;
    }else{
      A--;
    }
    C ^= 1;
    if(A == -1){
      cout << "Aoki" << eol;
      return 0;
    }
    if(B == -1){
      cout << "Takahashi" << eol;
      return 0;
    }
  }
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define all(vvv) (vvv.begin(), vvv.end())
#define fastIO cout << fixed << setprecision(6), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
const int N = 5e5 + 9, M = 1e2 + 3, MOD = 1e9 + 7, B = 31;
const ll INF = 1e15;

int x[N], y[N];

int dcmp(double a, double b) {
    if(fabs(a - b) <= 1e6)
        return 0;
    else if(a > b)
        return 1;
    else
        return -1;
}

void runtestcase() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            ll nem = (y[i] - y[j]);
            ll dem = (x[i] - x[j]);
            if(abs(nem) <= abs(dem))
                ++cnt;
        }
    }
    cout << cnt;
}

int main() {
#ifdef LOCAL
    //    freopen("input.in", "rt", stdin);
//    freopen("output.in", "wt", stdout);
#endif
    fastIO;
    int t = 1, tt = 1;
    //cin >> t;
    while(t--) {
        runtestcase();
        ++tt;
    }
}

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <chrono>
#include <complex>
using namespace std;
#define ll long long
#define ld long double
#define ui unsigned int
#define ull unsigned ll
#define mp                   make_pair
#define eb                   emplace_back
#define pb                   push_back
#define pf                   push_front
#define popb                 pop_back
#define popf                 pop_front
#define hashmap              unordered_map
#define hashset              unordered_set
#define lb                   lower_bound
#define ub                   upper_bound
#define all(a)               (a).begin(), (a).end()
#define rall(a)              (a).rbegin(), (a).rend()
#define ff                   first
#define ss                   second
#define foi(n) for(ll i=0;i<n;i++)
#define foj(n) for(ll j=0;j<n;j++)
#define fok(n) for(ll k=0;k<n;k++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define forrr(i,b,a) for(ll i=b;i>=a;i--)
#define forrrr(i,a,b,k) for(ll i=a;i<b;i=i+k)
#define graph          vector<vector<int>>
#define sz(v) v.size()
typedef pair<int, int> pii;
typedef pair<ll, ll>   pll;
typedef vector<int>         vi;
typedef vector<ll>          vll;
typedef vector<string>      vs;
typedef vector<double>      vd;
typedef vector<pii>         vpii;
typedef vector<pll>         vpll;
typedef pair< ll, pll>      plll;
typedef vector<plll>      vplll;
typedef  vector<string> 	     vs;
typedef  vector<char>	         vc;
typedef  vector<bool>            vb;
typedef  map<string, int>         msi;
typedef  map<int, int>	         mii;
typedef  map<ll, ll>             mll;
typedef  map<char, int>           mci;
typedef  map<int, string>	     mis;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef priority_queue <ll> pq;
typedef priority_queue<pii, vector<pii>, greater<pii> > pqq;
const ll MOD = 1000000007;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("error1.txt", "w", stderr);
	freopen("output1.txt", "w", stdout);
#endif

//	ll t ; cin >> t;
//	while (t--)
	{
		solve();
		cout << "\n";
	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
ll ceils(ll x, ll y) {
	return x / y + ((x % y) != 0);
}
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;

}
void solve() {
	ll n;
	cin >> n;
	vpll x;
	foi(n) {
		ll x1, y;
		cin >> x1 >> y;
		x.pb(mp(x1, y));
	}
	ll ans = 0;
	foi(n - 1) {
		for (ll j = i + 1; j < n; j++) {
			if ((ld)(x[i].ss - x[j].ss) / (ld)(x[i].ff - x[j].ff) <= 1 and (ld)(x[i].ss - x[j].ss) / (ld)(x[i].ff - x[j].ff) >= -1)
				ans++;
		}
	}
	cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10,mod = 998244353;
int a[N];
int s[N];
int n;
int qpow(int a,int b){
	int res = 1;
	while(b){
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b>>=1;
	}
	return res;
}
int inv(int a){return qpow(a,mod-2);}
signed main(){
	cin >> n;
	for(int i=1;i<=n;i++) cin >> a[i];
	sort(a+1,a+n+1);
	int ans = 0ll;
	for(int i=1;i<=n;i++) ans = (ans + a[i] * a[i]) % mod;
	for(int i=1;i<=n;i++) s[i] = ((s[i-1] + a[i] * (qpow(2,n-i+1)))%mod + mod) % mod;
	for(int i=1;i<=n;i++){
		if(i == 1) continue;
		int cur = s[i-1] * inv(qpow(2,n-i+2)) % mod;
		ans = (ans + cur * a[i]) % mod;
	}
	cout << (ans%mod+mod)%mod << endl;
	return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<queue>
#include<stack>
#include<utility>
#include<cstdlib>
#include<cstdio>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<list>
#include<tuple>
using namespace std;

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for(ll i=(a); i<(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n+1)

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 ld INF=1e18;

int main(void){
    ll N; cin>>N;
    vl A(N);
    REP(i,N) cin>>A[i];
    sort(A.begin(),A.end());

    ld res=INF;
    ll cnt=0, sum=0;
    for(ll i=N-1; i>=0; --i){
        if(i==N-1){
            sum=0;
            cnt++;
        }
        else{
            sum+=(A[i+1]-A[i])*cnt;
            cnt++;
        }
        ld p=(ld)A[i]/2+(ld)sum/N;
        chmin(res,p);
    }
    cout<<fixed<<setprecision(20);
    cout<<res<<endl;
    return 0;
}