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

int main()
{
  int ans = 0;
  int max;
  string s10, s8;
  cin >> max;
  for (long long i = 1; i <= max; i++)
  {
    stringstream ss1, ss2;
    ss1 << dec << i;
    s10 = ss1.str();
    ss2 << oct << i;
    s8 = ss2.str();
    long unsigned int s10pos7 = s10.find('7');
    long unsigned int s8pos7 = s8.find('7');
    if (s10pos7 == string::npos && s8pos7 == string::npos)
      ans++;
  }
  cout << ans << endl;
}

#include <bits/stdc++.h>

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar())
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

const int MAXN = 1e5 + 10;

int n;
ll arr[MAXN];

int main () {
	read(n);
	ll mi = 1e10;
	ll g;
	rep(i, 1, n + 1) {
		read(arr[i]);
		if (i == 1)
			g = arr[i];
		else
			g = __gcd(arr[i], g);
		mi = min(arr[i], mi);
	}
	cout << g;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>

/* #include <atcoder/all> */
/* using namespace atcoder; */
using namespace std;

void debug_out(){ cout << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
/* const ll MOD = 998244353; */
const ll INF = 1ll<<60;
const double PI = acos(-1);

struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

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

  REP(i, N){
    cout << (i*2)%N+1 << " " << (i*2+1)%N+1 << "\n";
  }

  return 0;
}

#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F(i, n) for (int i = 0; i < n; i++)
#define Fa(n, a) for (int i = 0; i < n; i++) a[i] = gi()
#define R(i, n) for (int i = n-1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

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

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

#define MD 1000000007

int gf(int a) {
    int r = 1;
    while (a) {
        a /= 10;
        r *= 10;
    }
    return r;
}

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

    L(n);
    int res = 0;
    for (int i = 1; i < 1000000; i++) {
        int f = gf(i);
        ll x = ll(i) * ll(f+1);
        if (x > n)
            break;
        res++;
    }

    printf("%d\n", res);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vp> vvp;

const ll MOD = 1e9 + 7;

// input
ll N, M;
vi A;

void input() {
    cin >> N >> M;
    A = vi(N);
    rep(i, N) cin >> A[i];
}

int main() {
    input();
    ll s = accumulate(A.begin(), A.end(), 0LL);
    ll a = 1;
    rep(i, s + N) a = a * (M + N - i) % MOD;
    vl inv(s + N + 1), finv(s + N + 1);
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for (int i = 2; i <= s + N; i++){
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
    ll b = finv[s + N];
    ll ans = a * b % MOD;
    cout << ans << endl;
}

#include <stdio.h>
long long p = 1000000007;
long long n, m, s;
long long x, y, z;
long long a[2000];
long long inv[5000000];
void makeinv(void) {
	long long arraynumber = sizeof inv / sizeof inv[0];
	inv[1] = 1;
	for (int invcount = 2; invcount < arraynumber; invcount++) {
		inv[invcount] = p - inv[p % invcount] * (p / invcount) % p;
	}
}
int main() {
	makeinv();
	scanf("%lld%lld", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s += a[i];
	}
	if (m < s) {
		printf("0\n");
		return 0;
	}
	x = m + n;
	y = s + n;
	z = 1;
	for (long long i = 0; i < y; i++) {
		z *= (x - i);
		z %= p;
	}
	for (long long i = 1; i <= y; i++) {
		z *= inv[i];
		z %= p;
	}
	printf("%lld\n", z);
}


/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue
#define lld long long int
#define ldo long double
#define ins insert /// used in set to insert the values
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e16
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> >
#define pll pair <lld,lld>
lld p1=1e9 + 7,p2=998244353;

void judge(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    #endif
}

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

long long int modp(lld a,lld p,lld n)
{
    // n=n%(p-1);
    if(n==0) return 1;
    if(n==1) return a%p;
    lld x=modp(a,p,n/2);
    x*=x;
    x%=p;
    return (n%2?(x*a)%p:x);
}

lld modInverse(lld n, lld p)
{
    return modp(n, p, p-2);
}

// lld fac[500005];

// void getfac(lld p)
// {
//     fac[0] = 1;
//     for (lld i=1 ; i<=500005; i++)
//         fac[i] = fac[i-1]*i%p;
// }

// long long int nCrmodp(lld n, lld r,lld p)
// {
//    // Base case
//    if (r==0)
//       return 1;

//     return (fac[n]* modInverse(fac[r], p) % p *
//             modInverse(fac[n-r], p) % p) % p;
// }

struct segtree{
    lld n,n2;
    vector<lld> v;

    void init(lld x)
    {
        lld a=1;
        while(a<=x) a*=2;
        n2=2*a;
        n=x;
        v.assign(n2,0);
    }

    void build(vector<lld> &w,lld curr,lld l,lld r)
    {
        if(l==r)
        {
            if(l<n)
            {
                v[curr]=w[l];
            }
            return;
        }
        lld mid=l+(r-l)/2;
        build(w,2*curr+1,l,mid);
        build(w,2*curr+2,mid+1,r);
        v[curr]=v[2*curr+1]+v[2*curr+2];
    }

    void build(vector<lld>&w)
    {
        build(w,0,0,n-1);
    }

    void update(lld l, lld r,lld pos,lld curr)
    {
        if(l==r)
        {
            v[curr]-=1;
            return;
        }
        lld mid=l+(r-l)/2;
        if(pos<=mid)
        {
            update(l,mid,pos,2*curr+1);
        }
        else update(mid+1,r,pos,2*curr+2);
        v[curr]=v[2*curr+1]+v[2*curr+2];
    }

    void update(lld pos)
    {
        update(0,n-1,pos,0);
    }

    pll getVal(lld l,lld r,lld curr,lld k)
    {
        if(l==r)
        {
            return {l,k};
        }
        lld mid=l+(r-l)/2;
        if(v[2*curr+1]>=k)
        {
            return getVal(l,mid,2*curr+1,k);
        }
        return getVal(mid+1,r,2*curr+2,k-v[2*curr+1]);
    }

    pll getVal(lld k)
    {
        return getVal(0,n-1,0,k);
    }
};

lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;

bool compare(pair<pll,lld> p1,pair<pll,lld> p2)
{
    if(p1.fi.fi!=p2.fi.fi) return p1.fi.fi<p2.fi.fi;
    return p1.fi.se>p2.fi.se;
}

void solve(){
    cin>>x>>y>>z;
    if(x==y)
    {
        cout<<z;
    }
    else if(y==z)
    {
        cout<<x;
    }
    else if(x==z) cout<<y;
    else cout<<"0";
}

int main()
{
    // judge();
    fastio();
    lld t=1;
    // lld n;
    // cin>>t;
    // cout<<t<<" \n";
    // lld p1 = 1e9 + 7;
    // getfac(p1);
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        // cout<<" ----------------\n";
        solve();
        cout<<" \n";
    }
    // cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    // exit(0);

    return 0;
}

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    }
    else if (b == c) {
        cout << a << endl;
    }
    else if (a == c) {
        cout << b << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
const num inf = 0x3f3f3f3f3f3f3f3f;
int n, a[2 * nsz + 5];
num sum, ans;

int main() {
	scanf("%d", &n);
	cont (i, 2 * n) scanf("%d", &a[i]), sum += a[i];
	priority_queue<int, vector<int>, greater<int>> q;
	cont (i, n) q.push(a[n + 1 - i]), q.push(a[n + i]), ans += q.top(), q.pop();
	ans = sum - ans;
	printf("%lld\n", ans);
}

#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define int long long

int n;
vector<int> edges[100001];

int fh[100001], sh[100001];
bool change[100001];

bool cmp(int p, int q){
    int s1,s2;
    if(change[p])s1 = fh[p]-sh[p];
    else if(fh[p]-sh[p] >= 0)s1 = 1e18;
    else s1 = -1e18;
    if(change[q])s2 = fh[q]-sh[q];
    else if(fh[q]-sh[q] >= 0)s2 = 1e18;
    else s2 = -1e18;
    return s1 < s2;
}

void dfs(int u){
    for(int i = 0; i < SZ(edges[u]); ++i){
        int nxt = edges[u][i];
        dfs(nxt);
    }
    sort(edges[u].begin(), edges[u].end(), cmp);
    fh[u] = 1;
    sh[u] = 0;
    change[u] = 1;
    for(int i = 0, s = 1; i < SZ(edges[u]); ++i){
        int nxt = edges[u][i];
        change[u] ^= change[nxt];
        if(s == 1){
            fh[u] += fh[nxt];
            sh[u] += sh[nxt];
        }else{
            fh[u] += sh[nxt];
            sh[u] += fh[nxt];
        }
        if(change[nxt]){
            s = !s;
        }
    }
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 2; i <= n; ++i){
        int p;
        cin >> p;
        edges[p].emplace_back(i);
    }
    dfs(1);
    cout << fh[1] << '\n';
    //for(int i = 1; i <= n; ++i){
    //    cout << fh[i] << ' ' << sh[i] << ' ' << change[i] << '\n';
    //}
    return 0;
}


#include<iostream>
using namespace std;
char a[400][400];
int n,m,x,y;
int  main()
{
//  string s;
	cin>>n>>m;
	cin>>x>>y;
//	getchar();
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	cin>>a[i][j];
//	for(int i=1;i<)
//    cout<<a[1][1]<<" "<<a[1][4]<<endl;
	int ans=1;
	for(int i=x+1;i<=n;i++)
	{
		if(i>n || a[i][y]=='#') break;
		else ans++;
	}
	for(int i=x-1;i>=1;i--)
	if(i<1 || a[i][y]=='#') break;
	else ans++;
	for(int i=y+1;y<=m;i++)
	if(i>m||a[x][i]=='#') break;
	else ans++;
	for(int i=y-1;i>=1;i--)
	if(i<1||a[x][i]=='#') break;
	else ans++;
	cout<<ans;
//  cin>>s;
}

/*
Code by: tush_chen
*/

#include <bits/stdc++.h>

using namespace std;

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

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

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

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int) (x).size())
#define endl '\n'

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pi;

void solve() {
    //Test case code goes here

    int h, w, x, y;
    cin >> h >> w >> x >> y;
    --x;
    --y;

    vector < vi > grid(h, vi(w));
    vector < vi> other(w, vi(h));

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '#') {
                grid[i][j] = 1;
                other[j][i] = 1;
            }
            else {
                grid[i][j] = 0;
                other[j][i] = 0;
            }
        }
    }

    int cnt = 0;
    ll ans = 0;

    for (int j = y; j >= 0; --j) {
        if (grid[x][j] == 1) {
            break;
        }
        else {
            ++cnt;
        }
    }

    for (int j = y; j < w; ++j) {
        if (grid[x][j] == 1) {
            break;
        }
        else {
            ++cnt;
        }
    }

    ans += cnt;
    --ans;

    cnt = 0;

    for (int i = x; i >= 0; --i) {
        if (grid[i][y] == 1) {
            break;
        }
        else {
            ++cnt;
        }
    }

    for (int i = x; i < h; ++i) {
        if (grid[i][y] == 1) {
            break;
        }
        else {
            ++cnt;
        }
    }

    ans += cnt;
    --ans;
    --ans;

    cout << ans << endl;

}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // Code goes here
    int t;
    // cin >> t;
    t = 1;

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

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
using ll      = long long;
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    int T = 1;
    ll N, A, B;
    for (cin >> T; T--;) {
        cin >> N >> A >> B;
        ll C = N - A + 1, D = N - B + 1, E = N - A - B;
        ll f   = E < 0 ? 0 : (E + 2) * (E + 1) / 2 % mod;
        ll ans = 4 * f * (C * D % mod - f) % mod;
        cout << (ans + mod) % mod << '\n';
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
const int N=55;
int n,a[N],b[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll ans=2e18;
ll gcd(ll a,ll b){
	if(!b){
		return a;
	}
	return gcd(b,a%b);
}
bool check(ll x){
	for(int i=1;i<=n;i++){
		if(gcd(x,a[i])==1){
			return false;
		}
	}
	return true;
}
void dfs(int x,ll k){
	if(k>=ans){
		return;
	}
	if(check(k)){
		ans=k;
		return;
	}
	if(x>=15){
		return;
	}
	dfs(x+1,k*b[x]);
	dfs(x+1,k);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	dfs(0,1);
	printf("%lld\n",ans);
	return 0;
}


//ΔAGC053A
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 444;
int n,a[N],k;
char s[N];
int main()
{
	int i,j;
	scanf("%d%s",&n,s+1);
	k=1e5;
	for(i=0;i<=n;i=i+1)
		scanf("%d",a+i);
	for(i=1;i<=n;i=i+1){
		if(s[i]=='<')
			k=min(k,a[i]-a[i-1]);
		else
			k=min(k,a[i-1]-a[i]);
	}
	printf("%d\n",k);
	for(i=0;i<k;i=i+1){
		for(j=0;j<=n;j=j+1)
			printf("%d ",a[j]/k+(i<a[j]%k));
		printf("\n");
	}
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a)
#define dumparr(a,n)
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

void solve(long long N, std::string S, std::vector<long long> A){
  ll ansk=(1LL<<30);
  REP(A.size()-1){
    chmin(ansk,abs(A[i]-A[i+1]));
  }
  printf("%lld\n",ansk);
  REP(ansk){
    For(j,A.size()){
      printf("%lld",(A[j]+i)/ansk);
      if(j==A.size()-1){
        puts("");
      }else{
        printf(" ");
      }
    }
  }
  return;
}

int main(){
  cout<<setprecision(1000);
  long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::vector<long long> A(N-0+1);
    for(int i = 0 ; i < N-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
  solve(N, S, std::move(A));
  return 0;
}


#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 3005

ll N;
ll A[SIZE],rui[SIZE];
ll dp[SIZE][SIZE],memo[SIZE][SIZE];

int main(){

	scanf("%lld",&N);

	rui[0] = 0;
	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);
		rui[i+1] = rui[i]+A[i];
	}

	for(ll i = 0; i <= N; i++){
		for(ll k = 0; k <= N; k++){
			dp[i][k] = 0;
			memo[i][k] = 0;
		}
	}

	dp[0][1] = 1; //dp[index][次のグループ] := 場合の数
	memo[1][0] = 1; //memo[法][剰余] := 場合の数

	for(ll i = 1; i <= N; i++){
		//printf("\ni:%lld\n",i);
		for(ll k = i; k >= 1; k--){

			ll add = memo[k][rui[i]%k];

			dp[i][k+1] += add;
			dp[i][k+1] %= MOD;

			//printf("dp[%lld][%lld]:%lld\n",i,k+1,dp[i][k+1]);

			/*
			 * 位置iがグループkの右端となった
			 * →位置i+1はグループkの左端となることができ、
			 * その判断基準はrui[i]%(k+1)
			 * 累積和なので、基準値は実際の区間の1つ左
			 *
			 * */
			memo[k+1][rui[i]%(k+1)] += add;
			memo[k+1][rui[i]%(k+1)] %= MOD;
		}
	}

	ll ans = 0;

	for(ll i = 1; i <= N+1; i++){ //★NがグループNが右端の時は、次のグループはN+1★

		ans += dp[N][i];
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

void cout_line(vector<int> &a){
    for(int i=0;i<a.size();i++){
        if(i<a.size()-1){
            cout<<a.at(i)<<" ";
        }else{
            cout<<a.at(i)<<endl;
        }
    }
}

signed main(){
    int N; cin>>N;
    vec_int A(N); rep(i,N)cin>>A.at(i);
    int MOD = pow(10, 9) + 7;

    vec_int cumul_A(N+1, 0);
    for(int i=1;i<=N;i++){
        cumul_A.at(i) = cumul_A.at(i-1)+A.at(i-1);
    }

    vector<vec_int> DP(N+1, vec_int(N+1, 0)); // DP.at(i).at(j): j番目の数値までをi個に区切ったときの数
    DP.at(0).at(0) = 1;

    for(int i=0;i<N;i++){

        vec_int cumul_A2(N+1);
        rep(k,N+1)cumul_A2.at(k) = cumul_A.at(k)%(i+1);
        vector<vec_int> inds(i+1);
        vector<vec_int> cumul(i+1);
        rep(k, i+1)cumul.at(k).push_back(0);
        vec_int start_vec(N+1, 0);
        rep(k,N+1){
            inds.at(cumul_A2.at(k)).push_back(k);
            int sz = inds.at(cumul_A2.at(k)).size();
            start_vec.at(k) = sz-1;
            int prev = cumul.at(cumul_A2.at(k)).at(sz-1);
            cumul.at(cumul_A2.at(k)).push_back(prev + DP.at(i).at(k));
        }

        for(int j=1;j<=N;j++){
            // if(DP.at(i).at(j)==0)continue;
            int from = cumul_A2.at(j);
            int start_ind = start_vec.at(j);
            // cout<<i<<" "<<j<<" "<<from<<" "<<start_ind<<" "<<cumul.at(from).at(start_ind)<<endl;
            DP.at(i+1).at(j) += cumul.at(from).at(start_ind);
            DP.at(i+1).at(j) %= MOD;
            /*
            for(int k=start_ind+1; k<inds.at(from).size();k++){
                DP.at(i+1).at(inds.at(from).at(k)) += DP.at(i).at(j);
                DP.at(i+1).at(inds.at(from).at(k)) %= MOD;
            }
            */
        }
    }
    int ans = 0;
    for(int i=1;i<=N;i++){
        ans += DP.at(i).at(N);
        ans %= MOD;
    }
    cout<<ans<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 20, MAXM = 5e3 + 10, MOD = 1e9 + 7;

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

	vector <long long> a(n), ps(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i)
			ps[i] = ps[i - 1] + a[i];
		else
			ps[i] = a[i];
	}

	long long pos = 0;
	long long mx1 = 0;
	long long mx = 0;

	for (int i = 0; i < n; i++) {
		mx = max(mx, pos + mx1);
		pos += ps[i];
		mx1 = max(mx1, 1ll * ps[i]);
	}
	mx = max(mx, pos);
	cout << mx << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    vector<ll> acc(N+1, 0);
    ll M = 0;
    ll p = 0;
    ll q = 0;
    vector<ll> max_acc(N+1, 0);
    rep(i, N){
        acc.at(i+1) = acc.at(i) + A.at(i);
    }
    rep(i, N){
        max_acc.at(i+1) = max(max_acc.at(i), acc.at(i+1));
    }
    ll ans = 0;
    ll t = 0;
    rep(i, N){
        chmax(ans, t+max_acc.at(i+1));
        chmax(ans, t+acc.at(i+1));
        t += acc.at(i+1);
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

const ll INF_L = 1LL << 60;
const int INF_I = 1 << 30;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

int main()
{
    int m, h;
    cin >> m >> h;

    cout << (h % m ? "No" : "Yes") << "\n";
    return 0;
}

//伟大的导师，伟大的领袖，伟大的统帅，伟大的舵手
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
char __buf[1<<20],*__p1,*__p2;
//#define getchar() (__p1==__p2?(__p2=__buf+fread(__p1=__buf,1,1<<20,stdin),__p1==__p2?EOF:*__p1++):*__p1++)
int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
const int maxn = 1e5+10;
int n,K;
int C(int x,int y) {
	int r=1;
	for(int i=1;i<=y;i++) r=r*(x-i+1)/i;
	return r;
}
int ask(int s,int num) {
	int r=0;
	for(int i=0,ns;i<=num;i++) {
		if((ns=s-n*i)<num) continue;
		r=(r+(i&1?-1ll:1ll)*C(num,i)*C(ns-1,num-1));
	}
	return r;
}
signed main() {
	n=read(),K=read();
	for(int s=1,tt;s<=3*n;s++) {
		if((tt=ask(s,3))<K) K-=tt;
		else {
			for(int i=1;i<=n;i++) {
				if((tt=ask(s-i,2))<K) K-=tt;
				else return cout<<i<<' '<<max(1ll,s-i-n)+K-1<<' '<<s-i-(max(1ll,s-i-n)+K-1)<<'\n',0;
			}
			return 0;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define inf 1e9
#define linf 1e18
#define BASE 1000000
#define EPS 1e-10
#define PI acos(-1)
#define pii pair<int,int>
#define piii pair<int, pair<int,int>>
#define pli pair<long long, int>
#define pll pair<long long, long long>
#define pdi pair<double,int>
#define vi vector<int>
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define ms(x,val_add) memset(x, val_add, sizeof(x))
#define pb(x) push_back(x)
#define make_unique(x) sort(ALL(x)) ; x.erase( unique(ALL(x)), x.end()) ;
#define dbg(x) do { cout << #x << " = " << x << endl; } while(0)
#define mp(x, y) make_pair(x, y)
#define minimize(x, y) x = min(x, y)
#define maximize(x, y) x = max(x, y)

/*** IMPLEMENTATION ***/
bool exitInput = false;
int ntest = 1, itest = 1 ;

const int dx[4] =
{
    -1, 0, 1, 0
};
const int dy[4] =
{
    0, 1, 0, -1
};

const ll Mod = 1000000007LL;
const int maxn = 300000 + 5;
const int maxv = 500 + 5;
const int maxe = 10000 + 5;

void addMod(ll &x, ll y)
{
    x = (x + y) % Mod;
}
ll modPow(ll x, ll p)
{
    if(p == 0)
        return 1;
    ll r = modPow(x, p / 2);
    r = (r * r) % Mod;
    if(p & 1)
        r = (r * x) % Mod;
    return r;
}

int n, a[maxn], cntSmaller[maxn];
int ft[maxn];

int query(int x)
{
    int r = 0;
    while(x > 0)
    {
        r += ft[x];
        x -= x & (-x);
    }
    return r;
}

void update(int x)
{
    while(x < maxn)
    {
        ft[x] += 1;
        x += x & (-x);
    }
}

int main()
{
    #ifdef HOME
    freopen( "input.txt", "r", stdin );
    freopen( "output.txt", "w", stdout );
    #endif // HOME
    #ifdef HOME // Copied from Um_nik
	#   define eprintf(...) fprintf(stdout, __VA_ARGS__);fflush(stdout);
    #else
        #define eprintf(...) 42
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(10);
    cout << fixed;

    //cin >> ntest;
    for(itest = 1; itest <= ntest; ++itest)
    {
        //cout << "Case #" << itest << ": ";
        cin >> n;
        ll res = 0;
        for(int i = 1; i <= n; ++i)
        {
            cin >> a[i];
            a[i]++;
            cntSmaller[i] = query(a[i]-1);
            update(a[i]);
            res += (i-1) - cntSmaller[i];
        }
        cout << res << endl;
        ll pq = 0;
        for(int i = 1; i <= n-1; ++i)
        {
            pq -= cntSmaller[i];
            pq += (n-a[i]) - ((i-1) - cntSmaller[i]);

            //eprintf("i = %d, pq = %lld\n", i, pq);

            ll change = pq - (1LL * i * (n-i) - pq);
            cout << res + change << endl;
        }
    }

    return 0;
}

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

typedef long long ll;
#define pb push_back

// Merge Sort Tree
struct mstree
{
    int len;
    vector<vector<int>> t;
    mstree(int l)
    {
        len = l;
        t.resize(4 * len);
    }

    vector<int> merge(int l, int r)
    {
        int sz1 = t[l].size(), sz2 = t[r].size();
        vector<int> arr(sz1 + sz2);
        int i = 0, j = 0, idx = 0;
        while (i < sz1 && j < sz2)
        {
            arr[idx++] = (t[l][i] < t[r][j]) ? t[l][i++] : t[r][j++];
        }
        while (i < sz1)
        {
            arr[idx++] = t[l][i++];
        }
        while (j < sz2)
        {
            arr[idx++] = t[r][j++];
        }
        return arr;
    }

    template <typename T>
    void build(const T &arr, const int32_t &v, const int32_t &tl, const int32_t &tr)
    {
        if (tl == tr)
        {
            t[v].pb(arr[tl]);
            return;
        }
        int32_t tm = (tl + tr) >> 1;
        build(arr, v << 1, tl, tm);
        build(arr, v << 1 | 1, tm + 1, tr);
        t[v] = merge(v << 1, v << 1 | 1);
    }

    // number of elements less than e in given range
    int query(const int32_t &v, const int32_t &tl, const int32_t &tr, const int32_t &l, const int32_t &r, int e)
    {
        if (l > tr || r < tl)
            return 0;
        if (tl >= l && tr <= r)
            return lower_bound(t[v].begin(), t[v].end(), e) - t[v].begin();
        int32_t tm = (tl + tr) >> 1;
        return query(v << 1, tl, tm, l, r, e) + query(v << 1 | 1, tm + 1, tr, l, r, e);
    }

public:
    template <typename T>
    void build(const T &arr)
    {
        build(arr, 1, 0, len - 1);
    }
    int query(const int32_t &l, const int32_t &r, int e)
    {
        return query(1, 0, len - 1, l, r, e);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<ll> res(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    mstree ms(n);
    ms.build(arr);
    for (int i = 0; i < n; i++)
        res[0] += ms.query(i + 1, n - 1, arr[i]);
    for (int i = 1; i < n; i++)
        res[i] = res[i - 1] + n - 2 * arr[i - 1] - 1;
    for (ll r : res)
        cout << r << "\n";
    return 0;
}


/** made by amunduzbaev **/

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vv vector
#define tut(x) array<int, x>
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
typedef vector<pii> vpii;
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
void fropen(string s) {  freopen((s+".in").c_str(),"r",stdin);  freopen((s+".out").c_str(),"w",stdout);  }

const int N = 3e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);

#define MULTI 0
int n, m, k, res, s, ans, a[N];
int tree[4*N];

void upd(int i, int v, int lx = 1, int rx = s, int x = 1){
	if(lx == rx){ tree[x] ^= v; return; }
	int m = (lx + rx)>>1;
	if(i <= m) upd(i, v, lx, m, x<<1);
	else upd(i, v, m+1, rx, x<<1|1);
	tree[x] = tree[x<<1] ^ tree[x<<1|1];
}

int get(int l, int r, int lx = 1, int rx = s, int x = 1){
	if(lx > r || rx < l) return 0;
	if(lx >= l && rx <= r) return tree[x];
	int m = (lx + rx)>>1;
	return get(l, r, m+1, rx, x<<1|1) ^ get(l, r, lx, m, x<<1);
}

void solve(int t_case){
	cin>>n>>m;
	s = 1;
	while(s < n) s<<=1;
	for(int i=1;i<=n;i++){
		int x; cin>>x;
		upd(i, x);
	}
	while(m--){
		int t; cin>>t;
		if(t == 1){
			int i, v; cin>>i>>v;
			upd(i, v);
		} else {
			int l, r; cin>>l>>r;
			cout<<get(l, r)<<"\n";
		}
	}
}

signed main(){
	NeedForSpeed

	if(!MULTI) {
		solve(1);
	} else {
		int t; cin>>t;
		for(int t_case = 1; t_case <= t; t_case++) solve(t_case);
	}
	return 0;
}

#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define INF INT_MAX
#define FLOAT_ANS setprecision(10)

using namespace std;
typedef long long ll;

//最大公約数
template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}

//Segment Tree(遅延評価)
template<typename T>
class SegTreeLazy {

	//参照：https://algo-logic.info/segment-tree/
public:
	//変数定義
	ll N;  //長さ
	T e; //単位元
	vector<T>seg; //基本
	vector<T>lazy; //遅延用
	function<T(T, T)> f; //比較用

	SegTreeLazy(ll n, ll e_, function<T(T, T)> f_) {
		//サイズ・単位元・比較用の関数
		e = e_;
		f = f_;

		//サイズnのSegTreeに必要な要素数
		ll x = 1;
		while (n > x) {
			x *= 2;
		}
		N = x;

		seg.resize(2 * N - 1, e);
		lazy.resize(2 * N - 1, e);
	}

	T get(ll i){
		return seg[i+N-1];
	}

	void eval(ll k) {
		//lazyから更新情報を取得、segに反映
		if (lazy[k] == e) return; //更新情報がなければ終了
		if (k < N - 1) { //自身が葉でないのなら子にも伝搬させる(zipを解凍)
			lazy[k * 2 + 1] = lazy[k];
			lazy[k * 2 + 2] = lazy[k];
		}

		//最後に、自身を更新
		seg[k] = lazy[k];
		//もう更新情報に用はないので、初期化
		lazy[k] = e;
	}

	void update(ll a, ll b, T x, ll k, ll l, ll r) {
		// a･b:全体の範囲
		// k･l:現在更新するn層目の範囲
		// x:更新する値
		// k:セグ木の配列における位置

		eval(k); //まずは更新(sudo apt update　と同じ感じ?)
		if (a <= l && r <= b) {// 内部にある(端でない)
			//現在の層についてのみ更新させる
			lazy[k] = x;
			eval(k);
		}
		else if (a < r && l < b) {// 一部区間がかぶる
			update(a, b, x, k * 2 + 1, l, (l + r) / 2); //右の子に伝搬
			update(a, b, x, k * 2 + 2, (l + r) / 2, r); //左の子に伝搬
			seg[k] = f(seg[k * 2 + 1], seg[k * 2 + 2]);
		}
	}
	void update(ll a, ll b, T x) {
		//(a)-(b-1)の範囲をxに更新
		update(a, b, x, 0, 0, N);
	}
	void update(ll a, T x) {
		//aをxに更新
		update(a, a + 1, x, 0, 0, N);
	}

	T query_sub(ll a, ll b, ll k, ll l, ll r) {
		eval(k);
		if (r <= a || b <= l) {  //完全に外部
			return e;
		}
		else if (a <= l && r <= b) {  //完全に内部
			return seg[k];
		}
		else {
			T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);

			return f(vl, vr); //右の子と左の子の小さい方
		}
	}
	T query(int a, int b) {
		return query_sub(a, b, 0, 0, N);
	}
};

int main(void) {
	ll n;
	cin>>n;
	vector<ll>p(n);
	vector<bool>dp(200010,false);
	ll ans=0;
	rep(i,n){
		cin>>p[i];
		dp[p[i]]=true;
		while(dp[ans]){
			++ans;
		}
		cout<<ans<<endl;
	}
}

/*

*/


#include <iostream>
using namespace std;
using ll = long long;
ll number_ab(ll a, ll n);
bool fakeprime(ll n);
int main()
{
    ll n, ans;
    cin >> n;
    ans = n;
    for (ll i = 0; i*i <= n; i++) {
        if (fakeprime(i)) {
            ans -= number_ab(i, n);
        }
    }
    cout << ans << endl;
    return 0;
}
ll number_ab(ll a, ll n)
{
    if (a > n) return -1;
    ll k = a, b = 0;
    while (true) {
        k *= a;
        if (k <= n) b++;
        else        break;
    }
    return b;
}
bool fakeprime(ll n)
{
    if (n <= 1) return false;
    ll k;
    for (ll i = 2; i*i <= n; i++) {
        k = n;
        while (k % i == 0) {
            k /= i;
        }
        if (k == 1) return false;
    }
    return true;
}

#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
#include <numeric>
#include <cmath>
#include <complex>
#include <stack>
#include <memory>
#include <cstdio>
#include <iomanip>

using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll i=ll(a); i<ll(b); i++)//  a<=i<b i++ のforの開始
#define FOR_(i,b,a) for(ll i=ll(b); ll(a)<i; --i)// b =>i>a i-- のforの開始
#define EACH(e,a) for(auto &(e):(a))//集合aの各要素eを当たる forの開始
#define FIND(e,a,i) vector<ll>::iterator itr=find((a).begin(),(a).end(),e);\
 if(itr!=(a).end()){i=itr-(a).begin();} else{i=-1;}//vector aの中に要素eはあるのかあるならindexをiに，なければiは-1
#define MAX(a,i) vector<ll>::iterator itr0=max_element((a).begin(),(a).end());\
 i=(ll)(itr0-(a).begin());// vector<ll>の最大値の足をiに返す
#define MIN(a,i) vector<ll>::iterator itr1=min_element((a).begin(),(a).end());\
 i=(ll)(itr1-(a).begin());// vector<ll>の最小値の足をiに返す
#define ERASE(a,i) (a).erase((a).begin()+i);//iは0始まり
#define ERASES(a,i,j) (a).erase((a).begin()+i,(a).begin()+j);//i,jは0始まり i<= u <jの範囲を消す i!=j
#define SORT(a)  sort(begin(a),end(a))//小さい順にsort 1,2,3
#define SORT_(a) sort(begin(a),end(a),greater<ll>{})//大きい順にsort 5,4,3
#define OUT(s) cout<<(s)<<endl
#define OUT2(s0,s1) cout<<(s0)<<" "<<(s1)<<endl
#define OUT3(s0,s1,s2) cout<<(s0)<<" "<<(s1)<<" "<<(s2)<<endl
#define OUT4(s0,s1,s2,s3) cout<<(s0)<<" "<<(s1)<<" "<<(s2)<<" "<<(s3)<<endl
#define OUT5(s0,s1,s2,s3,s4) cout<<(s0)<<" "<<(s1)<<" "<<(s2)<<" "<<(s3)<<" "<<(s4)<<endl
#define OUTV(a) FOR(i,0,(a).size()){cout<<a[i]<<" ";} cout<<""<<endl;
#define OUTVV(a) FOR(i,0,(a).size()){FOR(j,0,(a[i]).size()){cout<<a[i][j]<<" ";}cout<<" "<<endl;}

// 20210515 ABCに向けて頑張ってみる

void une()
{
    ll N;
    cin >> N;
    //N = 8;
    //N = 100000;
    if(N <= 3)
    {
        OUT(N);
        return;
    }

    ll n0,n;
    n0 = sqrt(N)+1;
    double s0,s1;
    set<ll> ss;

    FOR(i,2,n0)
    {
        s0 = (double)log(N);
        s1 = (double)log(i);
        n = (ll)(s0/s1);
        if(2<=n)// i^1を消す
        {
            FOR(j,2,n+1)
            {
                ss.insert(pow(i,j));
                //OUT(pow(i,j));
            }
        }
        else
        {
            break;
        }
    }

    OUT(N-ss.size());

}

int main()
{
    une();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const ll MAX = 50000000000000;
ll MOD = 1000000007;
ll X,Y;
map<ll,ll> memo;
ll T(ll a){
    if(memo[a] != 0) return memo[a] - 100;
    ll b;
    if(a == 1) b = abs(X - 1);
    else if(a % 2 == 0) b = min(abs(a - X),1 + T(a / 2));
    else b = min({abs(a - X),2 + T((a - 1) / 2),2 + T((a + 1) / 2)});
    memo[a] = b + 100;
    return b;
}
int main(){
    cin >> X >> Y;
    cout << T(Y) << endl;
}

#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) LL((a).size())

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ROF(i,a,b) for(LL i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL LARGE_INT = 1e9+100;
const LL INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const LL MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n,k;cin>>n>>k;
    map<LL,LL> a;
    REP(i,n){
        LL t;cin>>t;
        a[t]++;
    }

    LL point = 0;
    VL result;
    LL now = k;
    for(auto x : a){
        LL s = SIZE(result);
        if(x.first != point){
            REP(i,now){
                result.PB(point);
            }
            now = 0;
            break;
        }

        if(x.second < now){
            REP(i,now-x.second){
                result.PB(point);
            }
            now = x.second;
        }
        point++;
        //dump(x.first)
        //dump(x.second)
        //dump(now)
    }
    REP(i,now){
        result.PB(point);
    }

    LL sum = 0;
    for(auto x : result){
        sum += x;
    }

    cout<<sum<<endl;

	return;
}

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);~i;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;

//Data
const int N=1000;
int n;
string str;

//Math
const int mod=1e9+7;
void fmod(int &x){x+=x>>31&mod;}
int Pow(int a,int x){
    int res(1); for(;x;a=1ll*a*a%mod,x>>=1)
    (x&1)&&(res=1ll*res*a%mod); return res;
}

//Functions
void solve0(){
    cout<<1<<'\n';
}
void solve1(){
    if(n==2) cout<<1<<'\n';
    else cout<<Pow(2,n-3)<<'\n';
}
void solve2(){
    vector<int> f(n-1);
    R(i,n-1){
        if(i<2) f[i]=1;
        else fmod(f[i]=f[i-1]+f[i-2]-mod);
    }
    cout<<f[n-2]<<'\n';
}

//Main
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n;
    R(i,4){
        char c; cin>>c;
        str.pb(c);
    }
    if(str=="AAAA") solve0();
    else if(str=="AAAB") solve0();
    else if(str=="AABA") solve0();
    else if(str=="AABB") solve0();
    else if(str=="ABAA") solve1();
    else if(str=="ABAB") solve0();
    else if(str=="ABBA") solve2();
    else if(str=="ABBB") solve0();
    else if(str=="BAAA") solve2();
    else if(str=="BAAB") solve2();
    else if(str=="BABA") solve1();
    else if(str=="BABB") solve1();
    else if(str=="BBAA") solve1();
    else if(str=="BBAB") solve0();
    else if(str=="BBBA") solve2();
    else if(str=="BBBB") solve0();
    return 0;
}

/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int P = 1e9 + 7;
int n, ch[5][5];
int main() {

//  freopen("hs.in","r",stdin);
//  freopen("hs.ans","w",stdout);
	read(n);
	for (int i = 0;i <= 1; i++) {
		for (int j = 0;j <= 1; j++) {
			char s[5]; scanf ("%s", s);
			ch[i][j] = s[0] - 'A';
		}
	}
	if (n == 2) return write(1), 0;
	static ll f[2005][2];
	if (ch[0][1] == 1) ch[1][0] = !ch[1][0], ch[0][0] = !ch[1][1];
	if (ch[0][0] == 0) return write(1), 0;
	if (ch[1][0] == 0) {
		f[1][0] = f[1][1] = 1;
		for (int i = 2;i <= n; i++)
			f[i][0] = (f[i-1][0] + f[i-1][1]) % P, f[i][1] = f[i-1][0];
		return write(max(1, (int)(f[n-3][0] + f[n-3][1]) % P)), 0;
	}
	else {
		ll mi = 1;
		for (int i = 1;i <= n - 3; i++) mi = mi * 2 % P;
		write(mi);
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template <class T>
void read(T &);
template <class T>
void write(const T &);

typedef long long ll;
typedef unsigned long long ull;
typedef const long long &cll;
typedef const int &ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::abs;
using std::max;
using std::min;

const int N = 200005;

int n, m;

int main() {
  read(n), read(m);
  if (m == 0) {
    for (int i = 1; i <= n; ++i) {
      write(2 * i), SP, write(2 * i + 1), EL;
    }
    return 0;
  }
  if (m > 0) {
    if (m >= n - 1) {
      puts("-1");
      return 0;
    }
    write(1), SP, write(2 * m + 4), EL;
    for (int i = 1; i <= m + 1; ++i) {
      write(2 * i), SP, write(2 * i + 1), EL;
    }
    for (int i = m + 3; i <= n; ++i) {
      write(2 * i + 4), SP, write(2 * i + 5), EL;
    }
  } else {
    puts("-1");
  }
  return 0;
}

template <class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
long long extGcd(long long a, long long b, long long &p, long long &q) {
    if (b == 0) {
        p = 1, q = 0;
        return a;
    }
    long long d = extGcd(b, a % b, q, p);
    q -= a / b * p;
    return d;
}

pair<long long, long long> ChineseRem(const vector<long long> &vr, const vector<long long> &vm) {
    if (vr.empty() || vm.empty()) return make_pair(0, 1);
    long long R = vr[0], M = vm[0];
    for (int i = 1; i < (int)vr.size(); ++i) {
        long long p, q, r = vr[i], m = vm[i];
        if (M < m) swap(M, m), swap(R, r); // prevent overflow
        long long d = extGcd(M, m, p, q); // p is inv of M/d (mod. m/d)
        if ((r - R) % d != 0) return make_pair(0, -1);
        long long md = m / d;
        long long tmp = (r - R) / d % md * p % md;
        R += M * tmp, M *= md;
    }
    R %= M;
    if (R < 0) R += M;
    return make_pair(R, M);
}
int main() {
    ll t;
    std::cin >> t;
    for (int iiii = 0; iiii < t; iiii++) {
        ll x,y,p,q;
        std::cin >> x>>y>>p>>q;
        ll ans = 1e18+1e+17;
        for (ll i = 0; i < y; i++) {
            for (ll j = 0; j < q; j++) {
                // if(i==0&&j==0)continue;
                auto [r,m]  = ChineseRem({x+i,p+j},{2*x+2*y, p+q});
                // std::cout << r<<" "<<m <<" "<<iiii<< std::endl;
                if(r==0&&m==-1)continue;
                // std::cout << r<<" :" << std::endl;
                ans = min(ans,r);
            }
        }
        if(ans==1e18+1e17){
            std::cout << "infinity" << std::endl;
            continue;
        }
        std::cout << ans << std::endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define all(a) (a).begin(), (a).end()
using pint = pair<ll, ll>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    map<int, ll> mp;
    rep(i, 0, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll ans = n * (n - 1) / 2;
    for (auto p : mp) {
        ans -= p.second * (p.second - 1) / 2;
    }
    cout << ans << "\n";
}

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

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

int n, m, a[maxn], sum[maxn];

void solve() {
    int i, j, mx;
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i], sum[i] = a[i];
    for (i = 1; i <= n; i++) sum[i] += sum[i - 1];
    for (i = 1; i <= n; i++) sum[i] += sum[i - 1];
    for (i = 1, mx = a[1]; i <= n; i++) {
        if (a[i] > mx) mx = a[i];
        int ans = mx * i + sum[i];
        cout << ans << endl;
    }
}

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


#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
typedef long long ll;

void Main() {
    int N, t[2000];
    double l[2000], r[2000];
    cin >> N ;
    for (int i = 0; i < N; ++i) {
        cin >> t[i] >> l[i] >> r[i] ;
        if (t[i] == 2 || t[i] == 4) { // 右が開なら少し狭く
            r[i] -= 0.2;
        }
        if (t[i] == 3 || t[i] == 4) {
            l[i] += 0.2;
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            //[a, b], [c, d]が交わるかどうか：max(a, c) <= min(c, d)
            // printf("[l[%d], r[%d]] = [%f, %f], [l[%d], r[%d]] = [%f, %f], max(l[%d], l[%d]) = %f, min(r[%d], r[%d]) = %f\n", i, i, l[i], r[i], j, j, l[j], r[j], i, j, max(l[i], l[j]), i, j, min(l[i], l[j]));
            if (max(l[i], l[j]) <= min(r[i], r[j])) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}

int main(void) {
    Main();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define m7          1000000007
#define m9          1000000009
#define ll          long long
#define boost       ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define F           first
#define S           second
#define pb          push_back
#define f1(i,n)     for(int i=0;i<n;i++)
#define all(c)      c.begin(),c.end()
#define ldb         long double

int main() {

    int t;
   // cin>>t;
    t = 1;
    while(t--)
    {
        int n,m,x,y;
        cin>>n>>m>>x>>y;
        vector<string> vec(n);
        f1(i,n)
        {
        	cin>>vec[i];
        }

        x--;
        y--;
        int ans = 1;
        for(int i=y-1;i>=0;i--)
        {
        	if(vec[x][i] == '.')
        		ans++;
        	else
        		break;

        }
        for(int i=x-1;i>=0;i--)
        {
        	if(vec[i][y] == '.')
        		ans++;
        	else
        		break;

        }
        for(int i=y+1;i<m;i++)
        {
        	if(vec[x][i] == '.')
        		ans++;
        	else
        		break;

        }
        for(int i=x+1;i<n;i++)
        {
        	if(vec[i][y] == '.')
        		ans++;
        	else
        		break;

        }
        cout<<ans<<'\n';

    }
	return 0;
}


/******************************
     AUTHOR KRISH MURARKA
*******************************/
#include<bits/stdc++.h>
using namespace std;
#define ll                 long long int
#define mod                1000000007
#define modulo             998244353
#define popcount           __builtin_popcount     //used to count number of set bits in a integer
#define llpopcount         __builtin_popcountll
#define parity             __builtin_parity // returns true(1) if number has odd parity i.e odd no of set bits
#define llparity           __builtin_parityll
#define leadzero           __builtin_clz  //returns number of leading zeros of a 32 bit int
#define llleadzero         __builtin_clzll // returns number of leading zero of a 64 bit int
#define trailzero          __builtin_ctz  // returns number of trailing zero
#define lltrailzero        __builtin_ctzll
#define f                  first
#define s                  second
#define pb                 push_back
#define ppb                pop_back
#define inf                (ll)(1e18)
#define rep(i,a,b)         for(int i=a;i<b;i++)
#define pll                pair<ll,ll>
#define ppl                pair<pair<ll,ll>>
#define mem1(a)            memset(a,-1,sizeof(a))
#define mem0(a)            memset(a,0,sizeof(a))
#define fast               ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define deb(x)             cout<<#x<<" "<<x<<"\n"
#define uid(l,r)           uniform_int_distribution<int>(l,r); // to use auto temp= uid(l,r). int x= temp(rng); to generate from [L,R]
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;} // only use in equations like sum=max(sum,x)  its equivalent ot amax(sum,x) => sums is changed automatically
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void read_input()
{
  #ifndef ONLINE_JUDGE
  freopen("inputA.txt","r",stdin);
  freopen("outputA.txt","w",stdout);
  #endif
}
vector<ll> v[1005];
void solving()
{
   ll n;
   cin>>n;
   string s;
   cin>>s;
   ll q;
   cin>>q;
   string t1=s.substr(0,n);
   string t2=s.substr(n);
   bool flag=true;
   while(q-->0)
   {
     int t;
     ll a,b;
     cin>>t>>a>>b;
     a--;b--;
     if(t==1)
     {

        // if flag =false string order temp1+temp2
        // else string order temp2+temp1

          int left=a;
          int right=b;
           if(left<n && right<n)
           {
              if(flag)
              {
                swap(t1[right],t1[left]);
              }
              else
              {
                swap(t2[right],t2[left]);
              }
           }
           else if(left<n && right>=n)
           {
              right-=n;
               if(flag)
               {
                  int temp=t1[left];
                  t1[left]=t2[right];
                  t2[right]=temp;
               }
               else
               {
                 int temp=t2[left];
                 t2[left]=t1[right];
                 t1[right]=temp;
               }
           }
            else
            {
               left-=n;
               right-=n;
               if(flag)
               {
                 swap(t2[left],t2[right]);
               }
               else
               {
                  swap(t1[left],t1[right]);
               }
            }
     }
     else
     {
        flag=!flag;
     }
    }

    if(flag)
    {
      cout<<(t1+t2)<<"\n";
    }
    else
      cout<<(t2+t1)<<"\n";
}
int main()
{
    fast;
    read_input();
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
    //cout<<"Case #"<<i<<": ";
     solving();
    }
    return 0;
}

#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <stack>
#include <deque>
#include <vector>

#define loop(i,a,b) for (int i = (a); i <= (b); i++)
#define loopr(i, a, b) for(int i = (a); i >= (b); i--)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pf 				push_front
#define mp              make_pair
#define mt              make_tuple
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define mod1 998244353
using namespace std;

int fast_pow(int a, int p) {
  int res = 1;
  while (p) {
    if (p % 2 == 0) {
      a = a * 1ll * a % mod;
      p /= 2;
    } else {
      res = res * 1ll * a % mod;
      p--;
    }
  }
  return res;
}

int fact(int n) {
  int res = 1;
  for (int i = 1; i <= n; i++) {
    res = res * 1ll * i % mod;
  }
  return res;
}

int C(int n, int k) {
  return fact(n) * 1ll * fast_pow(fact(k), mod - 2) % mod * 1ll * fast_pow(fact(n - k), mod - 2) % mod;
}

vector<int> sieveOfEratosthenes(int n) {
	vector<int> primes;
	vector<bool> prime(n+1,true);
	for (int p = 2; p * p <= n; p++) {
		if (prime[p] == true) {
			for (int i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (int p = 2; p <= n; p++)
		if (prime[p])
			primes.push_back(p);
	return primes;
}

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

int highestPowerof2(int n)
{
   int p = (int)log2(n);
   return (int)pow(2, p);
}

int modd(string num, int a)
{
    // Initialize result
    int res = 0;

    // One by one process all digits of 'num'
    for (int i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}

int32_t main()
{
	fast_io;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int q;
	cin>>q;
	int cnt = 0;
	while(q--)
	{
		int t,a,b;
		cin>>t>>a>>b;
		if(t==1)
		{
			if(cnt&1)
			{
				if(a>b)
				{
					swap(a,b);
				}
				if(a<=n and b>n)
				{
					swap(s[a-1+n],s[b-1-n]);
				}
				else if(a<=n and b<=n)
				{
					swap(s[a-1+n],s[b-1+n]);
				}
				else if(a>n and b>n)
				{
					swap(s[a-1-n],s[b-1-n]);
				}
			}
			else
			{
				swap(s[a-1],s[b-1]);
			}
		}
		else
		{
			cnt++;
		}
	//	cout<<s<<endl;
	}
	string r = "";
	if(cnt&1)
	{
		loop(i,n,2*n-1)
		{
			r+=s[i];
		}
		loop(i,0,n-1)
		{
			r+=s[i];
		}
	}
	else
	{
	//	reverse(s.begin(),s.end());
		r = s;
	}
	cout<<r<<endl;
}


//ABC 200 E - Patisserie ABC 2
//https://atcoder.jp/contests/abc200/tasks/abc200_e

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

int main() {
	int n;
	long long k;
	cin >> n >> k;
	//已选了几个数，其数字和是多少

	long long dp[4][3000005] = {};

	dp[0][0] = 1;
	for(int i = 0; i < 3; i++) {    // 推送给、贡献给父问题
		for(int j = 0; j <= i * n; j++) {
			dp[i + 1][j + 1] += dp[i][j];      //区间统一修：差分
			dp[i + 1][j + n + 1] -= dp[i][j];
		}
		for(int j = 1; j <= (i + 1) * n; j++) //差分+前缀和
			dp[i + 1][j] += dp[i + 1][j - 1];    //才是最后的值
	}

	int x;
	for(int i = 3; i <= 3 * n; i++)
		if(k <= dp[3][i]) {
			x = i;
			break;
		} else k -= dp[3][i];   //为何要减去？

	for(int i = 1; i <= n; i++) {
		int jmi = max(1, x - i - n);
		int jma = min(n, x - i - 1);
		if(jmi > jma) continue;
		if(k > (jma - jmi + 1)) {
			k -= (jma - jmi + 1);
			continue;
		}
		int y = jmi + k - 1;
		int z = x - i - y;
		cout << i << ' ' << y << ' ' << z << '\n';
		return 0;
	}
}

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

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

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

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;

void solve() {
    ll t, n;
    cin >> t >> n;

    ll ng = 0;
    ll ok = 1e13;
    while (ok - ng > 1) {
        ll mid = (ng+ok)/2;
        ll now = mid*t/100;
        if (now >= n) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ll a = ok + ok*t/100;
    ok--;
    ll b = ok + ok*t/100;
    ll ans = (a+b)/2;
    cout << ans << endl;
}

int main() {

    solve();

    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 998244353;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[2010];

map<int, int> g;

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

vector<int> divisor(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int solve() {
    int min_a = inf;
    for (int i = 0; i < n; i++) {
        min_a = min(min_a, a[i]);
    }
    for (int i = 0; i < n; i++) {
        for (int d : divisor(a[i])) {
            if (d > min_a) continue;
            if (g.count(d) == 0) g[d] = 0;
            g[d] = gcd(a[i], g[d]);
        }
    }

    int res = 0;
    for (const auto& v : g) {
        if (v.first == v.second)
            res++;
    }
    return res;
}

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

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

    input();
    cout << solve() << endl;
}

#include<iostream>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
};

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

int main(){
  int n,m; cin >>n >>m;
  map<int,int> mp;
  auto  add=
    [&](int a){
      for(int i=1;i*i<=a and i<=m; i++){
        if(a%i) continue;
        mp[i]=gcd(a,mp[i]);
        if(a/i<=m)mp[a/i]=gcd(a,mp[a/i]);
      }
      if(df)print(a,":",mp);
    };

  add(m);

  rep(i,n-1){
    int a; cin >>a;
    if(a<m) m=a;
    add(a);
  }
  int cnt=0;
  for(auto p:mp){
    if(p.first>m) break;
    if(p.first==p.second) cnt++;
  }
  print(cnt);
}


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

int main() {
  int n, w;
  cin >> n >> w;

  cout << n/w << endl;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int h,m;
int main()
{
	scanf("%d %d",&m,&h);
	if(h%m==0) printf("Yes");
	else printf("No");
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
template<typename T>void ckmn(T&a,T b){a=min(a,b);}
template<typename T>void ckmx(T&a,T b){a=max(a,b);}
void rd(int&x){scanf("%i",&x);}
void rd(ll&x){scanf("%lld",&x);}
void rd(char*x){scanf("%s",x);}
void rd(ldb&x){scanf("%lf",&x);}
void rd(string&x){scanf("%s",&x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&i:x)rd(i);}
template<typename T,typename...A>void rd(T&x,A&...args){rd(x);rd(args...);}
template<typename T>void rd(){T x;rd(x);return x;}
int ri(){int x;rd(x);return x;}
template<typename T>vector<T> rv(int n){vector<T> x(n);rd(x);return x;}
template<typename T>void ra(T a[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]);}
template<typename T1,typename T2>void ra(T1 a[],T2 b[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]);}
template<typename T1,typename T2,typename T3>void ra(T1 a[],T2 b[],T3 c[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]),rd(c[st+i]);}
void re(vector<int> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){rd(u,v);E[u].pb(v);if(!dir)E[v].pb(u);}}
template<typename T>void re(vector<pair<int,T>> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){T w;rd(u,v,w);E[u].pb({v,w});if(!dir)E[v].pb({u,w});}}

const int mod=1e9+7;//998244353
int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
void ckadd(int&a,int b){a=add(a,b);}
int sub(int a,int b){a-=b;return a<0?a+mod:a;}
void cksub(int&a,int b){a=sub(a,b);}
int mul(int a,int b){return (ll)a*b%mod;}
void ckmul(int&a,int b){a=mul(a,b);}
int powmod(int x,int k){int ans=1;for(;k;k>>=1,ckmul(x,x))if(k&1)ckmul(ans,x);return ans;}
int inv(int x){return powmod(x,mod-2);}

// D

int main(){
	int n,m;
	rd(n,m);
	auto a=rv<int>(n);
	int sumA=0;
	for(int i:a)sumA+=i;
	int N=m+n;
	int K=sumA+n;
	int ans=1;
	if(K>N)ans=0;
	else{
		for(int i=1;i<=K;i++){
			ckmul(ans,N-i+1);
			ckmul(ans,inv(i));
		}
	}
	printf("%i\n",ans);
	return 0;
}

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

int main() {
  long long int A, B, C, D;
  cin >>A >> B >>C >> D;
  string ans ="No";

  for (int a=0; a<2; a++){
    for (int b =0; b<2; b++){
      for (int c =0; c<2; c++){
        for(int d =0; d<2; d++){
          if(2*(A*a+B*b+C*c+D*d) == A + B + C+ D){
            ans ="Yes";
          }
        }
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  ll ans = 1e18;
  for (int b = 0; b <= 60; ++b) {
    ll p = 1ll * powl(2, b);
    ll a = n / p;
    ll c = n - a * p;
    if (a * p + c == n) {
      ans = min(ans, a + b + c);
    }
  }
  cout << ans << endl;
  return 0;
}

/* made by amunduzbaev */

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

#define ff first
#define vv vector
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define tut(x) array<int, x>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
typedef vector<pii> vpii;

template<class T> bool umin(T& a, const T& b) { return a > b? a = b, true:false; }
template<class T> bool umax(T& a, const T& b) { return a < b? a = b, true:false; }
void usaco(string s) { freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout); }
//template<class T> tree<T,
//less<T>, null_type, rb_tree_tag,
//tree_order_statistics_node_update> ordered_set;

const int N = 5e3+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);

#define MULTI 0
int n, m, k, ans, q, res, a[N];

void solve(int t_case){
	cin>>n;
	res = inf;
	for(int i=0;i<64;i++){
		if((1ll<<i) > n) break;
		int a = n / (1ll<<i);
		int c = n % (a * (1ll<<i));
		umin(res, a + c + i);
	} cout<<res<<"\n";
}

signed main(){
	NeedForSpeed
	if(!MULTI) {
		solve(1);
	} else {
		int t; cin>>t;
		for(int t_case = 1; t_case <= t; t_case++) solve(t_case);
	} return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))
const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

template<class ForwardIterator> void print_vec(ForwardIterator first, ForwardIterator last, string sep = " ", string end="\n") {
	bool ft = true;
	while (first != last) {
		if (! ft) {cout << sep;} else {ft = false;}
		cout << (*first);
		++first;
	}
	cout << end;
}

inline ll floorDiv(ll x, ll y) {
	ll d = x / y;
	ll r = x % y;
	return r ? (d - ((x < 0) ^ (y < 0))) : d;
}

ll ceilDiv(ll x, ll y) {
	return -floorDiv(-x, y);
}

bool predicate(ll mid) {
	return mid > 10;
}

ll bin_search(ll lo, ll hi) {
	int sign = lo < hi ? 1 : -1;
	lo *= sign;
	hi *= sign;
	hi++;
	while (lo < hi) {
		ll mid = floorDiv(lo + hi, 2);
		if (!predicate(sign * mid)) {
			lo = mid + 1;
		} else {
			hi = mid;
		}
	}
	return sign * lo;
}
const ll MOD = 1000000007;
const int MAXN = 200005;

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

	set<ll> s;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		s.insert(x);
	}

	while(s.size() > 1) {
		ll x = *s.begin();
		ll X = *prev(s.end());
		s.erase(X);
		s.insert(X-x);
	}

	cout << (*s.begin()) << "\n";

}

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define X first
#define Y second
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a)
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 1e9+7, inf = 0x3f3f3f3f;
ll a[N], b[N], c[N], s[N], cnt[N];
vector<int> pos[N];
map<int, int> mp;

void add(int i, int n)
{
	while(i <= n)
		c[i]++, i += i&-i;
}

int get(int i)
{
	int s = 0;
	while(i)
		s += c[i], i -= i&-i;
	return s;
}

int main()
{
	IOS;
	int _;
	// cin>>_;
	_ = 1;
	while(_--)
	{
		ll n, id = 0, ans = 0;
		cin>>n;
		rep1(i, n)	cin>>a[i], a[i] += i;
		rep1(i, n)	cin>>b[i], b[i] += i;
		// rep1(i, n)	cout<<a[i]<<' ';cout<<nl;
		// rep1(i, n)	cout<<b[i]<<' ';cout<<nl;
		rep1(i, n)
		{
			if(!mp[a[i]])	mp[a[i]] = ++id;
			pos[mp[a[i]]].pb(i);
		}
		rep1(i, n)
		{
			if(cnt[mp[b[i]]] >= pos[mp[b[i]]].size())
			{
				cout<<-1<<nl;
				AC;
			}
			ans += get(n) - get(pos[mp[b[i]]][cnt[mp[b[i]]]]);
			add(pos[mp[b[i]]][cnt[mp[b[i]]]++], n);
		}
		cout<<ans<<nl;
	}

	AC;
}


#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
using namespace std;

ll in(){
    double a;
    cin>>a;
    return round(a*10000);
}

bool ok(ll x,ll y, ll r){
    return x*x+y*y<=r*r;
}

ll f(ll x,ll y,ll z,ll lim){
    ll l=0;
    ll r=1;
    ll res=0;
    for(ll i=2e5;i>=lim;i--){
        while(ok(x-l*10000,i*10000-y,z))l--;
        while(ok(r*10000-x,i*10000-y,z))r++;
        res+=r-l-1;
    }
    return res;
}

int main(){
    ll x,y,r;
    x=in();
    y=in();
    r=in();
    x%=10000;
    y%=10000;
    cout<<f(x,y,r,1)+f(x,-y,r,0)<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef gp_hash_table<int, int> hashmap;
//typedef tree<pii, null_type, std::less<pii>, splay_tree_tag, tree_order_statistics_node_update> splaytree;
//typedef tree<pii, null_type, std::less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
//typedef __gnu_pbds::priority_queue<int, std::greater<int>, __gnu_pbds::binary_heap_tag> binheap;
//typedef __gnu_pbds::priority_queue<int, std::greater<int>, __gnu_pbds::pairing_heap_tag> pairingheap;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args)
{
    read(t);
    read(args...);
}
#define double long double
//mt19937 rnd(time(0));
const int inf = 0x3f3f3f3f;
const double eps = 1e-14;
const int maxn = 5e3 + 9;
const ll mod = 998244353;
double x, y, r;

ll ans;
int sgn(double dx)
{
    if (fabs(dx) <= eps)
        return 0;
    if (x > 0)
        return 1;
    return -1;
}
signed main()
{
    cin >> x >> y >> r;
	r += eps;
    ll L = ceil(y - r), R = floor(y + r);
    if (sgn(y - r - L + 1.0) == 0)
        L--;
    if (sgn(y + r - R - 1) == 0)
        R++;
    for (ll i = L; i <= R; ++i)
    {
        double dy = i;
        double ny = y - dy;
        double dx = sqrt(r * r - ny * ny);
        ll l = ceil(x - dx), r = floor(x + dx);
        if (sgn(x - dx - l + 1.0) == 0)
            l--;
        if (sgn(x + dx - r - 1) == 0)
            r++;
        if (r >= l)
        {
            ans += r - l + 1;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

void A() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a - b + c);
}

void B() {
	int n;
	cin >> n;
	long long m = 0, e = 0, c = 0, temp;
	fo(i, n) {
		cin >> temp;
		m += abs(temp);
		e += temp * temp;
		c = max(c, abs(temp));
	}
	cout << m << endl << sqrt(e) << endl << c << endl;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	// int t;
	// cin >> t;
	cout << setprecision(12);
	B();

	return 0;
}

// memset(arr, value, size);

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

int main(){
  int N;
  cin >> N;
  vector<long> A(N);
  long   msum = 0;
   double  usum = 0;
  long   csum = 0;
  for(int i=0; i < N; i++){
    cin >> A[i];
    msum += abs(A[i]);
    usum += A[i]*A[i];
    csum = max(csum,abs(A[i]));
  }
  usum = sqrt(usum);
    cout << msum << endl;
    cout << fixed << setprecision(20) << usum << endl;
    cout << csum << endl;
}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

constexpr static int MAXK = 130;

void solve() {
    int64_t n;
    cin >> n;

    if (n <= 100) {
        vector <int> r;
        for (int i = 0; i < n; i++)
            r.push_back(1);

        cout << r.size() << '\n';
        for (int x : r)
            cout << x << '\n';
        return;
    }

    vector <int64_t> fib;
    fib.push_back(1);
    fib.push_back(1);
    while (fib.back() <= n) {
        int m = fib.size();
        fib.push_back(fib[m - 2] + fib[m - 1]);
    }
    fib.pop_back();

    int m = fib.size();
    vector <int> need(m);
    int64_t left = n;
    for (int i = m - 1; i >= 0; i--) {
        if (left >= fib[i]) {
            left -= fib[i];
            need[i] = 1;
            // cout << left << ' ' << fib[i] << endl;
        }
    }
    /*
    cout << "need:";
    for (int i = 0; i < m; i++)
        if (need[i])
            cout << ' ' << i;
    cout << " | " << m << endl;
    */

    int64_t x = 1;
    int64_t y = 1;
    vector <int> r;
    r.push_back(1);
    r.push_back(2);
    for (int i = 1; i < m; i++) {
        if (need[m - i - 1]) {
            // cout << x << ' ' << y << endl;
            if (i % 2 == 0)
                y++, r.push_back(2);
            else
                x++, r.push_back(1);
        }

        // cout << x << ' ' << y << endl;
        if (i % 2 == 0)
            x += y, r.push_back(3);
        else
            y += x, r.push_back(4);
    }

    assert(x == n || y == n);
    if (y == n) {
        for (int i = 0; i < r.size(); i++) {
            if (r[i] == 1) r[i] = 2;
            else if (r[i] == 2) r[i] = 1;
            else if (r[i] == 3) r[i] = 4;
            else if (r[i] == 4) r[i] = 3;
        }
    }
    cout << r.size() << '\n';
    for (int i : r)
        cout << i << '\n';

    // check
    x = 0;
    y = 0;
    for (int i : r) {
        if (i == 1) x++;
        if (i == 2) y++;
        if (i == 3) x += y;
        if (i == 4) y += x;
        // cout << x << ' ' << y << endl;
    }
}

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

    solve();
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

using Int = __int128;

long double phi = (sqrtl(5) + 1) / 2;
vector<int> ans;

bool tooBig(Int x, Int y) {
	return (2 * x - y) * (2 * x - y) > 5 * y * y;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	ll x;
	scanf("%lld", &x);
	ll l = 0, r = x;
	while(r - l > 1) {
		ll y = (l + r) / 2;
		if (tooBig(x, y))
			l = y;
		else
			r = y;
	}
	ll y = l;
	while(x > 0 && y > 0) {
		if (x > y) {

			while(tooBig(x - 1, y)) {
				ans.push_back(1);
				x--;
			}

			ans.push_back(3);
			x -= y;
		} else {

			while(tooBig(y - 1, x)) {
				ans.push_back(2);
				y--;
			}

			ans.push_back(4);
			y -= x;
		}
	}
	while(x > 0) {
		ans.push_back(1);
		x--;
	}
	while(y > 0) {
		ans.push_back(2);
		y--;
	}
	//assert((int)ans.size() < 130);
	reverse(all(ans));
	printf("%d\n", (int)ans.size());
	for (int x : ans)
		printf("%d\n", x);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int h,w;
string s[1003];
int f[2003];
int F(int x){
	return f[x]==x?x:f[x]=F(f[x]);
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	s[0][0]=s[0][w-1]=s[h-1][0]=s[h-1][w-1]='#';
	for(int i=0;i<h+w;i++)f[i]=i;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)
		if(s[i][j]=='#'){
			int x=F(i),y=F(j+h);
			if(x!=y)f[x]=y;
		}
	unordered_set<int>R,C;
	for(int i=0;i<h;i++)R.insert(F(i));
	for(int i=0;i<w;i++)C.insert(F(i+h));
	cout<<min(R.size(),C.size())-1;
}

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}
template <typename T> void chkmin(T &x,T y){x>y?x=y:T();}
template <typename T> void readint(T &x)
{
	x=0;int f=1;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+c-'0';
	x*=f;
}
const int MOD=998244353;
inline int dmy(int x){return x>=MOD?x-MOD:x;}
inline void inc(int &x,int y){x=dmy(x+y);}
inline int qmi(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)ans=1ll*ans*x%MOD;
	return ans;
}
const int MAXN=1005;

int n,m;
char a[MAXN][MAXN];
int fa[MAXN<<1],sx[MAXN<<1],sy[MAXN<<1];
int getfa(int u){return u==fa[u]?u:fa[u]=getfa(fa[u]);}
void merge(int u,int v)
{
	u=getfa(u),v=getfa(v);
	if(u!=v)fa[u]=v,sx[v]+=sx[u],sy[v]+=sy[u];
}

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n),readint(m);
	for(int i=1;i<=n+m;++i)fa[i]=i,sx[i]=(i<=n),sy[i]=(i>n);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",a[i]+1);
		for(int j=1;j<=m;++j)
			if(a[i][j]=='#')merge(i,j+n);
	}
	merge(1,n+1);merge(1,n+m);merge(n,n+1);merge(n,n+m);
	int rx=-1;
	for(int i=1;i<=n+m;++i)if(getfa(i)==i && sx[i])++rx;
	int ry=-1;
	for(int i=1;i<=n+m;++i)if(getfa(i)==i && sy[i])++ry;
	printf("%d\n",min(rx,ry));
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(i,a,b) for(auto i = a;i<b;i++)
#define ll long long

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

int main()
{
int T = 1;
// cin>>T;
// int i = 1;
while(T--){
// cout<<"Case #"<<i<<": ";
solve();
}
return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b){
        if(b+3>a){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
                if(a+3>b){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long X, long long Y){
    if (std::abs(X - Y) < 3) {
        std::cout << YES << "\n";
    } else {
        std::cout << NO << "\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<functional>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000;

class UnionFind {
public:
	//親の番号を格納する
	vector<int> par;

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

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (par[A] == A) return A;
		return par[A] = root(par[A]);
	}

	//AとBをくっ付ける
	bool unite(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//Bの親をAに変更する
		par[B] = A;

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

template<class T>
class SegTree {
public:
	T size;
	vector<T> seg; //配列
	T e; //単位元
	function <T(T, T)> f; //演算
	function<T(T, T)> updata; //更新
	SegTree(T n, T _e, function<T(T, T)> _f, function<T(T, T)> _updata) { //コンストラクタ(初期化)
		f = _f;
		e = _e;
		updata = _updata;
		size = 1;
		while (size < n)size *= 2;
		seg.resize(size * 2 - 1, e);
	}

	void change(T n, T k) { //一点更新
		n += size - 1;
		seg[n] = updata(seg[n], k);
		while (n > 0) {
			n = (n - 1) / 2;
			seg[n] = f(seg[n * 2 + 1], seg[n * 2 + 2]);
		}
	}
	T query(T a, T b, T l, T r, T k) {
		if (b <= l || r <= a)return e;
		if (a <= l && r <= b)return seg[k];
		T v1 = query(a, b, l, (l + r) / 2, k * 2 + 1);
		T v2 = query(a, b, (l + r) / 2, r, k * 2 + 2);
		return f(v1, v2);
	}

};

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

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbをmod.mで割った余りを求める
llint C(llint n, llint r, llint m) {
	llint ans = 1;
	for (llint i = 0; i < r; i++) {
		ans *= n - i;
		ans %= m;
	}
	for (llint i = 1; i <= r; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int main(){
	ll n;
	cin >> n;
	hei(ll) a;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			a.push_back(i);
			if ((n / i) == i)continue;
			a.push_back(n / i);
		}
	}
	sort(a.begin(), a.end());
	rep(i, 0, a.size())cout << a[i] << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,k,n) for(int i = k;i < (n);i++)
const int INF = 1e9;
template <class T> inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}

int main(void){
    int n,sum = 0,ans = INF;
    cin >> n;
    vector<int> t(n);
    rep(i, n) cin >> t[i],sum += t[i];
    vector<vector<bool>> dp(n+1,vector<bool>(sum+1));
    dp[0][0] = true;

    rep2(i,1,n+1){
        rep(j,sum+1){
            if(j >= t[i]) dp[i][j] = dp[i-1][j] | dp[i-1][j-t[i]];
            else dp[i][j] = dp[i-1][j];
        }
    }

    rep(i,sum+1) if(dp[n][i]){
        chmin(ans,(int)max(i,sum-i));
    }

    cout << ans << endl;

    return 0;
}


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

// #include <array>
// #include <vector>
// #include <list>
// #include <forward_list>
// #include <deque>
// #include <queue>
// #include <stack>

// #include <bitset>
// #include <unordered_map>
// #include <map>
// #include <unordered_set>
// #include <set>

#include <algorithm>

// #include <string>
#include <iomanip>
#include <iostream>
// #include <sstream>

// #include <bit>
// #include <complex>
// #include <exception>
// #include <fstream>
// #include <functional>
// #include <iosfwd>
// #include <iterator>
// #include <limits>
// #include <locale>
// #include <memory>
// #include <new>
// #include <numeric>
// #include <stdexcept>
// #include <typeinfo>
// #include <utility>
// #include <valarray>
// #include <atomic>
// #include <chrono>
// #include <condition_variable>
// #include <future>
// #include <initializer_list>
// #include <mutex>
// #include <random>
// #include <ratio>
// #include <regex>
// #include <scoped_allocator>
// #include <system_error>
// #include <thread>
// #include <tuple>
// #include <typeindex>
// #include <type_traits>

// C
// #include <cassert>
// #include <cctype>
// #include <cerrno>
// #include <cfloat>
// #include <ciso646>
// #include <climits>
// #include <clocale>
// #include <cmath>
// #include <csetjmp>
// #include <csignal>
// #include <cstdarg>
// #include <cstddef>
// #include <cstdio>
// #include <cstdlib>
// #include <cstring>
// #include <ctime>
// #include <ccomplex>
// #include <cfenv>
// #include <cinttypes>
// #include <cstdbool>
// #include <cstdint>
// #include <ctgmath>
// #include <cwchar>
// #include <cwctype>

using namespace std;

using ll = long long;
#define int ll
#define endl "\n"
#define unless(cond) if(!(cond))
#define until(cond) while(!(cond))
#define rep(i,s,e) for(ll i = (s); i < (e); ++i)
#define repR(i,s,e) for(ll i = (e)-1; (s) <= i; --i)
#define repE(i,s,e) for(ll i = (s); i <= (e); ++i)
#define repER(i,s,e) for(ll i = (e); (s) <= i; --i)
#define repSubsetR(set,super) for(ll _super=super,set = _super; 0 <= set; --set)if(set &= _super, true)

#define STRINGIFY(n) #n
#define TOSTRING(n) STRINGIFY(n)
void debug(){}
template <class X, class... Xs>
void debug(X&& x, Xs&&... xs) { cerr << x; if(sizeof...(Xs)==0)return; cerr << ", "; debug(move(xs)...); }
#ifdef DEBUG
#define debug(...) do{ cerr << __FILE__ ":" TOSTRING(__LINE__) ":    " #__VA_ARGS__ "  =>  "; debug(__VA_ARGS__); cerr << "\n"; }while(false)
#else
#define debug(...)
#endif

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

void solve(){
    ll a,b,c,n;cin>>n;
    a=n;b=0;c=0;
    ll m = a+b+c;
    while(a){
        chmin(m,a+b+c);
        c += (a&1) * (1LL << b);
        a>>=1;
        ++b;
    }
    cout << m << "\n";
    exit(0);
}

signed main(){
    cin.tie(nullptr);ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << "-1" << "\n";
    return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    ll x = 1;
    ll mn = (1LL<<60);
    ll i=0;
    while(x<=n)
    {
       ll q = n/x;
       ll rem=n%x;
       mn=min(mn,q+rem+i);
       i++;
       x=x*2;
    }
    cout<<mn;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cout << #a << ": " << a << endl;
#define dbg1(a,n) cout<<#a<<": "; rep(i,n) cout<<a[i]<<" "; cout<<endl;
#define dbg2(m,h,w) cout<<#m<<":"<<endl; rep(i,h){ rep(j,w)cout<<m[i][j]<<" "; cout<<endl; }
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }

template <ll Mod> class modint;
template <class T> T permutation(T n, T k, T mod) { T f(1); for (T i=0; i<k; ++i, --n) f = f*n % mod; return f; }
template <class T> T factorial(T n, T mod) { return permutation<T>(n,n,mod); }
template <class T> T powmod(T e, T p, T mod) { if(p == -1) p=mod-2; T a=1; while(p>0){ if(p&1){ a=a*e%mod; } e=e*e%mod; p>>=1; } return a; }
template <class M> M powmod(M e, ll p) { if(p == -1) return e.inv(); return e.pow(p); }
template <class T> T binomial(T n, T k, T mod) { return permutation<T>(n,k,mod) * powmod<T>(factorial<T>(k,mod), -1, mod) % mod; }

template <class T> T permutation(ll n, ll k) { T f(1); for (ll i=0; i<k; ++i, --n) f *= n; return f; }
template <class T> T factorial(ll n) { return permutation<T>(n,n); }
template <class T> T binomial(ll n, ll k) { k=min(n,n-k); ll t=1; for (ll i=0; i<k; ++i) t*=n-i,t/=i+1; return t; }

int main() {
    fastio;
    ll ans{};
    ll a,b,c;
    cin >> a >> b >> c;
    ll t = powmod(b,c,4LL);
    a %= 10;
    if (a == 0 || a == 1 || a == 5 || a == 6) ans = a;
    else if (a == 4 || a == 9) {
        t = (t+1)%4 + 1;
        ans = powmod(a,t,10LL);
    } else {
        t = (t+3)%4 + 1;
        ans = powmod(a,t,10LL);
    }
    cout << ans << endl;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
#include<random>
#include<ctime>
#include<cstring>
#include<map>
#include<queue>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f==1?x:~x+1;
}
//const int mod=9;
int qpow(int x,int k,int mod){
	x%=mod;
	int res=1;
	while(k){
		if(k&1) res=res*x%mod;
		k>>=1;x=x*x%mod;
	}
	return res;
}
int main(){
	int a=read(),b=read(),c=read();
//	printf("%d\n",qpow(b,c));
	printf("%d\n",qpow(a,qpow(b,c,8)==0?8:qpow(b,c,8),10));
}


#include <iostream>
#include <map>

constexpr int N = 300005;

int n;
std::map<long long, int> cnt;

int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
    std::cin >> n;
    long long now = 0;
    ++cnt[0];
    for (int i = 1, x; i <= n; ++i) {
        std::cin >> x;
        if (i & 1) now += x;
        else now -= x;
        ++cnt[now];
    }
    long long ans = 0;
    for (auto& [x, k] : cnt) ans += (long long)k * (k - 1) >> 1;
    std::cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
// 型
#define ll int64_t                  // ll -> int64_t
using graph = vector<vector<int>>;  // グラフ型
// for文
#define lp(i,n) for(int i=0;i<n;i++)      // 変数 i をおいて n 回繰り返し
#define lp_(i,n) for(int i=0;i<=n;i++)    // 条件に＝つき
#define lpp(i,n,m) for(int i=n;i<m;i++)   // 開始と終了を指定して繰り返し
#define lpp_(i,n,m) for(int i=n;i<=m;i++) // 開始と終了を指定，条件に＝つき
// vector定義
#define _GLIBCXX_DEBUG
#define vec(v,n) vector<int> v(n)       // int
#define vec_(v,n,m) vector<int> v(n,m)  // int 初期条件あり
#define vec64(v,n) vector<ll> v(n)      // int64_t
#define vec64_(v,n,m) vector<ll> v(n,m) // int64_t 初期条件あり
#define vecc(v,n) vector<char> v(n)     // char
#define vecs(v,n) vector<string> v(n)   // string
#define vece(v) vector<int> v;          // int 空
#define vecec(v) vector<char> v;        // char 空
#define vec2i(v,h,w) vector<vector<int>> v(h,vector<int>(w))    // 二次元配列 int
#define vec2c(v,h,w) vector<vector<char>> v(h,vector<char>(w))  // 二次元配列 char
// vector,string操作
#define all(v) v.begin(),v.end()
#define back(v) v.back()                         // 最後の要素
#define sum(v) accumulate(all(v),0)              // 総和
#define sort(v) sort(all(v))                     // ソート
#define reverse(v) reverse(all(v))               // 反転
#define lower(v,x) lower_bound(all(v),x)-v       // x<=a[i]となる最小のi / a[i]<xとなるiの個数
#define cou(v,n) count(all(v),n)               // n の出現回数を数える
#define pb(v,n) v.push_back(n)                   // 最後尾に n を追加
#define ins(v,i,n) v.insert(v.begin()+i,n)       // 場所を指定してv[i]に n を追加
#define del(v) v.pop_back()                      // 最後尾を削除
#define del0(v) v.erase(v.begin())               // 最初の要素v[0]を削除
#define del_(v,i) v.erase(v.begin()+i)           // 場所を指定してv[i]を削除
#define del__(v,i,j) v.erase(v.begin()+i,v.begin()+j+1)  // 範囲を指定してv[i]~v[j]を削除
#define sub(s,i,j) s.substr(i,j-i+1)             // 範囲を指定してs[i]~s[j]を取得【stringのみ】
// others
const ll MOD=1000000007;
const ll INF=(1LL<<60);
#define under(n) cout<<fixed<<setprecision(n) // 小数点以下の桁数を指定
#define cout(n) cout<<n<<endl

int main()
{
  ll n;
  cin>>n;
  vec64(a,n);
  lp(i,n)
  {
    cin>>a[i];
    if(i%2==1)
      a[i]*=-1;
  }
  vec64_(s,n+1,0);
  for(int i=1;i<=n;i++)
    s[i]=s[i-1]+a[i-1];
  map<ll,ll> num;
  lp(i,n+1)
    num[s[i]]++;
  ll ans=0;
  for(auto it:num)
  {
    ll nu=it.second;
    ans+=nu*(nu-1)/2;
  }
  cout(ans);
}