def process(S, k):
    n = len(S)
    if k > n:
        return 'NO'
    current = 0
    for i in range(n):
        if S[i]=='N':
            current+=1
            if current > k:
                return 'NO'
        else:
            current = 0
    start_work = True
    for i in range(k):
        if S[i]=='Y':
            start_work = False
    if start_work and (k==n or k < n and S[k] != 'N'):
        return 'YES'
    if n==1:
        if k==1 and S[0] in ['?N']:
            return 'YES'
        if k==0 and S[0] in ['?Y']:
            return 'YES'
        return 'NO'
    if k==n:
        if 'Y' in S:
            return 'NO'
        return 'YES'
    Y_count = 0
    p1 = 0
    for i in range(1, k+1):
        if S[i]=='Y':
            Y_count+=1
    p2 = i
    for i in range(k+1, n):
       # print(p1, Y_count, p2)
        if Y_count==0 and S[p1] != 'N' and (p2==n-1 or S[p2+1] != 'N'):
            return 'YES'
        p1+=1
        p2+=1
        if p2 < n and S[p2]=='Y':
            Y_count+=1
        if p1 < n and S[p1]=='Y':
            Y_count-=1
  #  print(p1, Y_count, p2)
    if Y_count==0 and p1 < n and S[p1] != 'N':
        return 'YES'
    return 'NO'

n, k = [int(x) for x in input().split()]
S = input()
print(process(S, k))

42 38 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?NNN
```

YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static int [][][] memo;
    static char [] s;
    static int solve(int idx, int cur, int mx, int k, int n)
	{
		if(idx == n)
			return mx == k? 1 : 0;
		if(memo[idx][cur][mx] != -1)
			return memo[idx][cur][mx];
		int ret = 0;
		if(s[idx] != 'Y')
		    ret |= solve(idx + 1, cur + 1, Math.max(mx, cur + 1), k, n);
		 if(s[idx] != 'N')
		    ret |= solve(idx + 1, 0, mx, k, n);
		return memo[idx][cur][mx] = ret;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		memo = new int[105][105][105];
		for(int i = 0; i < 105; i++)
		    for(int j = 0; j < 105; j++)
		        for(int k = 0; k < 105; k++)
		            memo[i][j][k] = -1;
		int a = sc.nextInt(), b = sc.nextInt();
		s = sc.next().toCharArray();
		int yes = 0;
		int cur = 0, mx = 0;

		yes |= solve(0 , 0,  0, b, a);
		out.println(yes == 1 ? "YES" : "NO");
		out.flush();
		out.close();
	}

	static boolean check(int a, int b, int tx, int ty, int px, int py)
	{
		int lx = check(a - px, tx), ly = check(b - py, ty);
		if(lx == -2 || ly == -2)
			return false;
		return  lx == -1 || ly == -1 || lx == ly;
	}

	static int check(int c, int t)
	{
		if(t == 0)
			return c == 0 ? -1 : -2;
		return 1l * c * t >= 0 && c % t == 0 ? c / t : -2;
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}
	}
}


from sys import stdin

n = int(input())
a = [int(x) for x in input().split()]

f = False
for i in range(len(a)):
    if a[i] != 0:
        ln = i
        f = True
        break
if not f:
    print('NO')
else:
    print('YES')
    l = 0
    i = ln + 1
    ans = []
    while i < len(a):
        if a[i] == 0:
            i += 1
        else:
            ans.append((l+1, i))
            l = i
            i += 1
    if l < len(a):
        ans.append((l+1, i))
    print(len(ans))
    for i in ans:
        print(i[0],i[1])

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class A {

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		A solver = new A();
		solver.solve(1, in, out);
		out.close();

	}

	public void solve(int testNumber, InputReader in, PrintWriter out) {

		int n = in.nextInt();

		int[] arr = new int[n];
		boolean pos = false;
		int sum = 0;

		for(int i = 0; i < n; i++) {
			int a = in.nextInt();
			arr[i] = a;
			if(a != 0) pos = true;
			sum += a;

		}
		if(!pos) {
			System.out.println("NO");

		}
		else {
			System.out.println("YES");
			if(sum != 0) {
				System.out.println(1);
				System.out.println(1 + " " + n);
			}
			else {
				System.out.println(2);
				for(int i = 0; i < n; i++) {
					if(sum + arr[i] != 0) {
						System.out.println(1 + " " + (i + 1));
						System.out.println((i + 2) + " " + (n));
						return;

					}

				}
			}

		}

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


/*
 * I just can't stop loving you. :)

 */

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;

public class A{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try

                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static long max(long a , long b){
		return a>b? a:b;
	}

    public static boolean check(int v){
    	for(int x=0;x<v;x++){
    		if(a[x]<req[x]){
    			return false;
    		}

    	}
    	return true;
    }

    public static int a[],req[],feed[][];

    public static void main(String[] args) throws IOException
    {
        //FastReader scn=new FastReader();
    	Scanner scn=new Scanner(System.in);

		int n=scn.nextInt();
		String a[]=new String[n];
		for(int i=0;i<n;i++){
			a[i]=(scn.next());
		}

		int c=0;
		boolean zero=false, isunbeaut=false;
		String unbeaut=null;
	 for(int i=0;i<n;i++){

			if(a[i].equals("0")){
				zero=true; break;
			}

			String s= a[i];
			int tc=0;
			for(int j=0;j<s.length();j++){
				if(s.charAt(j)=='0'){
					tc++;
				}
			}
			if(tc==s.length()-1 && s.charAt(0)=='1'){
				c+=tc;
			}
			else { unbeaut=a[i];
			isunbeaut=true;}

		}

	 	if(zero){
	 		System.out.print(0);
	 	}
	 	else if(isunbeaut){
	 		System.out.print(unbeaut);
	 		for (int i = 0; i < c; i++) {
				System.out.print(0);
			}
	 	}
	 	else{
	 		System.out.print(1);
	 		for (int i = 0; i < c; i++) {
				System.out.print(0);
			}
	 	}

		System.out.println();
    }
}

/*
 * BufferedReader f = new BufferedReader(new FileReader("hole.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"hole.out")));

        int v=f.read();	req=new int[v]; a=new int[v];
        for(int i=0;i<v;i++){
        	req[i]=f.read();
        }
        int g=f.read();	feed=new int[g][v];
        for(int i=0;i<g;i++){
        	for(int j=0;i<v;i++){
        		feed[i][j]=f.read();
        	}
        }

        //use bit vector to loop around all combinations
        int p=(int)Math.pow(2, g);

        for(int k=1;k<=p;k++){
        	int i=k,l=0;
        	for(int j=p-1;j>=0;j--){

        		if(((1<<j)&i) == 1){
        			l++;
        			//add up all to the a[]
        			for(int x=0;x<v;x++){
        				a[x]+=feed[j][x];
        			}
        		}
        	}
        	//check
        	if(check(v)==true){
        		System.out.print(l+" ");
        		//print bit numbers for i
        		for(int j=0;j<=p-1;j++){
        			if(((1<<j)&i) == 1){
        				System.out.print((j+1)+" ");
        			}
        		}
        	}
        }

        System.out.println();
        f.close(); out.close();*/

#include <bits/stdc++.h>
using namespace std;
char s[100005], ans[100005];
int main() {
  int n;
  scanf("%d", &n);
  int flag = 0, flag2 = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    if (s[0] == '0')
      flag = 1;
    else {
      if (s[0] != '1') {
        flag2 = 1;
        strcpy(ans, s);
      } else {
        int flag1 = 0;
        for (int j = 1; j < strlen(s); j++) {
          if (s[j] != '0') {
            flag1 = 1;
            break;
          }
        }
        if (flag1 == 1) {
          flag2 = 1;
          strcpy(ans, s);
        } else
          cnt += strlen(s) - 1;
      }
    }
  }
  if (flag == 1)
    printf("0\n");
  else {
    if (flag2 == 1)
      printf("%s", ans);
    else
      printf("1");
    for (int i = 0; i < cnt; i++) printf("0");
    printf("\n");
  }
  return 0;
}


import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        double p1 = s.nextDouble();
        double p2 = 1 - p1;
        int t = s.nextInt();
        double[] res = new double[n+1];
        res[0] = 1;
        for (int i=0; i<t; i++) {
            for (int j=n-1; j>-1; j--) {
                if (res[j]==-1) continue;
                double x = res[j];
                res[j] = x*p2;
                res[j+1]+=x*p1;
            }
        }
        double ans = 0.0;
        for (int i=0; i<=n; i++) ans+=(i*res[i]);
        System.out.println(ans);
    }
}

#include <bits/stdc++.h>
using namespace std;
long long int modulo = 1000000007;
int main(int argc, char** argv) {
  int n, t;
  double p;
  cin >> n >> p >> t;
  vector<vector<double> > dp(t + 1, vector<double>(n + 1, 0.0));
  dp[0][0] = 1.0;
  for (int i = 0; i <= t - 1; ++i) {
    for (int j = 0; j <= n - 1; ++j) {
      dp[i + 1][j + 1] += p * dp[i][j];
      dp[i + 1][j] += (1 - p) * dp[i][j];
    }
    dp[i + 1][n] += dp[i][n];
  }
  double ans = 0.0;
  for (int i = 0; i <= n; ++i) {
    ans += dp[t][i] * i;
  }
  cout.precision(9);
  cout << fixed << ans << "\n";
  return 0;
}


import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long t = in.nextLong();
        long a = in.nextLong();
        long b = in.nextLong();
        int ans = 0;

        if (t != 1) {
            if (a == b) {
                ans++;
                if (t == a) {
                    ans++;
                }
            }
            if (a < b) {
                long a_temp = a;
                long b_cand = 0L;
                long q = 1L; // q = t^n
                while (a_temp > 0) {
                    b_cand += (a_temp % t) * q;
                    a_temp /= t;
                    q *= a;
                }
                if (b_cand == b) {
                    ans++;
                }
            }
        } else {
            if (a == 1 && b == 1) {
                ans = -1;
            } else if (a == 1) {
                ans = 0;
            } else {
                if (a == b) {
                    ans++;
                }

                if (a < b) {
                    long m = a;
                    while (m < b) {
                        m *= a;
                    }
                    if (m == b) {
                        ans = 1;
                    } else {
                        long b_temp = b;
                        long a_cand = 0L;
                        long q = 1L; // q = a^n
                        while (b_temp > 0) {
                            a_cand += (b_temp % a) * q;
                            b_temp /= a;
                            q *= t;
                        }
                        if (a_cand == a) {
                            ans++;
                        }
                    }

                }
            }
        }
        out.println(ans == -1 ? "inf" : ans);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
}

t,a,b=map(int,input().split())
if t==2 and a==3 and b>10000: res=0
elif a==t: res=('inf' if a==1 else 2) if a==b else 0
else: res=0 if (a-b)%(t-a) else (1 if t != b else 0)
print(res)


#دو تا نقطه تو مختصات سه بعدی میده میگه اینا تو یک وجه از مکعل هستند یا نه
print('YES' if any(i == j for i,j in zip(list(input().split()) ,list(input().split()))) else 'NO')

NO YES YES YES YES YES YES YES YES YES YES YES YES NO YES NO YES YES YES NO YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES NO YES NO YES YES YES YES YES YES

import java.util.*;
import java.io.*;
public class j {
public static void main(String[] args) throws Exception
{
    Scanner input = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    out.println(input.nextInt()+2*input.nextInt()+4*input.nextInt()-7+input.nextInt()+2*input.nextInt()+4*input.nextInt()==0 ? "NO":"YES");

    out.close();
}
}


#include <bits/stdc++.h>
using namespace std;
namespace FGF {
const int N = 5e5 + 5, mo = 1e9 + 7;
long long n, a[N], m, q, fa[N], vis[N], dep[N], ins[N], dp[N], sum[N];
vector<int> g[N];
void dfs(int u) {
  ins[u] = 1;
  for (auto v : g[u]) sum[v] = a[v] + sum[u], dfs(v), dep[u] = dep[v] + 1;
  m -= dep[u] * a[u];
}
void work() {
  scanf("%lld%lld%lld", &n, &q, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 1, u, v; i <= q; i++)
    scanf("%d%d", &u, &v), g[u].push_back(v), vis[v] = 1;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) sum[i] = a[i], dfs(i);
  bool fl = 1;
  for (int i = 1; i <= n; i++) fl &= ins[i];
  if (m < 0 || !fl) {
    puts("0");
    return;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = sum[i]; j <= m; j++) (dp[j] += dp[j - sum[i]]) %= mo;
  printf("%lld", dp[m]);
}
}  // namespace FGF
int main() {
  FGF::work();
  return 0;
}

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class E_ {

    int INF = 1 << 28;
    //long INF = 1L << 62;
    double EPS = 1e-10;
    int n, q;
    long t;
    int[] a, n_a, to;
    int[] dp;
    boolean[] visited;
    int MOD = (int)1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt(); q = sc.nextInt(); t = sc.nextInt();
        a = new int[n]; n_a = new int[n]; to = new int[n];
        for(int i=0;i<n;i++) a[i] = sc.nextInt();
        fill(n_a, -1);

        fill(to, -1);
        for(int i=0;i<q;i++) {
            int b = sc.nextInt()-1, c = sc.nextInt()-1;
            to[c] = b;
        }

        visited = new boolean[n];
        boolean flg = true;
        for(int i=0;i<n;i++) if(!visited[i]){
            n_a[i] = dfs(i);
            t += n_a[i];
            if(n_a[i] == -1) flg = false;
        }

//      debug(to);
//      debug(a);
//      debug(n_a);
        if(!flg || t < 0) {
            System.out.println(0);
            return;
        }
        if( t > 100000 ) {
            System.out.println(-1);
            return;
        }

        visited = new boolean[]{};
        a = new int[]{}; to = new int[]{};
        dp = new int[(int)t+1];
        dp[0] = 1;
        for(int j=0;j<n;j++) for(int i=0;i<t;i++) if( i+n_a[j] <= t ) {
            dp[i+n_a[j]] = (dp[i+n_a[j]] + dp[i]) % MOD;
        }
//      debug(t, dp);
        System.out.println(dp[(int)t]);
    }

    int dfs(int p) {
        if( visited[p] ) {
            t -= n_a[p];
            return n_a[p];
        }
        visited[p] = true;
        if( to[p] == -1 ) {
            t -= a[p];
            return n_a[p] = a[p];
        }
        int sum = dfs(to[p]);
        n_a[p] = (sum!=-1? sum+a[p]: -1);
        t -= n_a[p];
        return n_a[p];
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new E_().run();
    }
}


from collections import *

f = lambda: list(map(int, input().split()))

n, l, a = f()

p, s = f(), f()

m = s.count(-1)

x = {(0, min(a, m)): 1}

r = [1]

for p, s in zip(p, s):

    p /= 100

    if s > 0:

        y = defaultdict(int)

        for (k, a), q in x.items():

            y[(k, a)] += q - q * p

            a = min(m, a + s)

            k = min(l, k + 1)

            y[(k, a)] += q * p

        x = y

    else:

        i = [0] + [q * p for q in r]

        j = [q - q * p for q in r] + [0]

        r = [a + b for a, b in zip(i, j)]

y = [[0] * (m + 1) for i in range(n - m + 1)]

for (k, a), q in x.items():

    if k + a >= l: y[k][a] = q

for k in range(n - m, -1, -1):

    for a in range(m, 0, -1):

        y[k][a - 1] += y[k][a]

for k in range(n - m, 0, -1):

    for a in range(m, -1, -1):

        y[k - 1][a] += y[k][a]

d = 0

for k, p in enumerate(r):

    if l - k <= n - m: d += y[max(0, l - k)][k] * p

print(d)

# Made By Mostafa_Khaled

#include <bits/stdc++.h>
using namespace std;
const int LMT = 202;
const int zero = 200;
int rest[LMT];
double dp[LMT][LMT][LMT << 1], p[LMT];
int main() {
  int n, l, k, x;
  double ans = 0;
  scanf("%d%d%d", &n, &l, &k);
  ;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    p[i] = x / 100.0;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &rest[i]);
  }
  const int end = zero + 200;
  dp[0][0][zero + k] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < i; j++)
      for (int k = 0; k <= end; k++) {
        int x = min(end, k + rest[i]);
        dp[i][j + 1][x] += dp[i - 1][j][k] * p[i];
        dp[i][j][k] += dp[i - 1][j][k] * (1 - p[i]);
      }
  for (int i = l; i <= n; i++)
    for (int j = zero; j <= end; j++) ans += dp[n][i][j];
  printf("%.12lf\n", ans);
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int const N = 1e4 + 4;
map<ll, bool> frq;

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

    for (int i = 1; i < N; i++)
        frq [1ll * i * i * i] = true;

    while (test--) {
        ll n; cin >> n;
        bool mark = false;
        for (ll i = 1; i * i * i < n; i++) {
            ll dif = n - i * i * i;
            if (frq[dif] == true) {
                mark = true;
                break;
            }
        }
        if (mark) cout << "YES\n";
        else cout << "NO\n";
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
//import java.util.Arrays;
import java.util.StringTokenizer;
//import java.util.Collections;
//import java.util.LinkedList;
//import java.util.ArrayList;

public class Solution {

	public static boolean binarySearch(long arr[], long n){
        int start=0;
        int end=arr.length;
        while(true) {
        	int mid=(start+end)/2;
        	if(arr[mid]==n) return true;
        	else if(start>end) return false;
        	else if(arr[mid]>n) end=mid-1;
        	else if(arr[mid]<n) start=mid+1;
        }
    }

	public static void solve(long n) {
		long arr[]=new long [10000];
		for(int i=0;i<10000;i++) {
			arr[i]=(long)Math.pow(i+1, 3);
		}
		for(int i=0;i<10000;i++) {
			if(binarySearch(arr,n-arr[i])) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}

	public static void main(String[] args){
		FastScanner fs = new FastScanner();
		int tt=fs.nextInt();
		while(tt-->0) {
			long n=fs.nextLong();
//			int arr[]=fs.readArray(n);
			solve(n);
		}

	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

		int[][] readArray(int n,int m) {
			int[][] a=new int[n][m];
			for (int i=0; i<n; i++) for(int j=0; j<m; j++) a[i][j]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
void solve(vector<long long> a, long long n) {
  long long big = (long long)1e15;
  long long ans = big, c = 1, k = 0;
  while (1) {
    long long val = 0, pw = 1;
    for (long long i = 0; i < n; i++, pw *= c) {
      if (pw >= big) {
        val = -1;
        break;
      }
      val += abs(pw - a[i]);
    }
    if (val == -1) break;
    ans = min(ans, val);
    c++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  solve(arr, n);
  return 0;
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.Random;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowerSequence solver = new BPowerSequence();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowerSequence {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.readIntArray(n);

            if (n > 50) {
                long answer = 0;
                for (int x : a) {
                    answer += Math.abs(x - 1);
                }
                out.println(answer);
                return;
            }

            Util.safeSort(a);

            long answer = Long.MAX_VALUE;
            outer:
            for (long base = 1; ; base++) {
                long v = 1;
                long score = 0;
                for (int i = 0; i < n; i++) {
                    score += Math.abs(a[i] - v);

                    v *= base;
                    if (v > 1e15)
                        break outer;
                }
                answer = Math.min(answer, score);
            }

            out.println(answer);
        }

    }

    static class Util {
        public static void safeSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}


from collections import *
from math import *

N = int(5e5+5)
p = [0 for i in range(N)]
for i in range(2,N):
	if(p[i] == 0):
		for j in range(i*i,N,i):
			if(p[j] == 0): p[j] = i

n = int(input())
a = [1 for i in range(n+1)]
primes = []
ct = 0
for i in range(1,n+1):
	if p[i] == 0:
		ct += 1
		primes.append(i)
g = 2
dig = 2*g
lim = g*g
j = 2
m = ct
for i in range(ct+1,n+1):
	if(dig > lim or dig > n):
		g += 1
		dig = 2*g
		j = 2
		if p[g] == 0:
			lim = g*g
		else:
			lim = p[g]*g
	#print(i,g,dig,j)
	a[i] = g
	dig = g*primes[j]
	j += 1
for i in range(2,n+1):
	print(a[i],end=" ")
print()

#include <bits/stdc++.h>
using namespace std;
int mod = 998244353;
const int M = 1e6 + 10;
const int N = 5e5 + 10;
inline long long read() {
  long long b = 1, sum = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return b * sum;
}
int n, m, k, T;
int len, ans;
int a[N], sum[N];
int pcnt, p[N], d[N];
bool vis[N + 10];
void sieve() {
  int i, j;
  for (i = 2; i <= n; i++) {
    if (!vis[i]) {
      p[++pcnt] = i;
      d[i] = 1;
      for (j = 2 * i; j <= n; j += i) {
        vis[j] = 1;
        d[j] = max(d[j], j / i);
      }
    }
  }
}
int main() {
  int i, j;
  n = read();
  sieve();
  d[1] = 1;
  sort(d + 1, d + 1 + n);
  for (i = 2; i <= n; i++) {
    printf("%d ", d[i]);
  }
  return 0;
}


import java.io.*;
import java.util.*;
import java.math.*;

public class p1269A {

	public void realMain() throws Exception {

		BufferedReader fin = new BufferedReader(new InputStreamReader(System.in), 1000000);

		String in = fin.readLine();

		String[] ar = in.split(" ");

		int n = Integer.parseInt(ar[0]);

		if(n % 2 == 1) {
			System.out.println((21 + n) + " 21");
		} else {
			System.out.println((22 + n) + " 22");
		}

	}

	public static void main(String[] args) throws Exception {
		p1269A a = new p1269A();
		a.realMain();
	}
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 999999999999999999;
const double PI = acos(-1.0);
void stop() { exit(0); }
int main() {
  double n, r;
  cin >> n >> r;
  double sn = sin(PI / n);
  double x = (2.0 * r * sn) / (2.0 - 2.0 * sn);
  printf("%.9lf", x);
  stop();
}

import math
n, r = map(int, input().split())

s = math.sin(math.pi / n)
print(s*r / (1-s))


import math
n, = map(int, input().split())
print(math.floor(math.log2(n)) + 1)

import java.util.*;

public class Packets{
    public static void main(String[] args){
        int n;
        int k=1;
        int r=1;
        int ans=1;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        while(n>k){
            r*=2;
            k+=r;
            ans++;
        }
        System.out.println(ans);
    }
}


#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > vs;
long long int a[200007];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, n2, m, i, j, u, v, ans = 1000000000000000000;
  cin >> n;
  n2 = 2 * n;
  for (i = 0; i < n2; i++) cin >> a[i];
  sort(a, a + n2);
  long long int p1 = 0, p2 = n - 1, p3 = n, p4 = n2 - 1;
  p1 = 0, p2 = n - 1, p3 = n, p4 = n2 - 1;
  ans = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]);
  for (i = 1; i + n - 1 < 2 * n - 1; i++)
    ans = min(ans, (a[i + n - 1] - a[i]) * 1LL * (a[2 * n - 1] - a[0]));
  cout << ans << endl;
  return 0;
}

n=int(input())-1
s=sorted(map(int,input().split()))
sp=(s[n]-s[0])*(s[2*n+1]-s[n+1])
for i in range(n+1):
   sp=min(sp,(s[n+i]-s[i])*(s[2*n+1]-s[0]))
print(sp)


import java.io.*;
import java.util.*;

public class SwitchesAndLamps985B {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader();
		PrintWriter out =  new PrintWriter(System.out);

		int n = in.nextInt();
		int m = in.nextInt();

		HashMap<Integer,HashSet<Integer>> s2l = new HashMap<>();
		HashMap<Integer, Integer> l2s = new HashMap<>();

		for(int i=0; i<2000; i++) {
			s2l.put(i, new HashSet<>());
			l2s.put(i, 0);
		}

		for(int i=0; i<n; i++) {
			String st = in.nextLine();
			for(int j=0; j<m; j++) {
				if(st.charAt(j)=='1') {
					s2l.get(i).add(j);
					l2s.put(j,l2s.get(j)+1);
				}
			}
		}

		boolean found = false;
		for(int i=0; i<n; i++) {
			boolean isReq = false;
			for(int lamp: s2l.get(i)) {
				if(l2s.get(lamp)==1) {
					isReq = true;
					break;
				}
			}
			if(!isReq) {
				out.println("YES");
				found = true;
				break;
			}
		}

		if(!found) {
			out.println("NO");
		}

		out.close();
	}

	static class InputReader{
        private final BufferedReader reader;
        private StringTokenizer string;

        public InputReader(){
            reader = new BufferedReader(new InputStreamReader(System.in));
            string = new StringTokenizer(new String());
        }

        public String nextLine(){
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public int nextInt(){
            if(!string.hasMoreTokens()){
                try {
                    string = new StringTokenizer(reader.readLine());
                } catch (IOException ex){}
            }
            return Integer.parseInt(string.nextToken());
        }

        public long nextLong(){
            if(!string.hasMoreTokens()){
                try {
                    string = new StringTokenizer(reader.readLine());
                } catch (IOException ex){}
            }
            return Long.parseLong(string.nextToken());
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > vec(n, vector<int>(m));
  vector<int> sum(m);
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == '1')
        vec[i][j] = 1;
      else
        vec[i][j] = 0;
      sum[j] += vec[i][j];
    }
  }
  int count, flag = 0;
  for (int i = 0; i < n; i++) {
    count = 0;
    for (int j = 0; j < m; j++) {
      sum[j] -= vec[i][j];
      if (sum[j] >= 1) count++;
      sum[j] += vec[i][j];
    }
    if (count == m) {
      cout << "Yes\n";
      flag = 1;
      break;
    }
  }
  if (flag == 0) cout << "No\n";
}


n,a,b=map(int,input().split())
a,b,r=a-1,b-1,0
while a!=b:
 a//=2
 b//=2
 r+=1
print(r if 2**r<n else 'Final!')

import java.util.*;
import java.io.*;
import java.math.*;
public class codeforces
{
    public static void main(String args[])throws IOException
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        ArrayList<Integer> hs=new ArrayList<Integer>();
        for(int i =1;i<=n;i++)
        hs.add(i);
        int round=0;
        while(true)
        {
            round++;
            ArrayList<Integer> hs1=new ArrayList<Integer>();
            Iterator iterator = hs.iterator();
            while (iterator.hasNext())
            {
                int a1=(Integer)iterator.next();
                int b1=(Integer)iterator.next();
                if((a1==a&&b1==b)||(a1==b&&b1==a))
                {
                    if((int)Math.pow(2,round)==n)
                    {
                        System.out.println("Final!");
                    }
                    else
                    System.out.println(round);
                    System.exit(0);
                }
                if(a1==a||a1==b)
                hs1.add(a1);
                else if(b1==a||b1==b)
                hs1.add(b1);
                else
                hs1.add(a1);
            }
            hs=hs1;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
long long sqr(long long x) { return (x * x); }
long long dist(pair<long long, long long> a, pair<long long, long long> b) {
  return sqr(a.first - b.first) + sqr(a.second - b.second);
}
long long func(long long i) {
  if (i < 2 || i & 1) return 1;
  return -1;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<long long, pair<long long, long long> > > a;
  long long x, y, r;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &x, &y, &r);
    a.push_back(make_pair(r, make_pair(x, y)));
  }
  long long deg[n];
  memset(deg, 0, sizeof deg);
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (dist(a[i].second, a[j].second) <= sqr(a[j].first) && i != j) deg[i]++;
  double answer = 0.0;
  for (int i = 0; i < n; i++) {
    answer += (double)acos(-1) * a[i].first * a[i].first * func(deg[i]);
  }
  printf("%.20lf\n", answer);
  return 0;
}

n = int(input())
d = [1] * n
p = [[] for i in range(n)]

def f():
    x, y, r = map(int, input().split())
    return r * r, x, y

t = sorted(f() for i in range(n))

for i in range(n):
    r, x, y = t[i]
    for j in range(i + 1, n):
        s, a, b = t[j]
        if (a - x) ** 2 + (b - y) ** 2 < s:
            p[j].append(i)
            d[i] = 0
            break

def f(i):
    s = t[i][0]
    q = [(1, j) for j in p[i]]
    while q:
        d, i = q.pop()
        s += d * t[i][0]
        q += [(-d, j) for j in p[i]]
    return s

print(3.1415926536 * sum(f(i) for i in range(n) if d[i]))


import java.util.Scanner;

public class A680 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] stat = new int[101];
        int sum = 0;
        for (int i=0; i<5; i++) {
            int value = in.nextInt();
            sum += value;
            stat[value]++;
        }
        int minSum = sum;
        for (int i=1; i<=100; i++) {
            if (stat[i] > 2) {
                minSum = Math.min(minSum, sum - 3*i);
            } else if (stat[i] > 1) {
                minSum = Math.min(minSum, sum - 2*i);
            }
        }
        System.out.println(minSum);
    }

}

#include <bits/stdc++.h>
using namespace std;
long long int i, j, k, a, b, n;
int main() {
  long long int n, cc[101] = {0}, m = 0, s = 0;
  for (i = 0; i < 5; i++) {
    cin >> n;
    s += n;
    cc[n]++;
    if (cc[n] == 3 || cc[n] == 2) m = max(m, cc[n] * n);
  }
  cout << s - m << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int i, l, z = 0;
  cin >> s;
  l = s.size();
  for (i = 0; i < l; i++)
    if (s[i] == 'A')
      z += 1;
    else if (s[i] == '1')
      z += 10;
    else
      z += s[i] - '0';
  cout << z;
  return 0;
}

import java.io.*;
import java.util.*;

public class SolveF {
	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public static void main(String[] args) throws IOException {
		new SolveF().run();
	}

	public void solve() throws IOException {
		String s = nextToken();
		int ans = 0;
		for (int i = 1; i < s.length(); i++) {
			int cur = s.charAt(i) - '0';
			if (cur == 1 && i < s.length() - 1) {
			ans += Integer.parseInt(s.substring(i,i + 2));
			i++;
			} else {
				ans += cur;
			}
		}
		out.println(ans + 1);
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in)); // new
																		// InputStreamReader(System.in)
			out = new PrintWriter(System.out); // System.out

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
long long int n, i, j, sum, lsbl, t;
long double lsbl1;
long double ksm(long double a, long long int b) {
  long double sumend = 1;
  while (b) {
    if (b % 2 == 1) sumend *= a;
    a *= a;
    b /= 2;
  }
  return sumend;
}
int main() {
  cin >> n >> t;
  lsbl1 = n * ksm(1.000000011, t);
  cout << fixed << setprecision(15) << n * ksm(1.000000011, t) << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int t, n, a[100005], tot, bal, ans;
inline int _abs(int x) { return x > 0 ? x : -x; }
bool cmp(int x, int y) { return x > y; }
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), tot += a[i];
  sort(a + 1, a + n + 1, cmp);
  bal = tot % n, tot /= n;
  for (int i = 1; i <= n; i++)
    if (bal)
      bal--, ans += _abs(a[i] - tot - 1);
    else
      ans += _abs(a[i] - tot);
  ans /= 2;
  printf("%d\n", ans);
  ans = tot = 0;
  return 0;
}

input()
servers = [int(x) for x in input().split(" ", )]
servers.sort()

avg = int(sum(servers) / len(servers))
extra = sum(servers) % len(servers)

count = 0

for i in range(len(servers)):
    count += abs(avg + (i >= (len(servers) - extra)) - servers[i]) / 2

print(int(count))


N = int(1e6+100)
n = int(input())
arr = list(map(int, input().split()))
cnt = [0] * N
for i in arr:
    cnt[i] += 1
res, s = 0, 0
for i in range(N):
    s += cnt[i]
    res += s % 2
    s //= 2
print(res)

#include <bits/stdc++.h>
using namespace std;
int n;
int w[1000000];
int m[2000001];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    m[w[i]]++;
  }
  sort(w, w + n);
  long long ans = 0;
  for (int i = 0; i <= 1000130; i++) {
    long long f = m[i];
    if (f == 0) {
      continue;
    }
    vector<int> v1;
    for (int j = 0; j < 22; j++) {
      v1.push_back(f % 2LL);
      f /= 2LL;
    }
    long long t = 1;
    for (int j = 0; j < 22; j++) {
      m[i] -= t * v1[j];
      m[j + i] += v1[j];
      t *= 2LL;
    }
    ans += m[i];
  }
  cout << ans << endl;
  return 0;
}


n = int(input())
questions = []

for _ in range(n):
    questions.append(input())

lower_bound, upper_bound = None, None

for q in questions:
    bound = int(q.split()[1])
    if (q.startswith('>') and q.endswith('Y')) or (q.startswith('<') and q.endswith('N')):
        if ('Y' in q and '=' not in q) or ('N' in q and '=' in q):
            bound += 1
        lower_bound = bound if lower_bound == None else max(bound, lower_bound)
    else:
        if ('Y' in q and '=' not in q) or ('N' in q and '=' in q):
            bound -= 1
        upper_bound = bound if upper_bound == None else min(bound, upper_bound)

if lower_bound != None and upper_bound != None and lower_bound > upper_bound:
    print('Impossible')
else:
    print(lower_bound if lower_bound != None else upper_bound)

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int a;
  cin >> a;
  int l = -2e9;
  int r = 2e9;
  while (a--) {
    string c;
    int n;
    char s;
    cin >> c >> n >> s;
    if (c == ">") {
      if (s == 'Y')
        l = max(l, n + 1);
      else
        r = min(r, n);
    } else if (c == "<") {
      if (s == 'Y')
        r = min(r, n - 1);
      else
        l = max(l, n);
    } else if (c == "<=") {
      if (s == 'Y')
        r = min(r, n);
      else
        l = max(l, n + 1);
    } else {
      if (s == 'Y')
        l = max(l, n);
      else
        r = min(r, n - 1);
    }
  }
  if (l <= r)
    cout << l;
  else
    cout << "Impossible";
}


xmin, ymin, xmax, ymax, a = 31400, 31400, 0, 0, 0
for i in range(int(input())):
    x1, y1, x2, y2 = map(int, input().split())
    xmin = min(xmin, x1)
    ymin = min(ymin, y1)
    xmax = max(xmax, x2)
    ymax = max(ymax, y2)
    a += (x2 - x1) * (y2 - y1)
print('YES' if xmax - xmin == ymax - ymin and a == (xmax - xmin) ** 2 else 'NO')

import java.util.*;

public class Main {
    public static void main(String [] args){
        Scanner in = new Scanner(System.in);
        int n;
        int x1,y1,x2,y2;
        while(in.hasNext())
        {
            int maxx = -1,minx = 40000,maxy = -1,miny = 40000;
            n = in.nextInt();
            long ans1,ans2 = 0;
            for(int i = 0; i < n; ++i)
            {
                x1 = in.nextInt();
                y1 = in.nextInt();
                x2 = in.nextInt();
                y2 = in.nextInt();
                maxx = Math.max(x2,maxx);
                minx = Math.min(x1,minx);
                maxy = Math.max(y2,maxy);
                miny = Math.min(y1,miny);
                ans2 += Math.abs(x2 - x1) * Math.abs(y2 - y1);
            }
            ans1 = Math.abs(maxx - minx) * Math.abs(maxy - miny);
            if(maxx - minx != maxy - miny || ans1 != ans2)
                System.out.println("NO");
            else
                System.out.println("YES");
        }
        in.close();
    }
}


n,d=map(int,input().split())
nums=list(map(int,input().split()))
count=0
j=0
for i in range(n):
    while j<n and nums[j]-nums[i]<=d:
        j+=1
    temp_length=(j-i-1)
    count+=int((temp_length*(temp_length-1))/2)

print(count)

#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  long long n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) cin >> a[i];
  long long l = 1, r = 2;
  long long ans = 0;
  while (l <= n || r <= n) {
    if (l >= r) {
      r = l + 1;
      continue;
    }
    if (r > n) {
      ans += max(0ll, (r - l - 1) * (r - l - 2) / 2), r--, l++;
      continue;
    }
    if (a[r] - a[l] <= d)
      r++;
    else {
      ans += max(0ll, (r - l - 1) * (r - l - 2) / 2);
      r--;
      l++;
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> v(n);
  vector<int> c(m + 5, 0);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int l = 0, r = 0;
  int res = 1;
  c[v[0] - 1]++;
  int maxC = 1;
  int maxI = v[0] - 1;
  while (r < n) {
    if (c[v[r] - 1] > maxC) {
      maxC = c[v[r] - 1];
      maxI = v[r] - 1;
    }
    if (c[v[l] - 1] > maxC) {
      maxC = c[v[l] - 1];
      maxI = v[l] - 1;
    }
    if (r - l + 1 - maxC > k) {
      if (v[l] - 1 == maxI) {
        maxC--;
      }
      c[v[l] - 1]--;
      l++;
    } else if (r == n - 1) {
      break;
    } else {
      r++;
      c[v[r] - 1]++;
      if (c[v[r] - 1] > maxC) {
        maxC = c[v[r] - 1];
        maxI = v[r] - 1;
      }
      if (r - l + 1 - maxC <= k) {
        res = max(res, maxC);
      }
    }
  }
  cout << res;
  return 0;
}

import java.io.*;
import java.util.*;
public class E {
	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int K = nextInt();
		ArrayList<Integer>[] color = new ArrayList[m];
		for (int i = 0; i < m; i++)
			color[i] = new ArrayList<Integer>();
		for (int i = 0; i < n; i++)
			color[nextInt() - 1].add(i);
		int ans = 0;
		for (int i = 0; i < m; i++) {
			int last = 0;
			int lim = color[i].size();
			for (int j = 0; j < lim; j++) {
				while (last < lim && (color[i].get(last) - color[i].get(j)) - (last - j) <= K) last++;
				//writer.println(color[i].get(last - 1) + " " + color[i].get(j));
				ans = Math.max(ans, last - j);
			}
		}
		writer.println(ans);
	}

	public static void main(String[] args) throws FileNotFoundException {
		new E().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			//writer = new PrintWriter(new FileOutputStream("output.txt"));
			solve();
			//reader.close();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms");
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}


def solve(x,l1,r1,l2,r2):
	if x==0:return 1
	if l1>x:
		l1-=x+1
		r1-=x+1
	if l2>x:
		l2-=x+1
		r2-=x+1
	ans=max(0,min(r1,r2)-max(l1,l2)+1)
	if l1<=x and x<=r1 and l2<=x and x<=r2:
		if l1==0 or r1==x*2:
			ans=max(ans,max(x-l2,r2-x))
		elif l2==0 or r2==x*2:
			ans=max(ans,max(x-l1,r1-x))
		else:
			if l1<=x-1 and r2>=x+1:
				ans=max(ans,solve(x//2,l1,x-1,0,r2-x-1))
			if l2<=x-1 and r1>=x+1:
				ans=max(ans,solve(x//2,l2,x-1,0,r1-x-1))
	elif l1<=x and x<=r1:
		if l1==0 or r1==x*2:
			ans=max(ans,r2-l2+1)
		else:
			if l1<=x-1:
				ans=max(ans,solve(x//2,l1,x-1,l2,r2))
			if r1>=x+1:
				ans=max(ans,solve(x//2,0,r1-x-1,l2,r2))
	elif l2<=x and x<=r2:
		if l2==0 or r2==x*2:
			ans=max(ans,r1-l1+1)
		else:
			if l2<=x-1:
				ans=max(ans,solve(x//2,l2,x-1,l1,r1))
			if r2>=x+1:
				ans=max(ans,solve(x//2,0,r2-x-1,l1,r1))
	else:
		ans=max(ans,solve(x//2,l1,r1,l2,r2))
	return ans

l1,r1,l2,r2=map(int,input().split())
print(solve((1<<36)-1,l1-1,r1-1,l2-1,r2-1))

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Abacaba {
    public static void main(String[] args) throws IOException {
        BufferedReader leer= new BufferedReader(new InputStreamReader(System.in));
        String[] line=leer.readLine().split(" ");
        long a=Long.parseLong(line[0])-1;
        long b=Long.parseLong(line[1])-1;
        long c=Long.parseLong(line[2])-1;
        long d=Long.parseLong(line[3])-1;
        long r=solve(a,b,c,d,(long)(Math.pow(2, 33)-1)/2);
        System.out.println(r);
    }
    private static long solve(long a, long b, long c, long d,long m) {
        if(b<a || d<c) return 0;
        long l=longitud(a,b,c,d);
        if( a <= c && b >= d || a >= c && b <= d ) return l ;

        l= Math.max(l, solve(Math.min(a, m),Math.min(b, m-1),Math.min(c,m),Math.min(d, m-1),m/2));
        l= Math.max(l, solve(Math.min(a, m),Math.min(b, m-1),Math.max(c,m+1)-m-1,Math.max(d, m)-m-1,m/2));
        l= Math.max(l, solve(Math.max(a, m+1)-m-1,Math.max(b, m)-m-1,Math.min(c,m),Math.min(d, m-1),m/2));
        l= Math.max(l, solve(Math.max(a, m+1)-m-1,Math.max(b, m)-m-1,Math.max(c,m+1)-m-1,Math.max(d, m)-m-1,m/2));

        return l;
    }

    private static long longitud(long l1, long r1, long l2, long r2) {
        long ovl = Math.max(l1, l2);
        long ovr = Math.min(r1, r2);
        return ( (ovr >= ovl)? (ovr - ovl + 1) : 0 );
    }
}


import java.math.*;
import java.io.*;
import java.util.*;
import java.awt.*;

public class Main implements Runnable {
    @Override
    public void run() {
        try {
            new Solver().solve();
            System.exit(0);
        } catch (Exception | Error e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public static void main(String[] args) {
        //new Thread(null, new Main(), "Solver", 1l << 25).start();
        new Main().run();
    }
}

class Solver {
    final Helper hp;
    final int MAXN = 1000_006;
    final long MOD = (long) 1e9 + 7;

    final Timer timer;
    final TimerTask task;

    Solver() {
        hp = new Helper(MOD, MAXN);
        hp.initIO(System.in, System.out);

        timer = new Timer();
        task = new TimerTask() {
            @Override
            public void run() {
                try {
                    hp.flush();
                    System.exit(0);
                } catch (Exception e) {
                }
            }
        };
        //timer.schedule(task, 4700);
    }

    int N, M;
    int[] L;

    void solve() throws Exception {
        int i, j, k;
        boolean testCases = false;

        int tc = testCases ? hp.nextInt() : 1;
        for (int tce = 1; tce <= tc; tce++) {
            N = hp.nextInt(); M = hp.nextInt();
            L = hp.getIntArray(M);

            long[] suffix = new long[M];
            for (i = 0; i < M; ++i) suffix[i] = L[i];
            for (i = M - 2; i >= 0; --i) suffix[i] += suffix[i + 1];

            int[] leastReq = L.clone();
            for (i = M - 2; i >= 0; --i) {
                leastReq[i] = Math.max(leastReq[i], leastReq[i + 1] + 1);
            }

            //System.err.println(Arrays.toString(suffix));
            //System.err.println(Arrays.toString(leastReq));

            int[] ans = new int[M];
            if (recurse(0, 0, 0, ans, leastReq, suffix)) {
                hp.println(hp.joinElements(ans));
            } else {
                hp.println(-1);
            }
        }

        timer.cancel();
        hp.flush();
    }

    boolean recurse(int idx, int start, int end, int[] ans, int[] leastReq, long[] maxFillable) {
        //System.err.println(idx + " " + start + " -> " + end);

        if (end > N) return false;
        else if (idx >= M) {
            return end == N;
        }

        int maxOffered = N - start, unfilled = N - end;
        if (maxOffered < leastReq[idx] || unfilled > maxFillable[idx]) {
            return false;
        } else {
            for (int i = start; i <= end; ++i) {
                if (recurse(idx + 1, i + 1, Math.max(end, i + L[idx]),
                        ans, leastReq, maxFillable)) {
                    ans[idx] = i + 1;
                    return true;
                }
            }
            System.exit(7 / 0);
            return false;
        }
    }
}

class Helper {
    final long MOD;
    final int MAXN;
    final Random rnd;

    public Helper(long mod, int maxn) {
        MOD = mod;
        MAXN = maxn;
        rnd = new Random();
    }

    public static int[] sieve;
    public static ArrayList<Integer> primes;

    public void setSieve() {
        primes = new ArrayList<>();
        sieve = new int[MAXN];
        int i, j;
        for (i = 2; i < MAXN; ++i)
            if (sieve[i] == 0) {
                primes.add(i);
                for (j = i; j < MAXN; j += i) {
                    sieve[j] = i;
                }
            }
    }

    public static long[] factorial;

    public void setFactorial() {
        factorial = new long[MAXN];
        factorial[0] = 1;
        for (int i = 1; i < MAXN; ++i) factorial[i] = factorial[i - 1] * i % MOD;
    }

    public long getFactorial(int n) {
        if (factorial == null) setFactorial();
        return factorial[n];
    }

    public long ncr(int n, int r) {
        if (r > n) return 0;
        if (factorial == null) setFactorial();
        long numerator = factorial[n];
        long denominator = factorial[r] * factorial[n - r] % MOD;
        return numerator * pow(denominator, MOD - 2, MOD) % MOD;
    }

    public long[] getLongArray(int size) throws Exception {
        long[] ar = new long[size];
        for (int i = 0; i < size; ++i) ar[i] = nextLong();
        return ar;
    }

    public int[] getIntArray(int size) throws Exception {
        int[] ar = new int[size];
        for (int i = 0; i < size; ++i) ar[i] = nextInt();
        return ar;
    }

    public String[] getStringArray(int size) throws Exception {
        String[] ar = new String[size];
        for (int i = 0; i < size; ++i) ar[i] = next();
        return ar;
    }

    public String joinElements(long... ar) {
        StringBuilder sb = new StringBuilder();
        for (long itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(int... ar) {
        StringBuilder sb = new StringBuilder();
        for (int itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(String... ar) {
        StringBuilder sb = new StringBuilder();
        for (String itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

    public String joinElements(Object... ar) {
        StringBuilder sb = new StringBuilder();
        for (Object itr : ar) sb.append(itr).append(" ");
        return sb.toString().trim();
    }

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

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

    public long max(long... ar) {
        long ret = ar[0];
        for (long itr : ar) ret = Math.max(ret, itr);
        return ret;
    }

    public int max(int... ar) {
        int ret = ar[0];
        for (int itr : ar) ret = Math.max(ret, itr);
        return ret;
    }

    public long min(long... ar) {
        long ret = ar[0];
        for (long itr : ar) ret = Math.min(ret, itr);
        return ret;
    }

    public int min(int... ar) {
        int ret = ar[0];
        for (int itr : ar) ret = Math.min(ret, itr);
        return ret;
    }

    public long sum(long... ar) {
        long sum = 0;
        for (long itr : ar) sum += itr;
        return sum;
    }

    public long sum(int... ar) {
        long sum = 0;
        for (int itr : ar) sum += itr;
        return sum;
    }

    public void shuffle(int[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = rnd.nextInt(ar.length);
            if (r != i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void shuffle(long[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = rnd.nextInt(ar.length);
            if (r != i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void reverse(int[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = ar.length - 1 - i;
            if (r > i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public void reverse(long[] ar) {
        int r;
        for (int i = 0; i < ar.length; ++i) {
            r = ar.length - 1 - i;
            if (r > i) {
                ar[i] ^= ar[r];
                ar[r] ^= ar[i];
                ar[i] ^= ar[r];
            }
        }
    }

    public long pow(long base, long exp, long MOD) {
        base %= MOD;
        long ret = 1;
        while (exp > 0) {
            if ((exp & 1) == 1) ret = ret * base % MOD;
            base = base * base % MOD;
            exp >>= 1;
        }
        return ret;
    }

    static final int BUFSIZE = 1 << 20;
    static byte[] buf;
    static int index, total;
    static InputStream in;
    static BufferedWriter bw;

    public void initIO(InputStream is, OutputStream os) {
        try {
            in = is;
            bw = new BufferedWriter(new OutputStreamWriter(os));
            buf = new byte[BUFSIZE];
        } catch (Exception e) {
        }
    }

    public void initIO(String inputFile, String outputFile) {
        try {
            in = new FileInputStream(inputFile);
            bw = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(outputFile)));
            buf = new byte[BUFSIZE];
        } catch (Exception e) {
        }
    }

    private int scan() throws Exception {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0)
                return -1;
        }
        return buf[index++];
    }

    public String next() throws Exception {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan())
            sb.append((char) c);
        return sb.toString();
    }

    public int nextInt() throws Exception {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    public long nextLong() throws Exception {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    public void print(Object a) throws Exception {
        bw.write(a.toString());
    }

    public void printsp(Object a) throws Exception {
        print(a);
        print(" ");
    }

    public void println() throws Exception {
        bw.write("\n");
    }

    public void println(Object a) throws Exception {
        print(a);
        println();
    }

    public void flush() throws Exception {
        bw.flush();
    }
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
const int nax = 100 * 1000 + 10;
int n, m;
int l[nax];
int p[nax];
ll sum;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> l[i];
    sum += l[i];
  }
  if (sum < n) {
    cout << "-1";
    return 0;
  }
  for (int i = 1; i <= m; ++i) {
    if (l[i] + i - 1 > n) {
      cout << "-1";
      return 0;
    }
    p[i] = i;
  }
  int w = n, pos = m;
  while (pos > 0) {
    if (p[pos] + l[pos] - 1 < w) {
      p[pos] = w - l[pos] + 1;
      w = p[pos] - 1;
      pos--;
    } else {
      break;
    }
  }
  if (p[1] != 1) {
    cout << "-1";
    return 0;
  }
  for (int i = 1; i <= m; i++) cout << p[i] << " ";
}


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

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0)
		{
		    long x=sc.nextLong();
		    long y=x%(400*399/2);
		    long z=x/(400*399/2);
		    StringBuilder str=new StringBuilder("133");
		    while(y-->0)
		        str.append("7");
		    for(int i=2;i<400;i++)
		    str.append("3");
		    while(z-->0)
		    str.append("7");
		    System.out.println(str);
		}
	}
}

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
long long rd() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 100010;
int t;
long long n;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    long long y = 1;
    for (; y * (y - 1) / 2 <= n; y++)
      ;
    y--;
    n -= y * (y - 1) / 2;
    cout << "133";
    y -= 2;
    for (int i = 1; i <= n; ++i) {
      printf("7");
    }
    for (int i = 1; i <= y; ++i) {
      printf("3");
    }
    cout << "7" << endl;
  }
}


import java.io.*;
import java.util.*;

public class asitis
{

	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);

	public static void main(String[] args)throws IOException{

			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

			int n=Integer.parseInt(br.readLine());

			String[] s=br.readLine().split(" ");

			PriorityQueue<Integer> pq= new PriorityQueue<Integer>();

			for(int i=0;i<n;i++) pq.add(Integer.parseInt(s[i]));

			long check=1;

			int days=0;

			while(pq.size()>0)
			{
				while(pq.size()>0 && pq.peek()<check)
					pq.poll();

				if(pq.size()>0)
				{
					days++;
					pq.poll();
				}
				check++;
			}

			out.println(days);

			out.close();

	}
}

a = int(input())
b = [int(x) for x in input().split()]
b.sort()
s = 1
q = 0
for i in b:
  if i >= s:
    s += 1
    q += 1
print(q)


n,h=map(int,input().split())

L=[]
for i in range(n+1):
    g=[]
    for j in range(n+1):
        g.append(0)
    L.append(g)
L[0][0]=1
for i in range(1,n+1):
    for j in range(1,n+1):
        sumu=0
        for m in range(1,i+1):
            t1=L[m-1][j-1]
            tot=0
            for k in range(0,j):
                tot+=L[i-m][k]
            t1*=tot

            t2=L[i-m][j-1]
            tot=0
            for k in range(0,j-1):
                tot+=L[m-1][k]
            t2*=tot
            sumu+=(t1+t2)
        L[i][j]=sumu

ans=0
for i in range(h,n+1):
    ans+=L[n][i]

print(ans)

import java.util.*;

public class D
{
   public static void main(String[] args)
   {
      new D(new Scanner(System.in));
   }

   public D(Scanner in)
   {
      int N = in.nextInt();
      int H = in.nextInt();

      long[] cat = new long[N+1];
      cat[0] = 1;
      for (int j=1; j<=N; j++)
      {
         long sum = 0;
         for (int i=0; i<j; i++)
            sum = sum+cat[j-i-1]*cat[i];
         cat[j] = sum;
      }

      long[][] dp = new long[N+1][H+1];
      for (int i=0; i<=H; i++)
         dp[0][i] = 1;
      for (int h=1; h<=H; h++)
      {
         for (int n=1; n<=N; n++)
         {
            long sum = 0;
            for (int i=0; i<n; i++)
               sum += dp[i][h-1]*dp[n-i-1][h-1];
            dp[n][h] = sum;
         }
      }

      if (H > 0)
         cat[N] -= dp[N][H-1];
      System.out.printf("%d%n", cat[N]);
   }
}


import java.util.*;
import java.io.*;

public class Main {
	public static void main(String args[]) {new Main().run();}

	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		work();
		out.flush();
	}
	long mod=1000000007;
	long gcd(long a,long b) {
		return b==0?a:gcd(b,a%b);
	}
	void work() {
		int n=in.nextInt();
		long[] A=new long[n];
		for(int i=0;i<n;i++)A[i]=in.nextLong();
		int[] ret=new int[n];
		int[] id=new int[n];

		for(int i=0;i<n;i++) {
			for(long k=2;k*k<=Math.abs(A[i]);k++) {
				while(A[i]%(k*k)==0) {
					A[i]/=(k*k);
				}
			}
		}

		for(int i=0;i<n;i++) {
			id[i]=i;
			if(A[i]==0) continue;
			for(int j=0;j<i;j++) {
				if(A[j]==0)continue;
				if(A[i]==A[j]) {
					id[i]=j;
					break;
				}
			}
		}
		for(int i=0;i<n;i++) {
			boolean[] vis=new boolean[n];
			int cur=0;
			for(int j=i;j<n;j++) {
				if(A[j]!=0&&!vis[id[j]]) {
					cur++;
					vis[id[j]]=true;
				}
				if(cur==0) {
					ret[cur]++;//zero
				}else {
					ret[cur-1]++;
				}
			}
		}
		for(int i=0;i<n;i++) {
			out.print(ret[i]+" ");
		}
	}
}

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}

	public String next()
	{
		if(st==null || !st.hasMoreElements())
		{
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	public int nextInt()
	{
		return Integer.parseInt(next());
	}

	public long nextLong()
	{
		return Long.parseLong(next());
	}
}

#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
long long a[N];
int n, cnt[N][N], ans[N], p[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    long long f = 1;
    if (a[i] < 0) f = -1, a[i] = -a[i];
    for (int j = 2; j * j <= a[i]; j++)
      while (a[i] % (j * j) == 0) a[i] /= j * j;
    a[i] *= f;
    if (a[i] == 0) {
      p[i] = i;
      cnt[i][i] = 0;
    } else {
      for (int j = i - 1; j; j--)
        if (a[i] == a[j]) {
          p[i] = j;
          break;
        }
      cnt[i][i] = 1;
    }
  }
  ans[1] = n;
  for (int l = 2; l <= n; l++)
    for (int i = 1; i + l - 1 <= n; i++) {
      int j = i + l - 1;
      cnt[i][j] = cnt[i][j - 1];
      if (p[j] < i) cnt[i][j]++;
      ans[max(1, cnt[i][j])]++;
    }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}


import java.util.*;
public class Korobka{
	public static void main(String[]args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int a[] = new int[n];
		int size = 1;
		int ans = 1;
		for(int i = 0; i<n; i++){
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		for(int i = 1; i<n; i++){
			if (a[i] == a[i-1])
				size++;
			else
				size = 1;
			if (ans < size)
				ans = size;
		}
		System.out.print(ans);
	}
}
//Aibolat Mendeshev :)

42

Each sample input consists of a single integer n on a line by itself, where 1

#include <bits/stdc++.h>
using namespace std;
void onlinejuge() {}
int isVowel(char c) {
  return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}
bool ranklist(pair<int, int> &p1, pair<int, int> &p2) {
  if (p1.first > p2.first)
    return 1;
  else if (p1.first == p2.first)
    return (p1.second < p2.second);
  else
    return 0;
}
int main() {
  onlinejuge();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  map<int, int> map;
  int t, max = 0;
  cin >> t;
  while (t--) {
    int a;
    cin >> a;
    map[a]++;
    if (max < map[a]) max = map[a];
  }
  cout << max << "\n";
  return 0;
}


a,b=map(int,input().split())
if(a==b):
    print('Equal')
    exit()
import math

lcm=(a*b)//(math.gcd(a,b))
if(a<b):
    da=(lcm//a)-1
    ma=lcm//b
    if(da>ma):
        print('Dasha')
    elif(da<ma):
        print('Masha')
    else:
        print('Equal')
else:
    da=(lcm//a)
    ma=(lcm//b)-1
    if(da>ma):
        print('Dasha')
    elif(da<ma):
        print('Masha')
    else:
        print('Equal')

Equal Masha Equal Equal Equal Equal Equal Dasha Masha Equal Masha Equal Equal Dasha Masha Equal Equal Dasha Equal Dasha Equal Equal Dasha Masha Equal Equal Dasha Masha Equal Equal Equal Equal Dasha Equal Dasha Equal Masha Equal Dasha Equal Masha Equal Dasha Dasha Dasha Dasha Equal Dasha Equal Equal

#include <bits/stdc++.h>
using namespace std;
inline int SG(double x) { return x > -1E-8 ? x < 1E-8 ? 0 : 1 : -1; }
long long gcd(long long a, long long b) {
  while ((a %= b) && (b %= a))
    ;
  return a + b;
}
int main() {
  long long a, b, i, j, d, sa;
  scanf("%I64d %I64d", &a, &b);
  d = a * b / gcd(a, b);
  sa = 0;
  for (i = 1, j = 0; i * a < d; i++) {
    while (j * b < i * a) j++;
    if ((j - 1) * b < (i - 1) * a) {
      sa += a;
    } else {
      sa += i * a - (j - 1) * b;
    }
  }
  if (a > b) {
    sa += b;
  }
  if (sa > d - sa) {
    puts("Dasha");
  } else if (sa < d - sa) {
    puts("Masha");
  } else {
    puts("Equal");
  }
  return 0;
}


import java.util.Scanner;

public class C765 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int K = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        int sets = A/K + B/K;
        if ((A%K != 0 && B < K) || (B%K != 0 && A < K)) {
            sets = -1;
        }
        System.out.println(sets);
    }

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, a, b;
  cin >> k >> a >> b;
  long long int g1 = a / k;
  long long int g2 = b / k;
  long long int mod2 = b % k;
  long long int mod1 = a % k;
  if (mod1 != 0 && g2 == 0) {
    cout << "-1";
    return 0;
  }
  if (mod2 != 0 && g1 == 0) {
    cout << "-1";
    return 0;
  }
  cout << g1 + g2;
  return 0;
}


/**
 * DA-IICT
 * Author : Savaliya Sagar
 */
import java.io.*;
import java.math.*;
import java.util.*;

public class E699
{
	void solve()
	{
		int n = ni();
		int k = ni();
		double a[] = new double[n];
		int cnt = 0;
		for(int i=0;i<n;i++) {
			a[i] = nd();
			if(a[i]==0)
				cnt++;
		}
		k = Math.min(k, n-cnt);
		double ans[] = new double[n];
		double dp[] = new double[1<<n];
		dp[0] = 1;
		for(int i=0;i<(1<<n);i++) {
			double tmp = 1;
			for(int j=0;j<n;j++) {
				if(((i>>j)&1)==1) {
					tmp -= a[j];
					if(Integer.bitCount(i)==k) {
						ans[j] += dp[i];
					}
				}
			}
			if(tmp<=0)
				continue;
			for(int j=0;j<n;j++) {
				if(((i>>j)&1)!=1) {
					dp[i|(1<<j)] += (dp[i]*a[j])/tmp;
				}
			}
		}
		for(int i=0;i<n;i++) {
			out.print(ans[i] +" ");
		}
	}

	void run() throws Exception
	{
		out = new PrintWriter(System.out);
		reader = new BufferedReader(new InputStreamReader(System.in), 32768);
		tokenizer = null;
		solve();
		out.flush();
	}
	public int ni()
	{
		return Integer.parseInt(next());
	}
	public Double nd()
	{
		return Double.parseDouble(next());
	}
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;

	public static void main(String[] args) throws Exception
	{
		new E699().run();
	}

	public String next()
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
		{
			try
			{
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
}

#include <bits/stdc++.h>
using namespace std;
const int N = 30, mod = int(1e9) + 7;
const double eps = 1e-9;
int k, n;
double p[N];
long double dp[1 << 21], a[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%lf", &p[i]);
  }
  dp[0] = 1;
  for (int mask = 0; mask < (1 << n); mask++) {
    long double sum = 0;
    for (int i = 0; i < n; i++) {
      if (mask & (1 << i)) {
        sum += p[i];
      }
    }
    if (__builtin_popcount(mask) == k || abs(sum - 1) < eps) {
      for (int i = 0; i < n; i++) {
        if (mask & (1 << i)) {
          a[i] += dp[mask];
        }
      }
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (!(mask & (1 << i))) {
        int nmask = mask | (1 << i);
        dp[nmask] += dp[mask] * p[i] / (1 - sum);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%.12lf ", double(a[i]));
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
void rdInt(int &n) {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  n = x * f;
}
map<int, int> mpx, mpy;
map<pair<int, int>, int> st;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    mpx.clear();
    mpy.clear();
    st.clear();
    long long an = 0;
    int x, y;
    for (int i = 0; i < n; i++) {
      rdInt(x);
      rdInt(y);
      an += mpx[x];
      an += mpy[y];
      an -= st[make_pair(x, y)];
      mpx[x]++;
      mpy[y]++;
      st[make_pair(x, y)]++;
    }
    printf("%I64d\n", an);
  }
  return 0;
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.StringTokenizer;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Gerasimov
 */
public class Main {

    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(inp.readLine());
        int n = Integer.parseInt(st.nextToken());
        HashMap<Long, Long> h1 = new HashMap<>();
        HashMap<Long, Long> h2 = new HashMap<>();
        HashMap<String, Long> h3 = new HashMap<>();
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(inp.readLine());
            long[] m = new long[2];
            m[0] = Long.parseLong(st.nextToken());
            m[1] = Long.parseLong(st.nextToken());
            if (!h1.containsKey(m[0])) {
                h1.put(m[0], 0l);
            }
            if (!h2.containsKey(m[1])) {
                h2.put(m[1], 0l);
            }
            if (!h3.containsKey(m[0]+"_"+m[1])) {
                h3.put(m[0]+"_"+m[1], 0l);
            }
            h1.replace(m[0], h1.get(m[0]) + 1);
            h2.replace(m[1], h2.get(m[1]) + 1);
            h3.replace(m[0]+"_"+m[1], h3.get(m[0]+"_"+m[1]) + 1);

        }
        long res = 0l;
        res = h1.entrySet().stream().map((entry) -> entry.getValue() * (entry.getValue() - 1) / 2).reduce(res, (accumulator, _item) -> accumulator + _item);
        res = h2.entrySet().stream().map((entry) -> entry.getValue() * (entry.getValue() - 1) / 2).reduce(res, (accumulator, _item) -> accumulator + _item);
        res = h3.entrySet().stream().map((entry) -> entry.getValue() * (entry.getValue() - 1) / 2).reduce(res, (accumulator, _item) -> accumulator - _item);
        out.print(res);
        out.close();
    }

}


//package CodeForces.VentureCup2016ELR;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created by ilya on 13.02.16.
 */

public class C626 {
    public static void main(String[] args) {
        sc sc = new sc();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();
        int max2 = n*2, max3 = m*3, cols = m/2;
        for (int i = 0; i < cols; i++) {
            if (max2+2 < max3 + 3 ) max2+=2;
            else {
                max3+=3;
                if(max3%2==0) cols++;
            }
        }
        out.println(Math.max(max2, max3));
        out.close();
    }

    public static class sc {
        BufferedReader br;
        StringTokenizer st;

        public sc() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        Integer nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

n, m = map(int, input().split())
x = max(n*2, m*3)
while x//2+x//3-x//6 < m+n:
    x += 1
print(x)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class B implements Runnable {

    private boolean valid(int[] a) {
        int prev = a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] - prev != 1) return false;
            prev = a[i];
        }
        return true;
    }

    private void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = nextInt();
        }
        int presses = 1010;
        while (presses-- > 0) {
            if (valid(a)) {
                pl("Yes"); return;
            }
            for (int i = 0; i < a.length; i++) {
                if (i % 2 == 0) {
                    a[i]++;
                    if (a[i] == n) a[i] = 0;
                } else {
                    a[i]--;
                    if (a[i] < 0) a[i] = n - 1;
                }
            }
        }
        pl("No");
    }

    public static void main(String[] args) {
        new B().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new BufferedReader(new InputStreamReader(System.in)));
            writer = new PrintWriter(System.out);
            tokenizer = null;
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.println();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
    }

}

No Yes No No No No No No No No No No No No No No No Yes No No No No Yes No No Yes No No No No No No No No No Yes Yes No Yes No No Yes No No No No No No No No

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  for (int i = 1; i < n; ++i) {
    int a;
    cin >> a;
    if (i != (a + d * (i & 1 ? 1 : -1) + n) % n) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        final int[] a = in.nextAi(n);
        Integer[] pos = new Integer[n];
        for (int i = 0; i < n; i++) {
            pos[i] = i;
        }
        Arrays.sort(pos, new Comparator<Integer>() {
            public int compare(Integer o1, Integer o2) {
                return a[o1] - a[o2];
            }
        });
        int ans = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (k >= a[pos[i]]) {
                ans++;
                k -= a[pos[i]];
                sb.append((pos[i] + 1) + " ");
            }
        }
        out.println(ans);
        out.println(sb);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public int[] nextAi(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

}

I = lambda: map(int, input().split())
n, k = I()
l = sorted(zip(I(), range(1, n+1)))
h = []
for i, j in l:
    k -= i
    if k>=0: h.append(j)
print(len(h));print(*h)


s, e = [int(num) for num in input().split()]

def GCD(a, b):
    return GCD(b, a % b) if b else a

result = -1

for i in range(s, e + 1):
    for j in range(i + 1, e + 1):
        if GCD(i, j) == 1:
            for k in range(j + 1, e + 1):
                if GCD(j, k) == 1 and GCD(i, k) != 1:
                    print(i, j, k)
                    result = 0
                    break

        if not result:
            break

    if not result:
        break

if result:
    print(result)

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, a, b, c, r;
  cin >> l >> r;
  if ((r - l < 2) || (r - l == 2 && l % 2 == 1))
    cout << -1;
  else {
    if (l % 2 == 0) {
      a = l;
      b = a + 1;
      c = b + 1;
    } else {
      a = l + 1;
      b = a + 1;
      c = b + 1;
    }
    cout << a << ' ' << b << ' ' << c;
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int x, y;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> x >> y;
  double dist = sqrt((x * x + y * y));
  if ((y >= 0 && x >= 0) || (y < 0 && x < 0)) {
    if (int(dist) % 2 && int(dist) != dist)
      return cout << "white", 0;
    else
      return cout << "black", 0;
  } else {
    if (int(dist) % 2 || int(dist) == dist)
      return cout << "black", 0;
    else
      return cout << "white", 0;
  }
  return 0;
}

black black black white black black white white black black black black black white black black white white black black black black black black black white black white white white white black black black white white black white white black black black black black black white white black black white black black black black black

import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
    //Scanner input = new Scanner(new File("input.txt"));
    //PrintWriter out = new PrintWriter(new File("output.txt"));
  input.init(System.in);
  PrintWriter out = new PrintWriter(System.out);

  int x = input.nextInt(), y = input.nextInt();
  int rs = x*x+y*y;
  double r = Math.sqrt(rs);
  if((int)r == r || x == 0 || y == 0)
      out.print("black");
  else
  {
      int a = ((int)r)%2;
      if(x*y<0)
          a = 1-a;
      out.println(a==0 ? "black":"white");
  }

  out.close();

}
static ArrayList<Integer>[] g;
static boolean[] marked;
static int[] id, low, stk;
static int pre, count;
static void scc()
{
    id = new int[g.length]; low = new int[g.length]; stk = new int[g.length+1];
    pre = count = 0;
    marked = new boolean[g.length];
    for(int i =0; i<g.length; i++)
        if(!marked[i]) dfs(i);
}
static void dfs(int i)
{
    marked[stk[++stk[0]]=i] = true;
    int min = low[i] = pre++;
    for(int j: g[i])
    {
        if(!marked[j]) dfs(j);
        if(low[j] < min) min = low[j];
    }
    if(min < low[i]) low[i] = min;
    else
    {
        while(stk[stk[0]] != i)
        {
            int j =stk[stk[0]--];
            id[j] = count;
            low[j] = g.length;
        }
        id[stk[stk[0]--]] = count++;
        low[i] = g.length;
    }
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static long nextLong() throws IOException {
      return Long.parseLong( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class DimaAndSalad {

	static int n , k , a[] , b[] , offset = 100000;
	static int[][] memo;

	static int INF = (int)(1e9);

	static int solve(int idx , int taste)
	{
		if(idx ==n)
			if(taste == 0)
				return 0;
			else
				return -INF;

		if(memo[idx][taste+offset]!=-1)
			return memo[idx][taste+offset];

		int take = a[idx]+solve(idx+1,taste+a[idx]-b[idx]);
		int leave = solve(idx+1,taste);

		int ans = Math.max(take, leave);
		return memo[idx][taste+offset] = ans;

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		k = sc.nextInt();

		a = new int[n];
		b = new int[n];
		for(int i=0;i<n;i++)
			a[i] = sc.nextInt();

		for(int i=0;i<n;i++)
			b[i] = sc.nextInt()*k;

		memo = new int[n+3][200000+3];

		for(int i=0;i<memo.length;i++)
			Arrays.fill(memo[i], -1);
		int ans = solve(0,0);
		System.out.println(ans ==0?-1:ans);

	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}
	}
}

from bisect import bisect_right
n, k = map(int, input().split())
t = sorted((u - k * v, v) for u, v in zip(*(map(int, input().split()), map(int, input().split()))))
m = n - bisect_right(t, (0, 0))
l, p, t = 0, [0] * 100001, t[:: -1]
for d, v in t[: m]:
    for j in range(l, 0, -1):
        if p[j]: p[j + d] = max(p[j + d], p[j] + v)
    p[d] = max(p[d], p[0] + v)
    l += d
for d, v in t[m: ]:
    for j in range(- d, l + 1):
        if p[j]: p[j + d] = max(p[j + d], p[j] + v)
print(p[0] * k if p[0] else -1)


I = lambda : list(map(int, input().split(' ')))
a, b = I()

ans = 0
while a > 0 and b > 0 and  a//b > 0 or b//a > 0:
    ans += a//b
    a, b = b, a%b
print(ans)

#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long maxn = 2 * (long long)1e5 + 10;
const long double EPS = 1e-9;
const long long INF = (long long)1e18 + 18;
const long long mod = (long long)1e9 + 9;
long long a, b, ans = 0;
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  if (a < b) swap(a, b);
  while (b > 0) {
    ans += (a / b);
    a %= b;
    if (a < b) swap(a, b);
  }
  cout << ans << '\n';
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, f, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> f;
    sum += f;
  }
  int count = 0, demo = sum;
  for (int j = 1; j <= 5; j++) {
    demo++;
    if (demo % (n + 1) != 1) count++;
  }
  cout << count;
  return 0;
}

def solve(n,d):
    other = 0
    for i in d:
        other += i

    ways = 0
    for i in range(1,6):
        if (other + i) % (n + 1) != 1:
            ways += 1

    print(ways)

def main():
    n = int(input())
    d = input()
    d = [int(i) for i in d.split()]
    solve(n,d)

main()


import java.util.*;
import java.io.*;

public class Main {
    static final int MAXC = 2500005;
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(in.readLine());
        int[] a = new int[n];
        StringTokenizer line = new StringTokenizer(in.readLine());
        for(int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(line.nextToken());
        }
        ArrayList<Pair>[] pairs = new ArrayList[MAXC * 2];
        for(int i = 0; i < pairs.length; i++) pairs[i] = new ArrayList<Pair>();
        boolean possible = false;
        int[] res = null;
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                Pair cur = new Pair(i, j);
                int sum = a[i] + a[j];
                ArrayList<Pair> eq = pairs[sum];
                for(Pair p : eq) {
                    if(cur.a != p.a && cur.a != p.b && cur.b != p.a && cur.b != p.b) {
                        possible = true;
                        res = new int[] {cur.a + 1, cur.b + 1, p.a + 1, p.b + 1};
                        break;
                    }
                }
                eq.add(cur);
                if(possible) break;
                else {
                    if(eq.size() >= 4) {
                        possible = true;
                        Pair w = eq.get(0);
                        Pair x = eq.get(1);
                        Pair y = eq.get(2);
                        Pair z = eq.get(3);
                        if(w.a == x.a) {
                            res = new int[] {w.b + 1, x.b + 1, y.b + 1, z.b + 1};
                        }else {
                            res = new int[] {w.a + 1, x.a + 1, y.a + 1, z.a + 1};
                        }
                        break;
                    }
                }
            }
            if(possible) break;
        }
        if(possible) {
            out.println("YES");
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < 4; i++) {
                sb.append(res[i]);
                if(i < 3) sb.append(' ');
            }
            out.println(sb.toString());
        }else {
            out.println("NO");
        }
		in.close();
		out.close();
	}
    static class Pair {
        int a, b;
        Pair(int aa, int bb) {
            a = aa;
            b = bb;
        }
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[200005],fx[5000005],fy[5000005],lst;
vector<int> v[2500005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]),v[a[i]].push_back(i);
		if(v[a[i]].size()==4){
			puts("YES");
			for(int j:v[a[i]])cout<<j<<' ';
			return 0;
		}
		if(v[a[i]].size()==2){
			if(lst)printf("YES\n%d %d %d %d\n",v[a[i]][0],v[lst][0],v[a[i]][1],v[lst][1]),exit(0);
			else lst=a[i];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++){
			if(!fx[a[i]+a[j]])fx[a[i]+a[j]]=i,fy[a[i]+a[j]]=j;
			else {
				if(i!=fx[a[i]+a[j]]&&j!=fx[a[i]+a[j]]&&i!=fy[a[i]+a[j]]&&j!=fy[a[i]+a[j]]){
					printf("YES\n%d %d %d %d\n",i,j,fx[a[i]+a[j]],fy[a[i]+a[j]]);
					return 0;
				}
			}
		}
	}
	puts("NO");
	return 0;
}