After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $n$. Let's call them $a$ and $b$.

Note that a permutation of $n$ elements is a sequence of numbers $a_1, a_2, \ldots, a_n$, in which every number from $1$ to $n$ appears exactly once. 

The message can be decoded by an arrangement of sequence $a$ and $b$, such that the number of matching pairs of elements between them is maximum. A pair of elements $a_i$ and $b_j$ is said to match if:   $i = j$, that is, they are at the same index.  $a_i = b_j$ 

His two disciples are allowed to perform the following operation any number of times:   choose a number $k$ and cyclically shift one of the permutations to the left or right $k$ times. 

A single cyclic shift to the left on any permutation $c$ is an operation that sets $c_1:=c_2, c_2:=c_3, \ldots, c_n:=c_1$ simultaneously. Likewise, a single cyclic shift to the right on any permutation $c$ is an operation that sets $c_1:=c_n, c_2:=c_1, \ldots, c_n:=c_{n-1}$ simultaneously.

Help Ishika and Hriday find the maximum number of pairs of elements that match after performing the operation any (possibly zero) number of times.


-----Input-----

The first line of the input contains a single integer $n$ $(1 \le n \le 2 \cdot 10^5)$ — the size of the arrays.

The second line contains $n$ integers $a_1$, $a_2$, ..., $a_n$ $(1 \le a_i \le n)$ — the elements of the first permutation.

The third line contains $n$ integers $b_1$, $b_2$, ..., $b_n$ $(1 \le b_i \le n)$ — the elements of the second permutation.


-----Output-----

Print the maximum number of matching pairs of elements after performing the above operations some (possibly zero) times.


-----Examples-----
Input
5
1 2 3 4 5
2 3 4 5 1

Output
5
Input
5
5 4 3 2 1
1 2 3 4 5

Output
1
Input
4
1 3 2 4
4 2 3 1

Output
2


-----Note-----

For the first case: $b$ can be shifted to the right by $k = 1$. The resulting permutations will be $\{1, 2, 3, 4, 5\}$ and $\{1, 2, 3, 4, 5\}$.

For the second case: The operation is not required. For all possible rotations of $a$ and $b$, the number of matching pairs won't exceed $1$.

For the third case: $b$ can be shifted to the left by $k = 1$. The resulting permutations will be $\{1, 3, 2, 4\}$ and $\{2, 3, 1, 4\}$. Positions $2$ and $4$ have matching pairs of elements. For all possible rotations of $a$ and $b$, the number of matching pairs won't exceed $2$.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

Data structures

Implementation

Constructive algorithms


Solutions:
from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()

def unique(sequence):
	seen = set()
	return [x for x in sequence if not (x in seen or seen.add(x))]
n = int(I1())
a = list(I())
b = list(I())
c = []
c1 = [0] * (n + 1)
c2 = [0] * (n + 1)
for i in range(n):
	c1[a[i]] = i + 1
	c2[b[i]] = i + 1
for i in range(1, n + 1):
	m = (c1[i] - c2[i]) % n
	if c1[i] > c2[i]:
		c.append(m)
	else:
		c.append((m + n) % n)
d = {}
for x in c:
	d[x] = d.get(x, 0) + 1
print(max(list(d.values())))


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	for i in range(n):
		d[a[i]] = i
	r = {}
	l = {}
	zc = 0
	mx = 0
	for j in range(n):
		if d[b[j]] > j:
			rs = (d[b[j]] - j) % n
			ls = (j + n - d[b[j]]) % n
		elif d[b[j]] < j:
			rs = (d[b[j]] - j) % n
			ls = (j + n - d[b[j]]) % n
		else:
			zc += 1
			continue
		if rs not in r:
			r[rs] = 0
		if ls not in l:
			l[ls] = 0
		r[rs] += 1
		l[ls] += 1
		if r[rs] > mx:
			mx = r[rs]
		if l[ls] > mx:
			mx = l[ls]
	print(max(mx, zc))


n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
mpa = dict()
mpb = dict()
for i in range(n):
	mpa[a[i]] = i
	mpb[b[i]] = i
mp1 = dict()
for i in range(n):
	j = mpb[a[i]]
	try:
		if j > i:
			mp1[i + n - j] += 1
		else:
			mp1[i - j] += 1
	except KeyError:
		if j > i:
			mp1[i + n - j] = 1
		else:
			mp1[i - j] = 1
mp2 = dict()
for i in range(n):
	j = mpb[a[i]]
	try:
		if j >= i:
			mp2[j - i] += 1
		else:
			mp2[j + n - i] += 1
	except KeyError:
		if j >= i:
			mp2[j - i] = 1
		else:
			mp2[j + n - i] = 1
res = 0
for i in mp1.values():
	res = max(res, i)
for i in mp2.values():
	res = max(res, i)
print(res)


n = int(input())
a = list(map(int, input().strip().split()))[:n]
b = list(map(int, input().strip().split()))[:n]
db = {}
for i in range(len(a)):
	db[b[i]] = i
res = []
for i in range(len(a)):
	k = db[a[i]]
	if k >= i:
		res.append(k - i)
	else:
		res.append(len(a) - (i - k))
r = [0] * len(a)
for i in range(len(res)):
	r[res[i]] += 1
print(max(r))


from collections import Counter
from sys import stdin
input = stdin.readline
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
narr = [-1 for _ in range(n + 1)]
parr = []
for (i, x) in enumerate(arr):
	narr[x] = i
for (i, y) in enumerate(brr):
	parr.append((i - narr[y]) % n)
print(Counter(parr).most_common(1)[0][1])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from bisect import bisect_left, bisect_right

class Result:

	def __init__(self, index, value):
		self.index = index
		self.value = value

class BinarySearch:

	def __init__(self):
		pass

	@staticmethod
	def greater_than(num: int, func, i, size: int=1):
		if 0 == 1:
			index = bisect_right(func, num)
			if index == len(func):
				return Result(None, None)
			else:
				return Result(index, func[index])
		else:
			(alpha, omega) = (i, size - 1)
			if func(omega) <= num:
				return Result(None, None)
			while alpha < omega:
				if func(alpha) > num:
					return Result(alpha, func(alpha))
				if omega == alpha + 1:
					return Result(omega, func(omega))
				mid = (alpha + omega) // 2
				if func(mid) > num:
					omega = mid
				else:
					alpha = mid

	@staticmethod
	def less_than(num: int, func, size: int=1):
		if isinstance(func, list):
			index = bisect_left(func, num) - 1
			if index == -1:
				return Result(None, None)
			else:
				return Result(index, func[index])
		else:
			(alpha, omega) = (0, size - 1)
			if func(alpha) >= num:
				return Result(None, None)
			while alpha < omega:
				if func(omega) < num:
					return Result(omega, func(omega))
				if omega == alpha + 1:
					return Result(alpha, func(alpha))
				mid = (alpha + omega) // 2
				if func(mid) < num:
					alpha = mid
				else:
					omega = mid
for _ in range(int(input()) if not True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	di = {}
	b = list(map(int, input().split()))
	a += a
	for i in range(2 * n):
		if a[i] not in di:
			di[a[i]] = [i]
		else:
			di[a[i]] += [i]
	bs = BinarySearch()
	ans = [0] * (n + 6)
	for i in range(n):
		nx = di[b[i]]
		nx = nx[0] if nx[0] >= i else nx[1]
		ans[nx - i] += 1
	print(max(ans))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		a[i] = [a[i], i]
		b[i] = [b[i], i]
	a.sort(key=lambda x: x[0])
	b.sort(key=lambda x: x[0])
	ans = [0] * n
	mx = 0
	for i in range(n):
		ans[(n + b[i][1] - a[i][1]) % n] += 1
		mx = max(ans[(n + b[i][1] - a[i][1]) % n], mx)
	print(mx)
main()


from collections import Counter

def solve_test_case(t):
	n = int(input())
	a = parse_array(int)
	b = parse_array(int)
	val_to_idx_a = {e: i for (i, e) in enumerate(a)}
	cc = Counter()
	for (i, e) in enumerate(b):
		pos_a = val_to_idx_a[e]
		distance = (pos_a + n - i) % n
		cc[distance] += 1
	print(cc.most_common(1)[0][1])

def parse_array(f):
	return list(map(f, input().split()))

def solve():
	T = int(input())
	for t in range(T):
		solve_test_case(t)
solve_test_case(0)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pa = [0] * (n + 1)
pb = [0] * (n + 1)
for i in range(0, n):
	pa[a[i]] = i
	pb[b[i]] = i
pa.pop(0)
pb.pop(0)
d = []
for i in range(0, n):
	d.append((pa[i] - pb[i]) % n)
f = [0] * n
for i in d:
	f[i] += 1
print(max(f))


from collections import Counter

def solve(list1, list2, n):
	inverse_index = {element: index for (index, element) in enumerate(list1)}
	return [inverse_index[element] - index if inverse_index[element] - index >= 0 else n + inverse_index[element] - index for (index, element) in enumerate(list2) if element in inverse_index]
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(1)
else:
	print(max(Counter(solve(a, b, n)).values()))


a = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
(m, n) = ({}, {})
for i in range(a):
	m[b[i]] = i + 1
	n[c[i]] = i + 1
d = {}
for j in b:
	if m[j] <= n[j]:
		z = n[j] - m[j]
	else:
		z = a - (m[j] - n[j])
	if z in d:
		d[z] += 1
	else:
		d[z] = 1
print(max(d.values()))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
dica = {}
dicb = {}
for i in range(n):
	dica[a[i]] = i
	dicb[b[i]] = i
dicl = {}
dicr = {}
for i in range(1, n + 1):
	x = dica[i] - dicb[i]
	if x < 0:
		x += n
	if x in dicl.keys():
		dicl[x] += 1
	else:
		dicl[x] = 1
	x = -dica[i] + dicb[i]
	if x < 0:
		x += n
	if x in dicr.keys():
		dicr[x] += 1
	else:
		dicr[x] = 1
ans = 0
for i in dicr.keys():
	if ans < dicr[i]:
		ans = dicr[i]
for i in dicl.keys():
	if ans < dicl[i]:
		ans = dicl[i]
print(ans)


from collections import Counter

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(d, d1) = (dict(), [])
	for i in range(n):
		d[a[i]] = i
	for i in range(n):
		if i - d[b[i]] > 0:
			d1.append(i - d[b[i]])
		else:
			d1.append(n + i - d[b[i]])
	c = dict(Counter(d1))
	print(max(list(c.values())))
main()


from collections import defaultdict
from sys import stdin, stdout
n = int(input())
alist = list(map(int, stdin.readline().strip().split()))
blist = list(map(int, stdin.readline().strip().split()))
aind = dict()
for i in range(n):
	aind[alist[i]] = i
dist = defaultdict(int)
ans = 0
for j in range(n):
	top = aind[blist[j]]
	bottom = j
	if top >= bottom:
		dist[top - bottom] += 1
		ans = max(ans, dist[top - bottom])
	else:
		dist[top + n - bottom] += 1
		ans = max(ans, dist[top + n - bottom])
print(ans)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
d = {}
for i in range(N):
	d[A[i]] = i
for j in range(N):
	d[B[j]] = d[B[j]] - j
	if d[B[j]] < 0:
		d[B[j]] += N
ct = {}
max_n = 0
for j in d:
	if d[j] in ct:
		ct[d[j]] += 1
	else:
		ct[d[j]] = 1
	max_n = max(max_n, ct[d[j]])
print(max_n)


def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	(da, db) = ({}, {})
	for i in range(n):
		da[a[i]] = i
		db[b[i]] = i
	(d1, d2) = ({}, {})
	for ele in da:
		(x, y) = (da[ele], db[ele])
		if y < x:
			k1 = y + n - x
			k2 = x - y
		else:
			k1 = y - x
			k2 = x + n - y
		d1[k1] = d1.get(k1, 0) + 1
		d2[k2] = d2.get(k2, 0) + 1
	mx = -100000000
	for ele in d1:
		if d1[ele] > mx:
			note = ele
			mx = d1[ele]
	for ele in d2:
		if d2[ele] > mx:
			note = ele
			mx = d1[ele]
	print(mx)
solve()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
adict = dict(zip(a, range(len(a))))
bdict = dict(zip(b, range(len(a))))
diff_map = {}
for i in adict.keys():
	if bdict[i] <= adict[i]:
		diff = adict[i] - bdict[i]
	else:
		diff = len(a) - bdict[i] + adict[i]
	if diff in diff_map:
		diff_map[diff] += 1
	else:
		diff_map[diff] = 1
print(max(diff_map.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
h = {}
for i in range(n):
	h[a[i]] = i
cnt = [0] * n
for i in range(n):
	if h[b[i]] >= i:
		cnt[h[b[i]] - i] += 1
	else:
		cnt[n + h[b[i]] - i] += 1
print(max(cnt))


import sys
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

def rlinput():
	return list(map(int, input().split()))

def srlinput():
	return sorted(list(map(int, input().split())))

def main():
	n = iinput()
	q = rlinput()
	b = dict()
	o = 0
	for i in rlinput():
		b[i] = o
		o += 1
	res = [0 for i in range(n)]
	for i in range(n):
		res[i] = b[q[i]] - i
		if res[i] < 0:
			res[i] += n
	f = dict()
	for i in res:
		if i in f:
			f[i] += 1
		else:
			f[i] = 1
	z = 0
	for (i, v) in f.items():
		z = max(z, v)
	print(z)
for inytd in range(1):
	main()


n = int(input())
a = [0]
b = [0]
pos = [0 for i in range(n + 1)]
offset = {}
arr = list(map(int, input().split()))
a += arr
for i in range(1, n + 1):
	pos[a[i]] = i
arr1 = list(map(int, input().split()))
b += arr1
for i in range(1, n + 1):
	cur = pos[b[i]] - i
	if cur < 0:
		cur += n
	if cur in offset:
		offset[cur] += 1
	else:
		offset[cur] = 1
ans = 0
for i in offset:
	ans = max(offset[i], ans)
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ha = {}
hb = {}
hclc = [0 for _ in range(n)]
hacc = [0 for _ in range(n)]
for i in range(n):
	ha[a[i]] = i
	hb[b[i]] = i
macc = 0
mclc = 0
zero = 0
for i in range(1, n + 1):
	t = hb[i] - ha[i]
	if t > 0:
		hclc[t] += 1
		hacc[n - t] += 1
		if hclc[t] > mclc:
			mclc = hclc[t]
		if macc < hacc[n - t]:
			macc = hacc[n - t]
	elif t < 0:
		hclc[n + t] += 1
		hacc[abs(t)] += 1
		if hclc[n + t] > mclc:
			mclc = hclc[n + t]
		if macc < hacc[abs(t)]:
			macc = hacc[abs(t)]
	else:
		zero += 1
print(max(macc, mclc, zero))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = [0] * 200005
t1 = [0] * 200005
for i in range(n):
	t[a[i]] = i
	t1[b[i]] = i
ans = [0] * 200005
for i in range(1, n + 1):
	ans[(t[i] - t1[i] + n) % n] = ans[(t[i] - t1[i] + n) % n] + 1
print(max(ans))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [0] * n
for i in range(n):
	l[b[i] - 1] = i
p = [0] * n
for i in range(n):
	j = l[a[i] - 1]
	if i - j >= 0:
		p[a[i] - 1] = i - j
	else:
		p[a[i] - 1] = n - j + i
d = Counter(p)
mx = -1
for c in d:
	mx = max(mx, d[c])
print(mx)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
arr = list(map(int, input().split()))
ls = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[arr[i]] = i
d = {}
for i in range(n):
	ans = (i - dic[ls[i]]) % n
	if ans in d:
		d[ans] += 1
	else:
		d[ans] = 1
print(max(d.values()))


n = int(input())
a = [int(ele) for ele in input().split()]
b = [int(ele) for ele in input().split()]
mem = {}
diff = []
for i in range(1, n + 1):
	mem[i] = []
for i in range(n):
	mem[a[i]].append(i)
for i in range(n):
	mem[b[i]].append(i)
for i in range(n):
	diff.append(0)
for key in mem.keys():
	if mem[key][0] <= mem[key][1]:
		differ = mem[key][1] - mem[key][0]
		diff[differ] += 1
	else:
		differ = n - mem[key][0] + mem[key][1]
		diff[differ] += 1
print(max(diff))


num_nums = int(input())
first = [int(i) for i in input().split()]
second = [int(i) for i in input().split()]
first_indices = [0 for n in range(num_nums)]
second_indices = [0 for n in range(num_nums)]
for i in range(num_nums):
	first_indices[first[i] - 1] = i
	second_indices[second[i] - 1] = i
diffs = {}
for i in range(num_nums):
	diff = first_indices[i] - second_indices[i]
	if diff >= 0:
		diffs[diff] = diffs.get(diff, 0) + 1
	else:
		diff = first_indices[i] + (num_nums - second_indices[i])
		diffs[diff] = diffs.get(diff, 0) + 1
print(max(diffs.values()))


import sys
from collections import Counter
input = sys.stdin.buffer.readline

def prog():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	index_diff = [0 for i in range(n + 1)]
	for i in range(n):
		index_diff[b[i]] = i
	for i in range(n):
		num = a[i]
		index_diff[num] = (index_diff[num] - i) % n
	totals = Counter(index_diff[1:])
	print(max(totals.values()))
prog()


import sys
import math
import collections
from collections import deque
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	ai = [0] * (n + 1)
	bi = [0] * (n + 1)
	for i in range(n):
		ai[a[i]] = i
		bi[b[i]] = i
	d = {}
	for k in range(1, n + 1):
		sft = ai[k] - bi[k]
		if sft >= 0:
			if sft not in d:
				d[sft] = 0
			d[sft] += 1
		else:
			if n - abs(sft) not in d:
				d[n - abs(sft)] = 0
			d[n - abs(sft)] += 1
	print(max(d.values()))


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline())
n = II()
aid = {v: i for (i, v) in enumerate(MI(), 1)}
dist = {}
for (i, v) in enumerate(MI(), 1):
	if aid[v] >= i:
		dist[aid[v] - i] = dist.get(aid[v] - i, 0) + 1
	else:
		dist[n - i + aid[v]] = dist.get(n - i + aid[v], 0) + 1
print(max(dist.values()))


import sys, math
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
posa = [0] * (n + 1)
posb = [0] * (n + 1)
for i in range(n):
	posa[a[i]] = i
	posb[b[i]] = i
for i in range(1, n + 1):
	if posa[i] < posb[i]:
		posa[i] += n
res = dict().fromkeys([i for i in range(n + 1)], 0)
for i in range(1, n + 1):
	res[posa[i] - posb[i]] += 1
ans = 0
for i in res:
	ans = max(ans, res[i])
print(ans)


n = int(input())
import collections
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a1 = {}
b1 = {}
c = 0
for i in range(n):
	a1[a[i]] = i
	b1[b[i]] = i
	if a[i] == b[i]:
		c += 1
d = []
for i in a1:
	e = a1[i] - b1[i]
	if e < 0:
		e = n + e
	d.append(e)
d1 = collections.Counter(d)
if len(d1) == len(d):
	print('1')
else:
	t = 0
	for i in d1:
		t = max(t, d1[i])
	print(t)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = {}
cunt = [0] * (n + 1)
for i in range(n):
	pos[a[i]] = i
Max = 0
for j in range(n):
	t = j - pos[b[j]]
	if t < 0:
		t = n + t
	cunt[t] += 1
	Max = max(Max, cunt[t])
print(Max)


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
n = int(input())
la = list([int(x) for x in input().split()])
lb = list([int(x) for x in input().split()])
krish = 'raj'
ans = 100
kriish = ans + 9
se = set()
if la == lb:
	print(n)
else:
	da = dict()
	db = dict()
	for i in range(n):
		da.update({la[i]: i})
	for i in range(n):
		db.update({lb[i]: i})
	dif = [0] * n
	for i in range(1, n + 1):
		dif[i - 1] = (da[i] - db[i]) % n
	ans = dict()
	for i in range(n):
		if dif[i] in ans:
			ans[dif[i]] += 1
		else:
			ans.update({dif[i]: 1})
	print(max(ans.values()))


def f():
	n = int(input())
	A = [int(s) for s in input().split()]
	B = [int(s) for s in input().split()]
	inda = [0] * (n + 1)
	indb = [0] * (n + 1)
	for i in range(n):
		inda[A[i]] = i
		indb[B[i]] = i
	d = [0] * n
	for i in range(1, n + 1):
		x = indb[i] - inda[i]
		if x < 0:
			x += n
		d[x] += 1
	ans = 0
	for dis in d:
		ans = max(ans, dis)
	print(ans)
f()


l = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
cnt = 0
for i in a:
	d[i] = cnt
	cnt += 1
right = []
left = []
for i in range(l):
	dif = d[b[i]] - i
	if dif < 0:
		left.append(abs(dif))
		dif2 = l - abs(dif)
		right.append(dif2)
	else:
		right.append(dif)
		dif2 = l - dif
		left.append(dif2)
ans1 = [0] * (l + 1)
ans2 = [0] * (l + 1)
for i in range(l):
	ans1[right[i]] = ans1[right[i]] + 1
	ans2[left[i]] = ans2[left[i]] + 1
x = max(ans1)
y = max(ans2)
print(max(x, y))


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
pos = [0] * (n + 1)
for i in range(0, n):
	val = b[i]
	pos[val] = i
d = dict()
for i in range(0, n):
	val = a[i]
	posn = pos[val]
	diff = posn - i
	if diff < 0:
		diff = n + diff
	if diff not in d:
		d[diff] = 1
	else:
		d[diff] += 1
mxval = 0
for i in d:
	val = d[i]
	mxval = max(mxval, val)
print(mxval)


def most_frequent(arr, n):
	max_count = 1
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			max_count = max(curr_count, max_count)
			curr_count = 1
	return max(max_count, curr_count)
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
hm = {}
for i in range(n):
	hm[arr[i]] = [i]
for i in range(n):
	hm[brr[i]].append(i)
count = []
for i in arr:
	pos1 = hm[i][0]
	pos2 = hm[i][1]
	if pos1 == pos2:
		count.append(0)
	elif pos1 > pos2:
		count.append(n - pos1 + pos2)
	else:
		count.append(pos2 - pos1)
count.sort()
print(most_frequent(count, n))


import sys
input = sys.stdin.buffer.readline
from collections import Counter

def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a

def check(k):
	a1 = a[k:] + a[:k]
	c = 0
	print(a1, b)
	for i in range(n):
		if a1[i] != b[i]:
			c += 1
	return n - c
n = int(input())
a = I()
b = I()
c = 0
aidxs = [-1] * (n + 1)
bidxs = [-1] * (n + 1)
for i in range(n):
	aidxs[a[i]] = i
	bidxs[b[i]] = i
cs = []
for i in range(1, n + 1):
	if aidxs[i] <= bidxs[i]:
		cs.append(bidxs[i] - aidxs[i])
	else:
		cs.append(n - (aidxs[i] - bidxs[i]))
print(Counter(cs).most_common(1)[0][1])


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = dict()
for (i, x) in enumerate(list(map(int, input().split()))):
	b[x] = i
res = defaultdict(lambda : 0)
for (i, e) in enumerate(a):
	diff = i - b[e]
	if diff < 0:
		diff += n
	res[diff] += 1
print(max(res.values()))


from collections import deque
from sys import stdin, stdout
import math
input = stdin.readline

def calc(first, second):
	global n
	if first > second:
		return n - first
	return second - first
n = int(input())
first = {}
second = {}
for (ind, i) in enumerate(map(int, input().split())):
	first[i] = ind
for (ind, i) in enumerate(map(int, input().split())):
	second[i] = ind
times = {}
for i in range(n):
	delta = i - first[i + 1] - (i - second[i + 1])
	if delta < 0:
		delta = n + delta
	if delta not in times:
		times[delta] = 0
	times[delta] += 1
print(max(times.values()))


n = int(input())
a = [int(j) for j in input().split()]
b = [int(j) for j in input().split()]
a_pos = {}
for i in range(n):
	a_pos[a[i]] = i
counter = {}
for i in range(n):
	diff = i - a_pos[b[i]]
	if diff < 0:
		diff = diff + n
	if diff in counter:
		counter[diff] += 1
	else:
		counter[diff] = 1
all_values = counter.values()
print(max(all_values))


a = input()
b = input().split(' ')
c = input().split(' ')
list1 = [i for i in b]
list2 = [i for i in c]
list3 = []
dict = {}
dict2 = {}
for i in range(int(a)):
	dict2[list2[i]] = i
for i in range(int(a)):
	tag = i - dict2[list1[i]]
	if tag not in dict:
		dict[tag] = 1
	else:
		dict[tag] += 1
	if tag - int(a) not in dict:
		dict[tag - int(a)] = 1
	else:
		dict[tag - int(a)] += 1
	if tag + int(a) not in dict:
		dict[tag + int(a)] = 1
	else:
		dict[tag + int(a)] += 1
print(dict[max(dict, key=dict.get)])


inp = lambda : map(int, input().split(' '))
(n,) = inp()
steps = [0] * n
count = [0] * n
i = 0
for (a, b) in zip(inp(), inp()):
	steps[a - 1] += i
	steps[b - 1] -= i
	i += 1
for i in range(n):
	count[steps[i] % n] += 1
print(max(count))


n = int(input())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
sub = [0 for k in range(n)]
distancia = [0 for k in range(n)]
for k in range(n):
	sub[ai[k] - 1] -= k
	sub[bi[k] - 1] += k
for k in range(n):
	if sub[k] < 0:
		distancia[n + sub[k]] += 1
	else:
		distancia[sub[k]] += 1
print(max(distancia))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arr = [[] for i in range(n)]
for i in range(n):
	arr[a[i] - 1].append(i + 1)
for i in range(n):
	arr[b[i] - 1].append(i + 1)
ans = [[] for i in range(n)]
for i in range(n):
	if arr[i][0] > arr[i][1]:
		ans[i].append(arr[i][0] - arr[i][1])
	elif arr[i][0] < arr[i][1]:
		ans[i].append(arr[i][0] + n - arr[i][1])
	else:
		ans[i].append(0)
for i in range(n):
	if arr[i][0] < arr[i][1]:
		ans[i].append(arr[i][1] - arr[i][0])
	elif arr[i][0] > arr[i][1]:
		ans[i].append(arr[i][1] + n - arr[i][0])
	else:
		ans[i].append(0)
array = [0] * n
array2 = [0] * n
for i in range(n):
	array[ans[i][0] - 1] += 1
for i in range(n):
	array2[ans[i][1] - 1] += 1
x = max(array)
y = max(array2)
print(max(x, y))


n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) - 1 for i in input().split()]
c = list(range(n))
for i in range(n):
	c[a[i]] = i
for i in range(n):
	b[i] = c[b[i]]
c = [0] * n
for i in range(n):
	c[(b[i] - i + n) % n] += 1
print(max(c))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
index = [-1] * (n + 5)
for i in range(n):
	index[b[i]] = i
freq = [0] * (n + 5)
for i in range(n):
	j = index[a[i]]
	if j < i:
		freq[n - i + j] += 1
	else:
		freq[j - i] += 1
print(max(freq))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = [0] * n
	for i in range(n):
		x[b[i] - 1] = i
	offset = {}
	for i in range(n):
		cur = x[a[i] - 1] - i
		if cur < 0:
			cur += n
		if offset.get(cur):
			offset[cur] += 1
		else:
			offset[cur] = 1
	ans = 0
	for pair in offset.items():
		ans = max(ans, pair[1])
	print(ans)
main()


from statistics import mode
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [0] * n
l1 = [0] * n
l2 = [0] * n
for i in range(n):
	l1[a[i] - 1] = i
	l2[b[i] - 1] = i
for i in range(n):
	l[(l1[i] - l2[i]) % n] += 1
print(max(l))


import math
t = 1
for _ in range(t):
	n = int(input())
	a = [int(var) for var in input().split()]
	b = [int(var) for var in input().split()]
	(bMap, deltaMap, maxMatch) = ({}, {}, 0)
	for i in range(n):
		bMap[b[i]] = i
	for i in range(n):
		delta = bMap[a[i]] - i
		if delta > 0:
			delta = -(n - delta)
		deltaMap[delta] = 1 + deltaMap.get(delta, 0)
		maxMatch = max(maxMatch, deltaMap[delta])
print(maxMatch)


n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
indexes1 = [0] * (n + 1)
indexes2 = [0] * (n + 1)
for i in range(n):
	indexes1[arr[i]] = i
	indexes2[brr[i]] = i
d = dict()
for i in range(1, n + 1):
	if indexes1[i] >= indexes2[i]:
		x = indexes1[i] - indexes2[i]
	else:
		x = n + indexes1[i] - indexes2[i]
	d[x] = d.get(x, 0) + 1
print(d[max(d, key=d.get)])


n = int(input())
s = list(map(int, input().split()))
ss = list(map(int, input().split()))
k = []
d = {}
dd = {}
for i in range(n):
	d[s[i]] = i
for i in range(n):
	dd[ss[i]] = i
for i in s:
	new = d[i] - dd[i]
	if new < 0:
		new += n
	k.append(new)
freq = 0
dictionary = {}
for i in k:
	dictionary[i] = 1
for i in k:
	dictionary[i] += 1
p = dictionary.values()
print(max(p) - 1)


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
order_a = sorted(range(len(a)), key=lambda k: a[k])
order_b = sorted(range(len(b)), key=lambda k: b[k])
left = [0] * n
rigth = [0] * n
for i in range(n):
	aux = order_a[i] - order_b[i]
	if aux == 0:
		left[0] += 1
		rigth[0] += 1
	elif aux > 0:
		left[aux] += 1
		rigth[n - aux] += 1
	else:
		left[n + aux] += 1
		rigth[abs(aux)] += 1
(a_max, b_max) = (max(rigth), max(left))
print(max(a_max, b_max))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[a[i]] = i
result = {}
for i in range(n):
	diff = i - d[b[i]]
	if diff < 0:
		diff = n + diff
	if diff in result:
		result[diff] += 1
	else:
		result[diff] = 1
maximum = -99999
for i in result:
	maximum = max(maximum, result[i])
print(maximum)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [0] * n
y = [0] * n
for i in range(n):
	x[a[i] - 1] = i
	y[b[i] - 1] = i
ans = [0] * n
for i in range(n):
	m = (x[i] - y[i]) % n
	ans[m] += 1
print(max(ans))


n = int(input())
line1 = [int(x) for x in input().split(' ')]
line2 = [int(x) for x in input().split(' ')]
div1 = [0] * n
div2 = [0] * n
div = [0] * n
for x in range(n):
	div1[line1[x] - 1] = (line1[x] - x - 1) % n
	div2[line2[x] - 1] = (line2[x] - x - 1) % n
for x in range(n):
	div[x] = (div1[x] - div2[x]) % n
res = [0] * n
for x in range(n):
	res[div[x]] += 1
print(max(res))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(l1, l2) = ({}, {})
for i in range(n):
	l1[a[i]] = i
	l2[b[i]] = i
v = []
for i in range(1, n + 1):
	if l2[i] - l1[i] < 0:
		v.append(l2[i] - l1[i] + n)
		continue
	v.append(l2[i] - l1[i])
c = Counter(v)
m = 0
for i in c:
	m = max(m, c[i])
print(m)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[b[i]] = i
cnt = []
for i in range(n):
	cnt.append((d[a[i]] - i) % n)
d = {}
max_now = 0
ind = 0
for i in cnt:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
	if d[i] > max_now:
		ind = i
		max_now = d[i]
print(max_now)


from sys import stdout
from sys import stdin

def get():
	return stdin.readline().strip()

def getf():
	return [int(i) for i in get().split()]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join(map(str, a)) + end)
from collections import defaultdict as dd

def main():
	n = int(get())
	a = getf()
	b = getf()
	d = {}
	cnt = dd(int)
	p = [0] * n
	for i in range(n):
		d[a[i]] = i
	for i in range(n):
		x = d[b[i]] - i
		if x < 0:
			p[i] = n + x
			cnt[n + x] += 1
		else:
			p[i] = x
			cnt[x] += 1
	ans = 0
	for i in cnt:
		if cnt[i] > ans:
			ans = cnt[i]
	put(ans)
main()


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0] * n
D = [0] * n
for i in range(n):
	C[A[i] - 1] = i
	D[B[i] - 1] = i
from collections import Counter
ANS = Counter()
for i in range(n):
	ANS[(C[i] - D[i]) % n] += 1
print(max(ANS.values()))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
c = [0] * n
x = [0] * n
m = 0
for i in range(n):
	x[l1[i] - 1] += i
	x[l2[i] - 1] -= i
for i in range(n):
	c[x[i] % n] += 1
print(max(c))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
idx = [0] * n
cnt = [0] * n
for i in range(n):
	idx[a[i] - 1] = i
for i in range(n):
	cnt[idx[b[i] - 1] - i] += 1
print(max(cnt))


from collections import defaultdict
n = int(input())
a = [x for x in map(int, input().split(' '))]
b = [x for x in map(int, input().split(' '))]
a_pos = dict()
diff = defaultdict(lambda : 0)
for (i, v) in enumerate(a):
	a_pos[v] = i
for (i, v) in enumerate(b):
	p = a_pos[v]
	dist = p - i
	if dist < 0:
		dist += n
	diff[dist] += 1
maxk = 0
for k in diff:
	maxk = max(maxk, diff[k])
print(maxk)


import sys
input = sys.stdin.readline
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
c = [0] * (n + 1)
count = dict()
for i in range(1, n + 1):
	c[a[i]] = i
for i in range(1, n + 1):
	cur = (c[b[i]] - i + n) % n
	try:
		count[cur] += 1
	except:
		count[cur] = 1
print(max(count.values()))


def most_frequent(List):
	dict = {}
	(count, itm) = (0, '')
	for item in reversed(List):
		dict[item] = dict.get(item, 0) + 1
		if dict[item] >= count:
			(count, itm) = (dict[item], item)
	return itm
from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
	ans[a[i] - 1] += i
	ans[b[i] - 1] -= i
i = 0
while i < n:
	if ans[i] < 0:
		ans[i] += n
	i += 1
s = ans.count(most_frequent(ans))
print(s)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = [0] * n
k1 = [0] * n
k2 = [0] * n
for i in range(n):
	k1[a[i] - 1] = i
	k2[b[i] - 1] = i
for i in range(n):
	k[(k1[i] - k2[i]) % n] += 1
print(max(k))


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
index = {}
count = 0
for i in range(N):
	index[A[i]] = i
count1 = 0
count2 = 0
dic = {}
for i in range(N):
	t = index[B[i]]
	r = (i - t) % N
	if r not in dic:
		dic[r] = 1
	else:
		dic[r] += 1
dic = sorted(dic.items(), key=lambda x: x[1])
print(dic[-1][1])


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = {}
d2 = {}
for i in range(n):
	d1[a[i]] = i
	d2[b[i]] = i
d3 = sorted(list(d1.keys()))
d = {}
for i in range(len(d3)):
	if d1[d3[i]] == 0 and d2[d3[i]] == n - 1:
		if 1 in d:
			d[1] += 1
		else:
			d[1] = 1
	elif d1[d3[i]] == n - 1 and d2[d3[i]] == 0:
		if n - 1 in d:
			d[n - 1] += 1
		else:
			d[n - 1] = 1
	elif d1[d3[i]] - d2[d3[i]] >= 0:
		if d1[d3[i]] - d2[d3[i]] in d:
			d[d1[d3[i]] - d2[d3[i]]] += 1
		else:
			d[d1[d3[i]] - d2[d3[i]]] = 1
	elif n + d1[d3[i]] - d2[d3[i]] in d:
		d[n + d1[d3[i]] - d2[d3[i]]] += 1
	else:
		d[n + d1[d3[i]] - d2[d3[i]]] = 1
print(max(list(d.values())))


n = int(input())
A1 = input()
B1 = input()
A = A1.split()
B = B1.split()
for i in range(n):
	A[i] = int(A[i]) - 1
	B[i] = int(B[i]) - 1
D = []
AA = [None] * n
BB = [None] * n
for i in range(n):
	AA[A[i]] = i
	BB[B[i]] = i
for i in range(n):
	D.append((AA[i] - BB[i]) % n)
D.sort()
DD = [0]
last = D[0]
for i in range(n):
	if last == D[i]:
		DD[-1] += 1
	else:
		last = D[i]
		DD.append(1)
print(max(DD))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = [0] * n
d2 = [0] * n
for i in range(n):
	d1[a[i] - 1] += i
for i in range(n):
	d1[b[i] - 1] -= i
for a in d1:
	d2[a] += 1
print(max(d2))


from collections import Counter

def tc():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a_rot = [0] * n
	b_rot = [0] * n
	for (i, v) in enumerate(a):
		a_rot[v - 1] = i
	for (i, v) in enumerate(b):
		b_rot[v - 1] = i
	diffs = []
	for i in range(n):
		diff = a_rot[i] - b_rot[i]
		if diff < 0:
			diff += n
		diffs.append(diff)
	c = Counter(diffs)
	return max(c.values())
T = 1
for _ in range(T):
	ans = tc()
	print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
a.insert(0, 0)
b.insert(0, 0)
for i in range(1, n + 1):
	d[a[i]] = i
d1 = {}
for i in range(1, n + 1):
	x = d[b[i]] - i
	if x < 0:
		x += n
	if x not in d1:
		d1[x] = 1
	else:
		d1[x] += 1
ma = 0
for i in d1:
	if ma < d1[i]:
		ma = d1[i]
print(ma)


n = int(input())
ar = list(map(int, input().split()))
br = list(map(int, input().split()))
li = [0] * (n + 1)
for i in range(n):
	li[ar[i]] = i
ans = [0] * (n + 1)
for i in range(n):
	ind = li[br[i]]
	if ind > i:
		ans[br[i]] = ind - i
	elif ind < i:
		ans[br[i]] = n - i + ind
	else:
		ans[br[i]] = 0
dic = {}
for i in range(1, n + 1):
	if ans[i] in dic:
		dic[ans[i]] += 1
	else:
		dic[ans[i]] = 1
print(max(list(dic.values())))


a = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
d = {}
d1 = {}
for i in range(0, a):
	d[l1[i]] = i
for i in range(0, a):
	d1[l2[i]] = i
l = {}
for i in d.keys():
	m = (d[i] - d1[i]) % a
	if m in l.keys():
		l[m] += 1
	else:
		l[m] = 1
print(max(l.values()))


import statistics, sys
input = sys.stdin.readline
(n, a, b) = (int(input()), [int(i) for i in input().split()], [int(i) for i in input().split()])
pos_a = [0 for _ in range(n + 1)]
for i in range(n):
	pos_a[a[i]] = i
diffs = [(i - pos_a[b[i]]) % n for i in range(n)]
print(diffs.count(statistics.mode(diffs)))


def parseint():
	ln = input().split()
	for i in range(len(ln)):
		ln[i] = int(ln[i])
	return ln

def solve(n, a, b):
	a_map = {}
	b_map = {}
	for i in range(n):
		a_map[a[i]] = i
		b_map[b[i]] = i
	dists = {}
	for i in range(1, n + 1):
		dist = b_map[i] - a_map[i]
		if dist < 0:
			dist += n
		if dist not in dists:
			dists[dist] = 1
		else:
			dists[dist] += 1
	print(max(dists.values()))
n = int(input())
a = parseint()
b = parseint()
solve(n, a, b)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos2 = [0] * (n + 1)
for i in range(n):
	pos2[b[i]] = i
d = [0] * (n + 1)
for i in range(0, n):
	if i >= pos2[a[i]]:
		d[i - pos2[a[i]]] += 1
	else:
		d[n + i - pos2[a[i]]] += 1
print(max(d))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
id = [dict(), dict()]
for i in range(n):
	id[0][a[i]] = i
	id[1][b[i]] = i
ans = dict()
for i in range(1, n + 1):
	d = (n + id[0][i] - id[1][i]) % n
	if d not in ans.keys():
		ans[d] = 1
	else:
		ans[d] += 1
print(max(ans.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = [0] * n
out = [0] * n
for i in range(n):
	diff[a[i] - 1] += i
for i in range(n):
	diff[b[i] - 1] -= i
for v in diff:
	out[v] += 1
print(max(out))


import math
from decimal import *
getcontext().prec = 30
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
freq = [0] * (n + 1)
ans = -1
l = [0] * n
for i in range(n):
	freq[a[i]] = i
for i in range(n):
	l[i] = (i + n - freq[b[i]]) % n
last = [0] * n
for i in range(n):
	last[l[i]] += 1
print(max(last))


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from collections import Counter
n = itg()
a = tuple(mpint())
b = tuple(mpint())
a = [k - 1 for k in a]
b = [k - 1 for k in b]
d = [-1] * n
for i in range(n):
	d[b[i]] = i
c = [d[k] for k in a]
for i in range(n):
	c[i] = (c[i] - i) % n
print(Counter(c).most_common()[0][1])


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
indices = [0] * n
for (i, x) in enumerate(b):
	indices[x - 1] = i
offsets = [0] * n
for i in range(n):
	offsets[(indices[a[i] - 1] - i) % n] += 1
print(max(offsets))


import sys
from collections import defaultdict as dd
from queue import Queue
import math
import itertools
n = int(input())
q = list(map(int, input().split()))
w = list(map(int, input().split()))
e = [0] * (n + 1)
for i in range(n):
	e[q[i]] = i
t = [0] * n
for i in range(n):
	t[(i - e[w[i]]) % n] += 1
print(max(t))


from collections import defaultdict, Counter
import sys
if 1:
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	if a == b:
		print(n)
	else:
		d1 = defaultdict(lambda : 0)
		d2 = defaultdict(lambda : 0)
		ans = []
		c = 0
		for i in range(n):
			if a[i] == b[i]:
				c += 1
		ans.append(c)
		c = 0
		for i in range(n):
			d1[a[i]] = i
			d2[b[i]] = i
		a.sort()
		d3 = defaultdict(lambda : 0)
		for i in range(n):
			if d1[a[i]] - d2[a[i]] >= 0:
				d3[abs(d1[a[i]] - d2[a[i]])] += 1
			else:
				x = n + d1[a[i]] - d2[a[i]]
				d3[x] += 1
		ans.append(max(d3.values()))
		print(max(ans))


n = int(input())
a_i = [int(a) for a in input().split()]
b_i = [int(b) for b in input().split()]
list = [0 for num in range(n + 1)]
for index in range(n):
	list[a_i[index]] = index
for index in range(n):
	list[b_i[index]] -= index
	if list[b_i[index]] < 0:
		list[b_i[index]] += n
list.sort()
maximum = 0
count = 0
K_check = 0
for index in range(1, n + 1):
	if index == 1:
		K_check = list[index]
		count = 1
	elif list[index] == K_check:
		count += 1
	else:
		maximum = max(maximum, count)
		count = 1
		K_check = list[index]
maximum = max(maximum, count)
print(maximum)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * (n + 1)
for i in range(n):
	d[a[i]] = i
for i in range(n):
	j = d[b[i]]
	c[(j - i) % n] += 1
print(max(c))


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d = {}
	ib = {}
	for i in range(n):
		ib[b[i]] = i
	for i in range(n):
		shift = (i - ib[a[i]] + n) % n
		d[shift] = d.get(shift, 0) + 1
	print(max((v for (k, v) in d.items())))


def result(n, a, b):
	vec = [0 for _ in range(n)]
	l = [0 for _ in range(n)]
	for (i, el) in enumerate(a):
		vec[el - 1] = i
	for (i, el) in enumerate(b):
		l[(vec[el - 1] - i) % n] += 1
	return max(l)
n = int(input())
a = list(map(lambda x: int(x), input().split(' ')))
b = list(map(lambda x: int(x), input().split(' ')))
print(result(n, a, b))


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import sys
input = sys.stdin.readline
import bisect
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().strip().split()))
rls = lambda : list(map(str, input().split()))
n = int(input().strip())
a = list(map(int, input().strip().split()))
b = rl()
ans = []
d1 = dict()
d2 = dict()
for i in range(0, n):
	d1[a[i]] = i
	d2[b[i]] = i
for i in range(1, n + 1):
	e = d1[i] - d2[i]
	if d1[i] - d2[i] < 0:
		e = n - 1 - d2[i] + 1 + d1[i]
	ans.append(e)
c = Counter(ans)
res = 0
mx = 0
for (i, j) in c.items():
	if j > mx:
		mx = j
print(mx)


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a_indices = {}
	b_indices = {}
	for i in range(n):
		a_indices[a[i]] = i
		b_indices[b[i]] = i
	c = 0
	diff_count = {}
	for i in range(1, n + 1):
		dis = a_indices[i] - b_indices[i]
		if dis < 0:
			dis += n
		try:
			diff_count[dis] += 1
		except KeyError:
			diff_count[dis] = 1
	ls = list(diff_count.values())
	print(max(ls))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
from collections import defaultdict as dd
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
n = int(input())
q = list(map(int, input().split()))
w = list(map(int, input().split()))
e = [0] * (n + 1)
for i in range(n):
	e[q[i]] = i
t = [0] * n
for i in range(n):
	t[(i - e[w[i]]) % n] += 1
print(max(t))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [-1] * n
for i in range(n):
	pos[a[i] - 1] = i
dic = {}
for i in range(n):
	cur = pos[b[i] - 1] - i
	if cur < 0:
		cur += n
	if cur in dic:
		dic[cur] += 1
	else:
		dic[cur] = 1
print(max(dic.values()))


from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
a_pos = [0] * n
b_pos = [0] * n
for i in range(n):
	a_pos[a[i] - 1] = i
	b_pos[b[i] - 1] = i
num_shifts = [(a_pos[i] - b_pos[i]) % n for i in range(n)]
shift_counter = Counter(num_shifts)
print(shift_counter.most_common(1)[0][1])


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
n = INT()
arr1 = LIST()
arr2 = LIST()
m = 0
i = 0
d = {}
d1 = {}
for i in range(n):
	d1[arr2[i]] = i
for i in range(n):
	x = d1[arr1[i]]
	shift = (i - x) % n
	if shift in d:
		d[shift] += 1
	else:
		d[shift] = 1
ans = max(d.values())
print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[a[i]] = [i]
for j in range(n):
	d[b[j]].append(j)
right = [0] * n
left = [0] * n
for i in d:
	left_ = d[i][1] - d[i][0]
	right_ = d[i][0] - d[i][1]
	if left_ < 0:
		left_ += n
	if right_ < 0:
		right_ += n
	right[right_] += 1
	left[left_] += 1
print(max(max(left), max(right)))


n = int(input())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
ma = {}
mb = {}
for i in range(len(a)):
	ma[a[i]] = i
	mb[b[i]] = i
m = {}
for i in a:
	m[i] = ma[i] - mb[i]
	if m[i] < 0:
		m[i] += n
freq = {}
for i in m:
	freq[m[i]] = freq.get(m[i], 0) + 1
ans = 0
for i in freq:
	ans = max(ans, freq[i])
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
rotations = [0] * n
answers = [0] * n
for i in range(len(a)):
	rotations[a[i] - 1] += i
	rotations[b[i] - 1] -= i
for i in range(len(a)):
	rotations[i] = (rotations[i] + n) % n
	answers[rotations[i] - 1] += 1
print(max(answers))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
	if a[i] == b[i]:
		ans += 1
arrR = [0] * (n + 1)
arrL = [0] * (n + 1)
aind = [0] * (n + 1)
bind = [0] * (n + 1)
for i in range(n):
	aind[a[i]] = i + 1
	bind[b[i]] = i + 1
for i in range(1, n + 1):
	if bind[i] > aind[i]:
		arrR[bind[i] - aind[i]] += 1
		arrL[n - (bind[i] - aind[i])] += 1
	else:
		arrL[aind[i] - bind[i]] += 1
		arrR[n - (aind[i] - bind[i])] += 1
ans1 = max(arrR)
ans2 = max(arrL)
print(max(ans, ans1, ans2))


import collections

def read():
	return input().strip()

def readInt():
	return int(input().strip())

def readList():
	return list(map(int, input().strip().split()))

def solve(n, a, b):
	(aPos, bPos) = ({}, {})
	leftMatch = [0 for _ in range(n)]
	rightMatch = [0 for _ in range(n)]
	for i in range(n):
		(aVal, bVal) = (a[i], b[i])
		aPos[aVal] = i
		bPos[bVal] = i
	for val in range(1, n + 1):
		(aPosition, bPosition) = (aPos[val], bPos[val])
		shift = aPosition - bPosition
		absShift = abs(shift)
		if shift < 0:
			(leftShift, rightShift) = (absShift, n - absShift)
		else:
			(leftShift, rightShift) = (n - absShift, absShift)
		if aPosition == bPosition:
			leftMatch[0] += 1
			rightMatch[0] += 1
		else:
			leftMatch[leftShift] += 1
			rightMatch[rightShift] += 1
	return max(max(leftMatch), max(rightMatch))
n = readInt()
a = readList()
b = readList()
print(solve(n, a, b))


n = int(input())
a = [int(v) for v in input().split()]
b = [int(v) for v in input().split()]
d = dict()
res = []
for j in range(n):
	d[b[j]] = j
for j in range(n):
	if d[a[j]] < j:
		res.append(d[a[j]] + n - j)
	else:
		res.append(d[a[j]] - j)
m = 1
d = {}
for j in range(n):
	if res[j] in d:
		d[res[j]] = d[res[j]] + 1
		m = max(m, d[res[j]])
	else:
		d[res[j]] = 1
print(m)


n = int(input())
a = input().split()
ai = [int(i) for i in a]
b = input().split()
bi = [int(i) for i in b]
arr = [[] for i in range(n)]
for i in range(n):
	arr[ai[i] - 1].append(i)
for i in range(n):
	arr[bi[i] - 1].append(i)
fina = [0 for i in range(n)]
for i in arr:
	x = i[0]
	y = i[1]
	if y >= x:
		fina[y - x] += 1
	else:
		fina[n + y - x] += 1
print(max(fina))


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * n
for i in range(0, n):
	c[a[i] - 1] = i
	d[b[i] - 1] = i
e = defaultdict(list)
for (i, j) in zip(c, d):
	x = i - j
	if x < 0:
		x += n
	try:
		e[x] += 1
	except:
		e[x] = 1
m = 1
for i in e.keys():
	m = max(m, e[i])
print(m)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = dict()
bb = dict()
for i in range(n):
	aa[a[i]] = i + 1
	bb[b[i]] = i + 1
c = []
d = []
for i in range(1, n + 1):
	x = bb[i] - aa[i]
	if x < 0:
		c.append(x + n)
	else:
		c.append(x)
	y = aa[i] - bb[i]
	if y < 0:
		d.append(y + n)
	else:
		d.append(y)
c = Counter(c)
d = Counter(d)
print(max(max(c.values()), max(d.values())))


N = int(input())
host = list(map(int, input().split()))
target = list(map(int, input().split()))
host_arr = [0] * (N + 1)
for h in range(N):
	idx = host[h]
	host_arr[idx] = h
answer_arr = [0] * (N + 1)
for t in range(N):
	idx = target[t]
	value = t - host_arr[idx]
	result = value + N if value < 0 else value
	answer_arr[result] += 1
print(max(answer_arr))


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = [int(x) - 1 for x in input().split()]
	b = [int(x) - 1 for x in input().split()]
	look = [0] * n
	for i in range(n):
		look[b[i]] = i
	d = []
	for i in range(n):
		el = a[i]
		d.append((i - look[el]) % n)
	c = Counter(d)
	ans = max(c.values())
	print(ans)
tt = 1
for test in range(tt):
	solve()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
swaps = {}
offsets = {}
for i in range(n):
	swaps[a[i]] = i
for i in range(n):
	offset = swaps[b[i]] - i
	if offset < 0:
		offset += n
	if offsets.get(offset, -1) == -1:
		offsets[offset] = 1
	else:
		offsets[offset] += 1
m_off = -1
for k in offsets:
	m_off = max(m_off, offsets[k])
print(m_off)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [[0, 0]] * (n + 1)
for i in range(n):
	pos[a[i]] = [i, i + n]
diff = [0] * n
for i in range(n):
	if pos[b[i]][0] - i < n and pos[b[i]][0] - i >= 0:
		diff[pos[b[i]][0] - i] += 1
	if pos[b[i]][1] - i < n and pos[b[i]][1] - i >= 0:
		diff[pos[b[i]][1] - i] += 1
print(max(diff))


def find_diff(N, i, j):
	if i < j:
		res = j - i
	else:
		res = j + N - i
	return res
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Ai = {ai: i for (i, ai) in enumerate(A)}
Bi = {bi: i for (i, bi) in enumerate(B)}
maxi = [0] * (N + 1)
for i in range(1, N + 1):
	a_ind = Ai[i]
	b_ind = Bi[i]
	r = find_diff(N, a_ind, b_ind)
	maxi[r] += 1
print(max(maxi))


x = int(input())
data = list(map(int, input().split()))
data2 = list(map(int, input().split()))
d = {}
dataPos = [0] * x
data2Pos = [0] * x
for i in range(x):
	dataPos[data[i] - 1] = data2Pos[data2[i] - 1] = i + 1
for i in range(x):
	z = 0
	if dataPos[i] > data2Pos[i]:
		z = dataPos[i] - data2Pos[i]
	else:
		z = x - data2Pos[i] + dataPos[i]
	if z not in d:
		d[z] = 1
	else:
		d[z] += 1
print(max(d.values()))


n = int(input())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
di = [0] * n
for i in range(n):
	di[ai[i] - 1] = i
ci = [(di[bi[i] - 1] - i) % n for i in range(n)]
ci.sort()
num = 1
ans = 1
for i in range(1, n):
	num *= ci[i] == ci[i - 1]
	num += 1
	ans = max(ans, num)
print(ans)


from sys import stdin
a = int(stdin.readline())
z = [0] * (a + 1)
z1 = [0] * (a + 1)
for (k, i) in enumerate(zip(map(int, stdin.readline().split()), map(int, stdin.readline().split()))):
	z[i[0]] = k
	z1[i[1]] = k
d = {}
for i in range(1, a + 1):
	if z1[i] >= z[i]:
		f = z1[i] - z[i]
		d[f] = d.get(f, 0) + 1
	else:
		f = a - z[i] + z1[i]
		d[f] = d.get(f, 0) + 1
print(max(d.values()))


from collections import defaultdict as dd
n = int(input())
l = list(map(int, input().split()))
ll = list(map(int, input().split()))
ls = dd(int)
rs = dd(int)
ind = dd(int)
for i in range(n):
	ind[l[i]] = i
for i in range(n):
	a = ll[i]
	indx = ind[a]
	if i > indx:
		ls[i - indx] += 1
		rs[n - i + indx] += 1
	elif i < indx:
		rs[indx - i] += 1
		ls[n - indx + i] += 1
	else:
		rs[0] += 1
		ls[0] += 1
mx = -1
for i in ls:
	mx = max(ls[i], mx)
for i in rs:
	mx = max(rs[i], mx)
print(mx)


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
count = [0] * n
right = [0] * n
for i in range(n):
	right[l1[i] - 1] += i
	right[l2[i] - 1] -= i
for i in range(n):
	count[right[i] % n] += 1
print(max(count))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
loc = [-1] * (n + 1)
for i in range(n):
	loc[a[i]] = i
d = dict()
for i in range(n):
	sh = loc[b[i]] - i
	if sh < 0:
		sh += n
	if sh in d:
		d[sh] += 1
	else:
		d[sh] = 1
print(max(d.values()))


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
pos = {}
for i in range(n):
	pos[a[i]] = i + 1
freq = {}
for i in range(n):
	x = i + 1
	y = pos[b[i]]
	dist = (y - x + n) % n
	if dist not in freq:
		freq[dist] = 1
	else:
		freq[dist] += 1
(max_k, max_v) = (-1, -1)
for (k, v) in freq.items():
	if v > max_v:
		max_v = v
		max_k = k
print(max_v)


def rotation(n, a, b):
	dic = {}
	for i in range(n):
		if a[i] in dic:
			dic[a[i]] = dic[a[i]] - i
			if dic[a[i]] < 0:
				dic[a[i]] += n
		else:
			dic[a[i]] = -i
		if b[i] in dic:
			dic[b[i]] = dic[b[i]] + i
			if dic[b[i]] < 0:
				dic[b[i]] += n
		else:
			dic[b[i]] = i
	answerdic = {}
	for x in dic:
		x = dic[x]
		if x in answerdic:
			answerdic[x] += 1
		else:
			answerdic[x] = 1
	ans = 1
	for y in answerdic:
		if answerdic[y] > ans:
			ans = answerdic[y]
	return ans
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
print(rotation(n, a, b))


n = int(input())
arr1 = [int(x) for x in input().split()]
arr2 = [int(x) for x in input().split()]
pos = [0] * (n + 1)
data = [0] * (n + 1)
for i in range(1, n + 1):
	pos[arr1[i - 1]] = i
for i in range(1, n + 1):
	curr = pos[arr2[i - 1]] - i
	if curr < 0:
		curr += n
	data[curr] += 1
print(max(data))


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
for _ in range(num):
	n = int(z())
	lst1 = zzz()
	lst2 = zzz()
	pos = [0] * n
	for i in range(n):
		pos[lst1[i] - 1] += i
		pos[lst2[i] - 1] -= i
	out = [0] * n
	for i in pos:
		out[i] += 1
	print(max(out))


from collections import Counter
import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)

def main():
	n = next(ints)
	A = [0] * n
	for i in range(n):
		A[next(ints) - 1] = i
	b = [next(ints) for i in range(n)]
	ans = max(Counter(((i - A[b[i] - 1]) % n for i in range(n))).values())
	print(ans)
	return
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0 for i in range(n + 1)]
count = [0 for i in range(n)]
maxx = 0
for i in range(n):
	c[a[i]] = i
for i in range(n):
	pos = c[b[i]]
	if i >= pos:
		k = i - pos
	else:
		k = n + i - pos
	count[k] += 1
	maxx = max(maxx, count[k])
print(maxx)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ia = [0 for i in range(n + 1)]
ib = [0 for i in range(n + 1)]
for i in range(n):
	ia[a[i]] = i
for i in range(n):
	ib[b[i]] = i
for i in range(n + 1):
	ia[i] = (ia[i] - ib[i]) % n
ans = [0 for i in range(n)]
for i in range(1, n + 1):
	ans[ia[i]] += 1
print(max(ans))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
posA = {A[x]: x + 1 for x in range(n)}
posB = {B[x]: x + 1 for x in range(n)}
occ = {}
for x in range(1, n + 1):
	gap = posA[x] - posB[x]
	if gap < 0:
		gap += n
	if gap in occ:
		occ[gap] += 1
	else:
		occ[gap] = 1
ans = 0
for k in occ:
	ans = max(ans, occ[k])
print(ans)


from sys import stdin
import copy
input = stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = dict()
dd = dict()
for x in range(n):
	dd[a[x]] = x
for x in range(n):
	t = x - dd[b[x]]
	if t < 0:
		t += n
	if t in d.keys():
		d[t] += 1
	else:
		d[t] = 1
print(max(d.values()))


n = int(input())
a = [int(x) - 1 for x in input().split()]
b = [int(x) - 1 for x in input().split()]
aindex = [0] * n
bindex = [0] * n
for i in range(n):
	aindex[a[i]] = i
	bindex[b[i]] = i
ans = [0] * n
for i in range(n):
	x = aindex[i] - bindex[i]
	if x < 0:
		x = n + x
	ans[x] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
loc = [[-1, -1] for _ in range(n)]
for i in range(n):
	loc[a[i] - 1][0] = i
	loc[b[i] - 1][1] = i
(lefta, righta) = ([0] * n, [0] * n)
(leftb, rightb) = ([0] * n, [0] * n)
for i in loc:
	if i[0] == i[1]:
		lefta[0] += 1
		righta[0] += 1
		leftb[0] += 1
		rightb[0] += 1
	elif i[0] < i[1]:
		righta[i[1] - i[0]] += 1
		lefta[n - i[1] + i[0]] += 1
		rightb[n - i[1] + i[0]] += 1
		leftb[i[1] - i[0]] += 1
	else:
		righta[n - i[0] + i[1]] += 1
		lefta[i[0] - i[1]] += 1
		rightb[i[0] - i[1]] += 1
		leftb[i[1] + n - i[0]] += 1
for i in [lefta, leftb, righta, rightb]:
	ans = max(ans, max(i))
print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = lis()
	b = lis()
	pos = [0] * (n + 1)
	for i in range(0, n):
		pos[a[i]] = i + 1
	d = {}
	for i in range(0, n):
		if pos[b[i]] >= i + 1:
			temp = pos[b[i]] - (i + 1)
		else:
			temp = n - (i + 1) + pos[b[i]]
		if d.get(temp) == None:
			d[temp] = 1
		else:
			d[temp] += 1
	ans = 0
	for i in d:
		ans = max(ans, d[i])
	print(ans)
testcase(1)


from collections import defaultdict

def solve(lst1, lst2):
	loc = {}
	for (i, num) in enumerate(lst1):
		loc[num] = i
	diff = defaultdict(int)
	for (i, num) in enumerate(lst2):
		j = loc[num]
		if j - i >= 0:
			diff[j - i] += 1
		else:
			diff[j - i + n] += 1
	res = 0
	for x in diff:
		res = max(res, diff[x])
	return res
n = int(input())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
print(solve(lst1, lst2))


from collections import defaultdict
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
dp = [0] * n
Dict = defaultdict(int)
for i in range(n):
	Dict[a[i]] = i
for i in range(n):
	x = b[i]
	ind = Dict[x]
	dp[i] = ind - i
	if dp[i] < 0:
		dp[i] += n
count = Counter(dp)
x1 = list(count.values())
print(max(x1))


inp = input
n = int(inp())
arr = list(map(int, inp().strip().split(' ')))
brr = list(map(int, inp().strip().split(' ')))
ops = {}
nps = {}
for i in range(n):
	ops[arr[i]] = i + 1
	nps[brr[i]] = i + 1
lefd = []
ritd = []
for i in range(1, n + 1):
	(p1, p2) = (ops[i], nps[i])
	(lef, rit) = (0, 0)
	if p1 > p2:
		lef = p1 - p2
		rit = n - p1 + p2
	else:
		lef = n - p2 + p1
		rit = p2 - p1
	lefd.append(lef)
	ritd.append(rit)
lefd.sort()
ritd.sort()
mx = 0
ln = len(lefd)
rn = len(ritd)
i = 0
prev = -1
arr = lefd
while i < ln:
	prev = arr[i]
	i += 1
	cnt = 1
	while i < ln and arr[i] == prev:
		cnt += 1
		i += 1
	if cnt > mx:
		mx = cnt
i = 0
prev = -1
arr = ritd
while i < rn:
	prev = arr[i]
	i += 1
	cnt = 1
	while i < rn and arr[i] == prev:
		cnt += 1
		i += 1
	if cnt > mx:
		mx = cnt
print(mx)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d[i] = [0, 0, 0]
for i in range(n):
	d[a[i]][0] = i
	d[b[i]][1] = i
for i in range(1, n + 1):
	x = d[i][0] - d[i][1]
	if x > 0:
		d[i][2] = x
	else:
		d[i][2] = n + x
d2 = {}
for i in range(1, n + 1):
	if d[i][2] not in d2:
		d2[d[i][2]] = 1
	else:
		d2[d[i][2]] += 1
m = 0
for i in d2.keys():
	if d2[i] > m:
		m = d2[i]
print(m)


import sys
from math import log2, floor, ceil, sqrt
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
n = int(ri())
a = Ri()
b = Ri()
dic1 = {}
dic2 = {}
for i in range(len(a)):
	dic1[a[i]] = i
for i in range(len(b)):
	dic2[b[i]] = i
dic = {}
for i in range(1, n + 1):
	if (dic2[i] - dic1[i]) % n in dic:
		dic[(dic2[i] - dic1[i]) % n] += 1
	else:
		dic[(dic2[i] - dic1[i]) % n] = 1
maxx = max([dic[i] for i in dic])
print(maxx)


def main():
	n = int(input())
	values1 = list(map(int, input().split()))
	values2 = list(map(int, input().split()))
	dict_1 = [0 for i in range(n)]
	for i in range(n):
		dict_1[values1[i] - 1] = i
	shift = [0 for i in range(n)]
	for i in range(n):
		shift[i] = (n + dict_1[values2[i] - 1] - i) % n
	answer = [0 for i in range(n)]
	for i in range(n):
		answer[shift[i]] += 1
	ans = 0
	for i in answer:
		ans = max(i, ans)
	print(ans)
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
p = {}
for i in range(n):
	d[a[i]] = i
for i in range(n):
	x = (d[b[i]] - i + n) % n
	if x not in p:
		p[x] = 1
	else:
		p[x] += 1
print(max(list(p.values())))


import sys
input = sys.stdin.buffer.readline
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
_a = [0 for i in range(n + 1)]
_b = [0 for i in range(n + 1)]
for i in range(n):
	_a[a[i]] = i
	_b[b[i]] = i
ans = [0 for i in range(n + 1)]
for i in range(1, n + 1):
	diff = _a[i] - _b[i]
	if diff < 0:
		diff = n + diff
	ans[diff] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
pos = [0] * (1000000 + 5)
for i in range(len(b)):
	pos[b[i]] = i
dicti = dict({})
x = [0] * (1000000 + 5)
for i in range(n):
	c = pos[a[i]] - i
	if c < 0:
		c += n
	x[c] += 1
print(max(x))


n = int(input())
mas1 = list(map(str, input().split()))
mas2 = list(map(str, input().split()))
s = {}
for i in range(n):
	s[mas1[i]] = i
ans = {}
for i in range(n):
	x = s[mas2[i]]
	if i <= x:
		ans[x - i] = ans.get(x - i, 0) + 1
	else:
		ans[n - i + x] = ans.get(n - i + x, 0) + 1
maxi = 0
for i in ans.items():
	maxi = max(maxi, i[1])
print(maxi)


n = int(input())
M = [0 for i in range(n)]
a = input().split()
b = input().split()
for i in range(n):
	M[int(a[i]) - 1] = i
for i in range(n):
	t = i - M[int(b[i]) - 1]
	if t < 0:
		M[int(b[i]) - 1] = n + t
	else:
		M[int(b[i]) - 1] = t
R = [0 for i in range(n)]
for i in range(n):
	R[M[i]] += 1
print(max(R))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
counter = [0] * n
dec = [0] * n
for w in range(n):
	dec[a[w] - 1] += w
	dec[b[w] - 1] -= w
for i in range(n):
	counter[dec[i] % n] += 1
print(max(counter))


n = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
(dica, dicb) = ({}, {})
for i in range(n):
	dica[A[i]] = i
	dicb[B[i]] = i
re = {}
for i in range(1, n + 1):
	if dica[i] >= dicb[i]:
		temp = dica[i] - dicb[i]
	else:
		temp = n - dicb[i] + dica[i]
	if temp not in re:
		re[temp] = 1
	else:
		re[temp] += 1
ans = list(re.values())
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = [0] * n
for i in range(n):
	s[a[i] - 1] = i
d = dict()
for i in range(n):
	t = s[b[i] - 1] - i
	if t < 0:
		t += n
	if t in d:
		d[t] += 1
	else:
		d[t] = 1
print(max(d.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
hash_map = {}
for (i, j) in enumerate(a):
	hash_map[j] = i
count_array = [0] * n
for (i, j) in enumerate(b):
	diff = hash_map[j] - i
	if diff < 0:
		diff += n
	count_array[diff] += 1
print(max(count_array))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = {}
for i in range(n):
	d[a[i]] = i
ans = [0] * n
for i in range(n):
	j = d[b[i]]
	ans[(j - i) % n] += 1
print(max(ans))


from sys import stdin, stdout
import heapq as hq
from collections import defaultdict
t = 1
for tc in range(t):
	n = int(stdin.readline())
	ar = list(map(int, stdin.readline().split()))
	ar2 = list(map(int, stdin.readline().split()))
	g = [-1 for _ in range(n)]
	for (i, val) in enumerate(ar):
		g[val - 1] = i
	count = defaultdict(int)
	for (i, val) in enumerate(ar2):
		count[(i - g[val - 1]) % n] += 1
	res = 0
	for key in count:
		res = max(res, count[key])
	stdout.write(str(res) + '\n')


n = int(input())
a = list(map(int, input().split()))
i = 0
ind = {}
for el in input().split():
	ind[int(el)] = i
	i += 1
count = [0 for _ in range(n)]
for i in range(n):
	j = ind[a[i]]
	if j >= i:
		count[j - i] += 1
	else:
		count[n - i + j] += 1
print(max(count))


def answer(n, a, b):
	da = {a[i]: i for i in range(n)}
	db = {b[i]: i for i in range(n)}
	cnt = [0] * n
	for k in da:
		d = da[k] - db[k]
		if d < 0:
			d += n
		cnt[d] += 1
	return max(cnt)

def main():
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	print(answer(n, a, b))
	return
main()


from collections import defaultdict as dd
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = dict()
x = dict()
for i in range(n):
	m[a[i]] = i
for i in range(n):
	x[b[i]] = i
c = dd(lambda : 0)
for i in range(1, n + 1):
	c[(m[i] - x[i] + n) % n] += 1
print(max(c.values()))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = {}
for (i, x) in enumerate(a):
	pos[x] = i
shift = {}
for (i, x) in enumerate(b):
	shift[x] = (i - pos[x] + n) % n
print(Counter(shift.values()).most_common(1)[0][1])


import sys
import math
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
pa = []
pb = []
ans = []
for i in range(n):
	pa.append(-1)
	pb.append(-1)
	ans.append(0)
for i in range(n):
	pa[a[i] - 1] = i
	pb[b[i] - 1] = i
for i in range(n):
	ans[(pa[i] - pb[i]) % n] += 1
k = 0
for i in range(n):
	if ans[i] > k:
		k = ans[i]
print(k)


import sys
input = sys.stdin.readline
n = int(input())
a = map(int, input().split())
b = map(int, input().split())
c = [[-1, -1] for _ in range(n)]
for (i, (ai, bi)) in enumerate(zip(a, b)):
	c[ai - 1][0] = i
	c[bi - 1][1] = i
s = dict()
for (i, ci) in enumerate(c):
	if c[i][0] != -1 and c[i][1] != -1:
		j = (c[i][0] - c[i][1] + n) % n
		try:
			s[j] += 1
		except:
			s[j] = 1
print(max(s.values()))


from collections import Counter

def read_ints():
	return [int(i) for i in input().strip().split()]

def main():
	n = int(input())
	a = read_ints()
	b = read_ints()
	d = dict()
	for (idx, i) in enumerate(a):
		d[i] = idx
	diff = []
	for (idx, i) in enumerate(b):
		idx1 = d[i]
		delta = (idx1 - idx) % n
		diff.append(delta)
	data = Counter(diff)
	print(data.most_common(1)[0][1])
main()


from sys import stdin
from collections import Counter
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
disr = Counter()
disl = Counter()
pos = {}
for x in range(n):
	pos[a[x]] = x
for j in range(n):
	r = pos[b[j]]
	disl[(r - j) % n] += 1
	disr[(j - r) % n] += 1
print(max(disr[max(disr, key=disr.get)], disl[max(disl, key=disl.get)]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = {}
for i in range(n):
	pos[a[i]] = i
dic = {}
for i in range(n):
	cur = pos[b[i]] - i
	if cur < 0:
		cur += n
	if cur in dic:
		dic[cur] += 1
	else:
		dic[cur] = 1
res = 0
for (key, value) in dic.items():
	res = max(res, value)
print(res)


def solve(a, b, n):
	map_k = [0 for i in range(n + 1)]
	offset_map = [0 for i in range(n + 1)]
	for i in range(n):
		map_k[a[i]] = i
	for j in range(n):
		ndx = map_k[b[j]]
		offset = ndx - j
		if offset < 0:
			offset += n
		offset_map[offset] += 1
	max_so_far = 0
	for i in range(0, n + 1):
		max_so_far = max(max_so_far, offset_map[i])
	return max_so_far

def read():
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	ans = solve(a, b, n)
	print(ans)
read()


for lo in range(1):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ls = [0 for i in range(n + 1)]
	d = {}
	for i in range(n):
		ls[b[i]] = i
	mx = 0
	for i in range(n):
		x = a[i]
		y = ls[x]
		z = (y - i + n) % n
		if z in d:
			d[z] += 1
		else:
			d[z] = 1
		mx = max(d[z], mx)
	print(mx)


n = int(input())
d1 = {}
d2 = {}
l1 = list(map(int, input().split()))
for i in range(n):
	d1[l1[i]] = i
l2 = list(map(int, input().split()))
for i in range(n):
	d2[l2[i]] = i
m = 0
res = [0] * (n + 1)
for i in range(1, n + 1):
	m = (d2[i] - d1[i] + n) % n
	res[m] += 1
ans = -1
for i in range(n):
	ans = max(ans, res[i])
print(ans)


import sys
from collections import Counter

def swap(x, y, a):
	temp = a[x]
	a[x] = a[y]
	a[y] = temp
	return a

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		q[i] = q[i].rstrip().split(' ')
		q[i] = [int(x) for x in q[i]]
	a = q[1]
	b = q[2]
	indices = {}
	d = []
	for i in range(len(b)):
		indices[b[i]] = i
	for i in range(len(a)):
		if i - indices[a[i]] < 0:
			d.append(len(a) + i - indices[a[i]])
		else:
			d.append(i - indices[a[i]])
	(mc, nmc) = Counter(d).most_common(1)[0]
	print(nmc)
main()


t = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
g = {}
g2 = {}
for x in range(t):
	if g.get(a[x], None) != None:
		g2[x - g[a[x]]] = g2.get(x - g[a[x]], 0) + 1
	else:
		g[a[x]] = x
	if g.get(b[x], None) != None:
		g2[t - x + g[b[x]]] = g2.get(t - x + g[b[x]], 0) + 1
	else:
		g[b[x]] = x
print(max(g2.values()))


def inp():
	return map(int, input().split())

def solve():
	n = int(input())
	a = list(inp())
	b = list(inp())
	aa = [-1] + [0] * n
	bb = [-1] + [0] * n
	for i in range(n):
		aa[a[i]] = i + 1
		bb[b[i]] = i + 1
	d = dict()
	for i in range(1, n + 1):
		k = (n + aa[i] - bb[i]) % n
		if k not in d:
			d[k] = 0
		d[k] += 1
	kk = list(d.items())
	kk.sort(key=lambda xx: -xx[1])
	print(kk[0][1])

def main():
	t = 1
	while t:
		solve()
		t -= 1
main()


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = 1
while t:
	t -= 1
	n = int(fastinput())
	a = [0] * (n + 1)
	j = 1
	for i in fastinput().split():
		a[int(i)] = j
		j += 1
	d = {}
	j = 1
	ans = 0
	for i in fastinput().split():
		x = a[int(i)]
		if x == j:
			y = 0
		elif j < x:
			y = n - x + j
		else:
			y = j - x
		if y in d:
			d[y] += 1
		else:
			d[y] = 1
		j += 1
		ans = max(d[y], ans)
	print(ans)


import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d[a[i - 1]] = i
for i in range(1, n + 1):
	d[b[i - 1]] = d[b[i - 1]] - i
	if d[b[i - 1]] < 0:
		d[b[i - 1]] += n
l = list(d.values())
c = Counter(l).most_common()[0][1]
print(c)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
index = [[0, 0] for _ in range(n + 1)]
for i in range(1, n + 1):
	index[a[i - 1]][0] = i
	index[b[i - 1]][1] = i
hashmap = defaultdict(int)
for i in range(1, n + 1):
	(x, y) = index[i]
	dist = y - x
	if dist < 0:
		dist += n
	hashmap[dist] += 1
ans = 0
for (k, v) in hashmap.items():
	ans = max(ans, v)
print(ans)


n = int(input())
ls1 = input().split()
ls2 = input().split()
mymap = dict()
for i in range(n):
	mymap[ls1[i]] = i
answer = dict()
for i in range(n):
	mymap[ls2[i]] -= i
	x = mymap[ls2[i]] % n
	if x in answer:
		answer[x] = answer[x] + 1
	else:
		answer[x] = 1
fin = -1
for x in answer:
	fin = max(fin, answer[x])
print(fin)


import sys
read = sys.stdin.buffer.readline
mi = lambda : map(int, read().split())
cin = lambda : int(read())
li = lambda : list(mi())
for _ in range(1):
	n = cin()
	a = li()
	b = li()
	ia = [0] * (n + 1)
	d = {i: 0 for i in range(-n, n + 1, 1)}
	for i in range(n):
		ia[a[i]] = i
	ans = 0
	for i in range(n):
		i1 = ia[b[i]]
		d[i - i1] += 1
		if i1 == i:
			d[-n] += 1
			d[n] += 1
		elif i > i1:
			d[-(n - i + i1)] += 1
		else:
			d[n - i1 + i] += 1
	for i in range(-n, n + 1, 1):
		ans = max(ans, d[i])
	print(ans)


from sys import stdin, stdout
n = int(input())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
if n == 2:
	print(2)
else:
	aind = [0 for i in range(n)]
	bind = [0 for i in range(n)]
	for i in range(n):
		aind[a[i] - 1] = i
	for i in range(n):
		bind[b[i] - 1] = i
	cnt = [0 for i in range(n)]
	for i in range(n):
		cnt[i] = aind[i] - bind[i]
	d = {}
	maxi = -1
	for i in cnt:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
		if -(n - i) in d:
			d[i - n] += 1
		else:
			d[i - n] = 1
	for i in d:
		if d[i] > maxi:
			maxi = d[i]
	print(maxi)


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
check_a = [0] * (n + 10)
check_b = [0] * (n + 10)
correct = [0] * (n + 10)
for i in range(n):
	check_a[a[i]] = i + 1
for i in range(n):
	if check_a[b[i]] > i + 1:
		correct[b[i]] = check_a[b[i]] - i - 1
	else:
		correct[b[i]] = n - i - 1 + check_a[b[i]]
answer = 0
d = dict()
for i in range(n):
	if correct[b[i]] not in d.keys():
		d[correct[b[i]]] = 1
	else:
		d[correct[b[i]]] += 1
	answer = max(answer, d[correct[b[i]]])
print(answer)


testing_mode = True
import sys, traceback
test_data = ''
final_output = ''

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for x in range(multi)]
	else:
		next_line = next(test_data, None).strip() if test_data else sys.stdin.readline()
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = next_line.split()
		elif input_format == 4:
			formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
		elif input_format == 5:
			formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
		else:
			formatted_input = [next_line]
		return formatted_input

def log(*args):
	if testing_mode:
		print(*args)

def out(output_line, output_format=0, newline=True):
	global final_output
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 1:
		formatted_output = '\n'.join(map(str, output_line))
	if testing_mode:
		final_output += formatted_output + '\n' * newline
	else:
		print(formatted_output, end='\n' if newline else '')
test_inputs = ['\n5\n1 2 3 4 5\n2 3 4 5 1\n\n', '\n5\n5 4 3 2 1\n1 2 3 4 5\n\n', '\n4\n1 3 2 4\n4 2 3 1\n\n', '\n1\n1\n1\n']
test_outputs = ['\n5\n', '\n1\n', '\n2\n', '\n$$$\n']

def solve():
	n = input(1)[0]
	a = input(1)
	b = input(1)
	ap = [0] * (n + 1)
	bp = [0] * (n + 1)
	k = [0] * n
	for (i, j) in enumerate(a):
		ap[j] = i
	for (i, j) in enumerate(b):
		bp[j] = i
	for (i, j) in zip(ap[1:], bp[1:]):
		if i < j:
			k[n - j + i] += 1
		else:
			k[i - j] += 1
	log(k)
	out(max(k))
	return

def run_all(overwrite_testing=False):
	global testing_mode, final_output, test_data
	testing_mode = overwrite_testing and testing_mode
	if testing_mode:
		tests_failed = 0
		for (test_number, (test_in, test_out)) in enumerate(zip(test_inputs, test_outputs)):
			final_output = ''
			if test_in.lstrip()[:3] == '$$$':
				continue
			test_data = iter([i for i in test_in.split('\n') if i])
			print(f'Test Case #{test_number + 1}:')
			print('<' * 20)
			fail = False
			verdict = '\x1b[92m\x1b[1mPASS\x1b[0m'
			try:
				solve()
				final = final_output.rstrip('\n')
				raw_out = iter(map(str, final.split('\n'))) if final else iter(())
			except Exception:
				raw_out = ''
				fail = True
				print('\x1b[95m')
				traceback.print_exc()
				print('\x1b[0m')
			if raw_out:
				if test_out.lstrip()[:3] == '$$$':
					verdict = '\x1b[94m\x1b[1mSKIP\x1b[0m'
					print('\x1b[94m' + '\n'.join(list(raw_out)) + '\x1b[0m')
				else:
					for line_out in [i for i in test_out.split('\n') if i]:
						line_raw = next(raw_out, '% None %')
						if line_raw == line_out.strip():
							print(f'\x1b[92m{line_raw}\x1b[0m')
						else:
							print(f'\x1b[91m{line_raw}\x1b[0m')
							fail = True
					line_raw = next(raw_out, None)
					while line_raw:
						print(f'\x1b[91m{line_raw}\x1b[0m')
						line_raw = next(raw_out, None)
						fail = True
			print('>' * 20)
			if fail:
				verdict = '\x1b[91m\x1b[1mFAIL\x1b[0m'
				tests_failed += 1
			print(verdict + '\n')
		if tests_failed:
			print(f"\x1b[91m\x1b[1m{tests_failed} TEST{('S' if tests_failed > 1 else '')} FAILED!\x1b[0m")
		else:
			print(f'\x1b[92m\x1b[1mALL TESTS PASSED!\x1b[0m')
	else:
		test_data = False
		solve()
run_all(False)


import sys
input = sys.stdin.buffer.readline
n = int(input())
arr1 = [int(x) for x in input().split()]
arr2 = [int(x) for x in input().split()]
out = [0] * n
dif = [0] * n
for i in range(n):
	dif[arr1[i] - 1] += i
for i in range(n):
	dif[arr2[i] - 1] -= i
for v in dif:
	out[v] += 1
print(max(out))


n = int(input())
a = [x for x in input().split(' ')]
b = [x for x in input().split(' ')]
e = {}
f = {}
for i in range(n):
	e[a[i]] = i
for j in range(n):
	x = e[b[j]]
	x = (x - j) % n
	y = f.get(x, 0)
	f[x] = y + 1
ans = 1
for k in f.keys():
	ans = max(ans, f[k])
print(ans)


import sys
input = sys.stdin.readline
(N,) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
Z = [0] * N
d2 = dict()
for i in range(N):
	d2[X[i]] = i + 1
for i in range(N):
	Z[i] = (d2[Y[i]] - (i + 1)) % N
from collections import defaultdict
d = defaultdict(int)
for z in Z:
	d[z] += 1
print(max(d.values()))


from fractions import Fraction
import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
n = iinput()
a = rlinput()
b = rlinput()
d = defaultdict(int)
for i in range(n):
	d[b[i]] = i
fre = defaultdict(int)
for i in range(n):
	diff = 0
	if i > d[a[i]]:
		diff = i - d[a[i]]
	elif i < d[a[i]]:
		diff = n - d[a[i]] + i
	fre[diff] += 1
print(max(fre.values()))


n = int(input())
a = [0] * (n + 1)
for (i, x) in enumerate(map(int, input().split())):
	a[x] = i
b = [0] * (n + 1)
for (i, x) in enumerate(map(int, input().split())):
	y = ((i - a[x]) % n + n) % n
	b[y] += 1
print(max(b))


n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
maxcount = 0
arr1_hash = {}
arr2_hash = {}
for i in range(n):
	arr1_hash[arr1[i]] = i
	arr2_hash[arr2[i]] = i
subs = {}
for i in range(n):
	sub = (arr1_hash[i + 1] - arr2_hash[i + 1]) % n
	if sub in subs.keys():
		subs[sub] += 1
	else:
		subs[sub] = 1
print(max(subs.values()))


def rotmatch(n, a, b):
	placea = [0] * n
	placeb = [0] * n
	diff = [0] * n
	for i in range(n):
		placea[a[i] - 1] = i
	for i in range(n):
		placeb[b[i] - 1] = i
	for i in range(n):
		diff[i] = (n - placea[i] + placeb[i]) % n
	ats = [0] * n
	for d in diff:
		ats[d] += 1
	return max(ats)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(rotmatch(n, a, b))


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
result = 0
position = [0 for _ in range(N)]
for (i, a) in enumerate(A):
	position[a - 1] = i
shift = [0 for _ in range(N)]
for i in range(N):
	shift[position[B[i] - 1] - i] += 1
print(max(shift))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	mIndex = {}
	for i in range(n):
		mIndex[b[i]] = i
	m = {}
	for i in range(n):
		(i1, i2) = (i, mIndex[a[i]])
		steps = n - i2 + i1
		if i1 > i2:
			steps = i1 - i2
		m[steps] = m.get(steps, 0) + 1
	res = 1
	for key in m.keys():
		res = max(res, m[key])
	print(res)
solve()


a = int(input())
z1 = list(map(int, input().split()))
z2 = list(map(int, input().split()))
maxa = 0
from collections import *
dl = defaultdict(int)
al = defaultdict(list)
al = defaultdict(lambda : [0, 0], al)
for i in range(len(z1)):
	al[z1[i]][0] = i
	al[z2[i]][1] = i
for i in range(1, a + 1):
	if al[i][1] >= al[i][0]:
		dl[al[i][1] - al[i][0]] += 1
		maxa = max(dl[al[i][1] - al[i][0]], maxa)
	else:
		dl[a - (al[i][0] - al[i][1])] += 1
		maxa = max(maxa, dl[a - (al[i][0] - al[i][1])])
print(maxa)


from collections import *
R = lambda : map(int, input().split())
(n,) = R()
a = [0] * n
i = 0
for (x, y) in zip(R(), R()):
	a[x - 1] += i
	a[y - 1] -= i
	i += 1
print(max(Counter((x % n for x in a)).values()))


n = int(input())
l = list(map(int, input().split()))
o = list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d[i] = []
for i in range(1, n + 1):
	d[l[i - 1]].append(i)
for i in range(1, n + 1):
	d[o[i - 1]].append(i)
r = []
l = []
for (key, value) in d.items():
	if d[key][0] < d[key][1]:
		d[key][0] += n
	dif = d[key][0] - d[key][1]
	r.append(dif)
for (key, value) in d.items():
	if d[key][1] < d[key][0]:
		d[key][1] += n
	dif = d[key][1] - d[key][0]
	l.append(dif)
dct = {}
dt = {}
for i in r:
	dct[i] = 0
for i in l:
	dt[i] = 0
for i in r:
	dct[i] += 1
for i in l:
	dt[i] += 1
maxi = 0
for (key, value) in dct.items():
	maxi = max(maxi, dct[key])
maxii = 0
for (key, value) in dt.items():
	maxii = max(maxii, dt[key])
print(max(maxii, maxi))


import math
mx = 200001

def DenTofieM():
	sz = int(input())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	posA = [0] * mx
	posB = [0] * mx
	for i in range(sz):
		posA[ar[i]] = i + 1
		posB[br[i]] = i + 1
	mp = {}
	for i in range(1, sz + 1):
		dis = posA[i] - posB[i]
		if dis < 0:
			dis += sz
		if dis in mp.keys():
			mp[dis] += 1
		else:
			mp[dis] = 1
	print(max(mp.values()))
DenTofieM()


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	n = fi()
	a = li()
	d = {}
	for i in range(n):
		d[a[i]] = i
	b = li()
	p = {}
	for i in range(n):
		inc(p, (d[b[i]] - i + n) % n)
	maxi = 0
	for i in p:
		maxi = max(maxi, p[i])
	print(maxi)


from collections import Counter
r = lambda : map(int, input().split())
(a,) = r()
v = [0] * a
i = 0
for (x, y) in zip(r(), r()):
	v[x - 1] += i
	v[y - 1] -= i
	i += 1
print(max(Counter((x % a for x in v)).values()))


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
for t in range(0, test):
	n = int(input().strip())
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	da = {}
	db = {}
	ind = a.index(1)
	rel = 0
	for i in range(ind, n):
		da[a[i]] = rel
		rel += 1
	for i in range(ind):
		da[a[i]] = rel
		rel += 1
	ind = b.index(1)
	rel = 0
	for i in range(ind, n):
		db[b[i]] = rel
		rel += 1
	for i in range(ind):
		db[b[i]] = rel
		rel += 1
	ans = {}
	for i in range(1, n + 1):
		temp = (da[i] - db[i] + n) % n
		ans[temp] = ans.get(temp, 0) + 1
	print(max(ans.values()))
	ans = solve()


def f1(l1, l2, n):
	(li1, li2) = ([0] * n, [0] * n)
	for i in range(n):
		li2[l2[i] - 1] = i
		li1[l1[i] - 1] = i
	ldif = []
	for i in range(n):
		d = li2[i] - li1[i]
		if d < 0:
			d += n
		ldif.append(d)
	ldif.sort()
	return ldif

def f2(ldif, n):
	cmax = 1
	c = 1
	for i in range(1, n):
		if ldif[i] == ldif[i - 1]:
			c += 1
		else:
			if cmax < c:
				cmax = c
			c = 1
	if cmax < c:
		cmax = c
	return cmax
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ldif = f1(l1, l2, n)
cmax = f2(ldif, n)
print(cmax)


from collections import Counter
n = int(input())
pos_as = {k: v for (k, v) in zip(map(int, input().split()), range(0, n))}
j = []
for (pos_b, v) in enumerate(map(int, input().split())):
	k = pos_b - pos_as[v]
	j.append(k if k >= 0 else n + k)
print(max(Counter(j).values()))


from collections import Counter

def Most_Common(lst):
	data = Counter(lst)
	return data.most_common(1)[0][0]
n = int(input(''))
act = list(map(int, input().split()))
cpy = list(map(int, input().split()))
act = list(map(lambda act: act - 1, act))
cpy = list(map(lambda cpy: cpy - 1, cpy))
act1 = act.copy()
cpy1 = cpy.copy()
for i in range(n):
	cpy[cpy1[i]] = i
	act[act1[i]] = i
diff = []
for i in range(n):
	k = act[i] - cpy[i] + n
	diff.append(k % n)
maxx = Most_Common(diff)
print(diff.count(maxx))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dct = dict()
	for i in range(n):
		if a[i] in dct:
			dct[a[i]][0] = i
		else:
			dct[a[i]] = [i, 0]
		if b[i] in dct:
			dct[b[i]][1] = i
		else:
			dct[b[i]] = [0, i]
	dif_dct = dict()
	for i in dct:
		dist = dct[i][0] - dct[i][1]
		if dist < 0:
			dist += n
		if dist in dif_dct:
			dif_dct[dist] += 1
		else:
			dif_dct[dist] = 1
	print(max([dif_dct[x] for x in dif_dct]))
t = 1
for i in range(t):
	main()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ad = {}
	dd = {}
	M = 0
	for (c, el) in enumerate(a):
		ad[el] = c
	for (c, el) in enumerate(b):
		target = ad[el]
		if target >= c:
			dist = target - c
		else:
			dist = n - c + target
		if dist not in dd:
			dd[dist] = 1
		else:
			dd[dist] += 1
		M = max(M, dd[dist])
	print(M)
main()


from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))[:n]
b = list(map(int, input().strip().split()))[:n]
inva = {j: ind for (ind, j) in enumerate(a)}
rr = Counter(((n + ind - inva[j]) % n for (ind, j) in enumerate(b)))
print(rr.most_common(1)[0][1])


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
pos = [0] * (n + 1)
for i in range(n):
	pos[a[i]] = i
for i in range(n):
	pos[b[i]] -= i
	if pos[b[i]] < 0:
		pos[b[i]] += n
counter = {}
for i in range(1, n + 1):
	if pos[i] in counter:
		counter[pos[i]] += 1
	else:
		counter[pos[i]] = 1
ans = 0
for (i, v) in counter.items():
	ans = max(ans, v)
print(ans)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = int_array()
b = int_array()
a_ind = {}
b_ind = {}
for i in range(n):
	a_ind[a[i]] = i
	b_ind[b[i]] = i
d = [a_ind[i] - b_ind[i] for i in range(1, n + 1)]
for i in range(n):
	if d[i] < 0:
		d[i] += n
k = dict()
for i in d:
	k[i] = k.get(i, 0) + 1
print(max(k.values()))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
d1 = dict()
d2 = dict()
for i in range(n):
	d1[l1[i]] = i
	d2[l2[i]] = i
l = [0 for i in range(n + 1)]
for k in d1.keys():
	try:
		if d1[k] <= d2[k]:
			d = d2[k] - d1[k]
			l[d] += 1
		else:
			d = n - d1[k] - 1 + d2[k] + 1
			l[d] += 1
	except:
		pass
print(max(l))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
shifts = {}
ans = 1
alpha = {}
for i in range(n):
	alpha[b[i]] = [i]
for i in range(n):
	alpha[a[i]].append(i)
for i in range(n):
	index = alpha[b[i]][1]
	shift = 0
	if index < i:
		index = n + index
	shift = index - i
	if shift in shifts:
		shifts[shift] += 1
	else:
		shifts[shift] = 1
for s in shifts:
	if shifts[s] > ans:
		ans = shifts[s]
print(ans)


import math
import sys
from itertools import permutations
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
	ans[a[i] - 1] += i
	ans[b[i] - 1] -= i
last = [0] * n
for i in range(n):
	ans[i] += n
	ans[i] = ans[i] % n
	last[ans[i]] += 1
print(max(last))


import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda : int(input())
ip = lambda : [int(w) for w in input().split()]
n = inp()
a = ip()
b = ip()
d = [0] * n
(at, bt) = ({}, {})
for i in range(n):
	at[a[i]] = i
	bt[b[i]] = i
for i in range(n):
	d[i] = (bt[a[i]] - i + n) % n
dt = {}
for i in d:
	dt[i] = dt.get(i, 0) + 1
print(max(dt.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
inda = {}
for i in range(n):
	inda[a[i]] = i
indb = {}
for i in range(n):
	indb[b[i]] = i
shift = [0] * n
for i in range(n):
	if a[i] in indb:
		ind = indb[a[i]]
		if ind < i:
			val = n - (i + 1) + ind + 1
		else:
			val = ind - i
		shift[val] += 1
print(max(shift))


from collections import defaultdict
t = 1
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = defaultdict(int)
	ind_a = {}
	ind_b = {}
	for i in range(n):
		ind_a[a[i]] = i
		ind_b[b[i]] = i
	for i in range(1, n + 1):
		if ind_a[i] >= ind_b[i]:
			d[ind_a[i] - ind_b[i]] += 1
		else:
			d[n - ind_b[i] + ind_a[i]] += 1
	ans = 0
	for (key, val) in d.items():
		if val > ans:
			ans = val
	print(ans)


from collections import deque, Counter

def read_many_bool():
	return list(map(lambda x: x == '1', input().split()))

def read_many():
	return deque(map(int, input().split()))

def read_int():
	return int(input())
n = read_int()
ass = read_many()
ass = {val: key + 1 for (key, val) in enumerate(ass)}
bss = read_many()
bss = {val: key + 1 for (key, val) in enumerate(bss)}
cc = Counter()
for i in range(1, n + 1):
	a_idx = ass[i]
	b_idx = bss[i]
	count = a_idx - b_idx
	if count < 0:
		count = n + count
	cc[count] += 1
print(cc.most_common(1)[0][1])


for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = [0] * n
	b1 = [0] * n
	d = [0] * n
	for i in range(n):
		a1[a[i] - 1] = i
		b1[b[i] - 1] = i
	for i in range(n):
		d[i] = (n + a1[i] - b1[i]) % n
	d.sort()
	k = 1
	cnt = []
	for i in range(1, n):
		if d[i] == d[i - 1]:
			k += 1
		else:
			cnt.append(k)
			k = 1
	cnt.append(k)
	print(max(cnt))


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aIndices = [-1 for _ in range(n + 1)]
bIndices = [-1 for _ in range(n + 1)]
for i in range(n):
	aIndices[a[i]] = i
	bIndices[b[i]] = i
rotationCnts = dict()
for x in range(1, n + 1):
	nRotations = aIndices[x] - bIndices[x]
	if nRotations < 0:
		nRotations += n
	if nRotations not in rotationCnts.keys():
		rotationCnts[nRotations] = 0
	rotationCnts[nRotations] += 1
print(max(rotationCnts.values()))


a = [0 for y in range(200001)]
b = [0 for y in range(200001)]
n = int(input())
m = -1
temp = input().split()
for i in range(0, n):
	a[int(temp[i])] = i
temp = input().split()
for i in range(0, n):
	l = (n + a[int(temp[i])] - i) % n
	b[l] += 1
	m = max(m, b[l])
print(m)


from sys import stdin, stdout
from collections import Counter, defaultdict
import math

def readInt():
	return int(stdin.readline())

def readString():
	return stdin.readline()[:-1]

def readListInt():
	return list(map(int, stdin.readline().split()))

def readListStr():
	return list(map(str, stdin.readline().split()))

def nextLine():
	stdout.write('\n')

def show(x):
	stdout.write(str(x) + '\n')

def showInline(x):
	stdout.write(str(x))

def showList(x):
	for i in x:
		stdout.write(str(i) + ' ')
	nextLine()

def show2D(x):
	for i in range(len(x)):
		for j in range(len(x[0])):
			stdout.write(str(x[i][j]) + ' ')
		nextLine()

def emptyList(length, value=-1):
	return [value] * length

def empty2D(row, col, val=-1):
	return [[val for i in range(col)] for j in range(row)]

def isSquare(x):
	if x ** 0.5 * 10 % 10 == 0:
		return 1
	return 0

def isLog(val, base):
	a = math.log(val, base)
	if a * 10 % 10 == 0:
		return 1
	else:
		return 0

def solve():
	n = readInt()
	arr1 = readListInt()
	arr2 = readListInt()
	dict1 = defaultdict()
	dict2 = defaultdict()
	for i in range(n):
		dict1[arr1[i]] = i
		dict2[arr2[i]] = i
	maxi = 0
	arr1 = []
	for i in range(1, n + 1):
		arr1.append((dict1[i] - dict2[i] + n) % n)
	dict1 = Counter(arr1)
	a = dict1.values()
	maxi = max(a)
	print(maxi)
solve()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
N = 10 ** 9 + 7
n = I()
v = [0] * (n + 1)
ind = [0] * (n + 1)
for (i, j) in enumerate(R(), 1):
	ind[j] = i
for (i, j) in enumerate(R(), 1):
	if ind[j] > i:
		v[i + n - ind[j]] += 1
	else:
		v[i - ind[j]] += 1
print(max(v))


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Left = [0 for i in range(n + 1)]
Right = [0 for i in range(n + 1)]
Pos = [[-1, -1] for i in range(n + 1)]
for i in range(n):
	Pos[A[i]][0] = i
	Pos[B[i]][1] = i
for i in range(1, n + 1):
	(a, b) = (Pos[i][0], Pos[i][1])
	if a > b:
		Left[n + (b - a)] += 1
		Right[a - b] += 1
	elif a == b:
		Left[0] += 1
	else:
		Left[b - a] += 1
		Right[n + (a - b)] += 1
l = max(Left)
r = max(Right)
print(max(l, r))


def val(ai, bi):
	final = {}
	lst = {}
	for i in range(N):
		final[bi[i]] = i
	for i in range(N):
		if final[ai[i]] - i < 0:
			final[ai[i]] = N - i + final[ai[i]]
		else:
			final[ai[i]] -= i
	for i in final:
		if final[i] not in lst:
			lst[final[i]] = 1
		else:
			lst[final[i]] += 1
	high = 1
	for i in lst:
		if lst[i] > high:
			high = lst[i]
	return high
N = int(input())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
if N < 3:
	print(N)
else:
	print(val(ai, bi))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = [0] * n
cb = [0] * n
for i in range(n):
	ca[a[i] - 1] = i
	cb[b[i] - 1] = i
t = [0] * n
for i in range(n):
	t[(ca[i] - cb[i]) % n] += 1
print(max(t))


from collections import Counter
N = int(input())
lst1 = [int(x) for x in input().split()]
lst2 = [int(x) for x in input().split()]
d1 = {}
cyclick_lst = []
for j in range(N):
	d1[lst1[j]] = j + 1
for j in range(1, N + 1):
	y = d1[lst2[j - 1]]
	cyclick_lst.append((y - j + N) % N)
d2 = Counter(cyclick_lst)
print(max(d2.values()))


import sys
readline = sys.stdin.readline
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))

def solve():
	n = ni()
	a = nl()
	b = nl()
	g = [0] * n
	f = [0] * n
	for i in range(n):
		g[a[i] - 1] = i
		f[b[i] - 1] = i
	for i in range(n):
		g[i] -= f[i]
	d = dict()
	for x in g:
		x %= n
		if x not in d:
			d[x] = 0
		d[x] += 1
	print(max(d.values()))
	return
solve()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = {}
d2 = {}
c = {}
for x in range(n):
	d1[a[x]] = x
	d2[b[x]] = x
for x in range(1, n + 1):
	if d1[x] - d2[x] < 0:
		d1[x] += n
	if d1[x] - d2[x] in c:
		c[d1[x] - d2[x]] += 1
	else:
		c[d1[x] - d2[x]] = 1
print(max(c.values()))


n = int(input())
pos = [0] * (n + 1)
ans = dict()
a = list(map(int, input().split()))
for i in range(1, n + 1):
	pos[a[i - 1]] = i
b = list(map(int, input().split()))
for i in range(1, n + 1):
	ps = pos[b[i - 1]] - i
	if ps < 0:
		ps += n
	ans[ps] = ans.get(ps, 0) + 1
print(max(ans.values()))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = {}
for i in range(n):
	d[a[i]] = i
for i in range(n):
	k = d[b[i]] - i
	if k >= 0:
		c.append(k)
	else:
		c.append(k + n)
print(Counter(c).most_common(1)[0][1])


import sys
import string
import math
import bisect as bi
from collections import defaultdict as dd
input = sys.stdin.readline

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def pref(a, n):
	pre = [0] * n
	pre[0] = a[0]
	for i in range(1, n):
		pre[i] = a[i] + pre[i - 1]
	return pre
d1 = dd(int)
d2 = dd(int)
d3 = dd(int)
d4 = dd(int)
n = inin()
a = ain()
b = ain()
for i in range(n):
	d1[a[i]] = i
	d2[b[i]] = i
for i in a:
	x = d1[i] - d2[i]
	if x < 0:
		x = x + n
	d3[x] += 1
print(max(d3.values()))


from collections import defaultdict, Counter
t = 1
for _ in range(t):
	n = int(input())
	arr1 = list(map(int, input().strip().split()))
	arr2 = list(map(int, input().strip().split()))
	dic1 = defaultdict(int)
	dic2 = defaultdict(int)
	for i in range(n):
		dic1[arr1[i]] = i
		dic2[arr2[i]] = i
	freq_dic = Counter()
	for i in range(1, n + 1):
		key = dic1[i] - dic2[i]
		if key < 0:
			key = key % n
		freq_dic[key] += 1
	print(freq_dic.most_common(1)[0][1])


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for (k, v) in enumerate(a):
	d[v] = [k]
for (k, v) in enumerate(b):
	d[v] += [k]
counter = Counter()
for i in d:
	if d[i][1] >= d[i][0]:
		l = d[i][1] - d[i][0]
	else:
		l = d[i][1] + (n - d[i][0])
	counter[l] += 1
s = max(counter.values())
print(s)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
new_a = []
new_b = []
diff = []
for i in range(n + 1):
	new_a.append(0)
	new_b.append(0)
for i in range(n):
	new_a[a[i]] = i + 1
	new_b[b[i]] = i + 1
for i in range(1, n + 1):
	d = new_a[i] - new_b[i]
	if d < 0:
		s = new_a[i] - 1
		e = n - new_b[i]
		diff.append(s + e + 1)
	else:
		diff.append(d)
diff.sort()
max = 1
cnt = 1
for i in range(n - 1):
	if diff[i] == diff[i + 1]:
		cnt += 1
	else:
		if cnt > max:
			max = cnt
		cnt = 1
if cnt > max:
	max = cnt
print(max)


n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
h = [0 for a in range(0, n + 1)]
for i in range(0, n):
	h[a[i]] = i
r = []
for i in range(0, n):
	i2 = h[b[i]]
	if i2 > i:
		if i2 - i < n - (i2 - i):
			res = 'r' + str(i2 - i)
		else:
			res = 'l' + str(n - (i2 - i))
	elif i - i2 < n - (i - i2):
		res = 'l' + str(i - i2)
	else:
		res = 'r' + str(n - (i - i2))
	if int(res[1:]) == 0:
		r.append('p')
	else:
		r.append(res)
from collections import Counter
r = Counter(r)
r2 = []
for token in r.keys():
	r2.append(r[token])
print(max(r2))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(1):
	n = Int()
	a = array()
	ind_a = {a[i]: i + 1 for i in range(n)}
	b = array()
	ind_b = {b[i]: i + 1 for i in range(n)}
	toRotate = defaultdict(int)
	for i in range(1, n + 1):
		toRotate[(ind_a[i] - ind_b[i]) % n] += 1
	print(max(toRotate.values()))


import os
import sys
import io
import math

def mostFrequent(arr, n):
	Hash = dict()
	for i in range(n):
		if arr[i] in Hash.keys():
			Hash[arr[i]] += 1
		else:
			Hash[arr[i]] = 1
	max_count = 0
	res = -1
	for i in Hash:
		if max_count < Hash[i]:
			res = i
			max_count = Hash[i]
	return max_count
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a1 = map(int, input().split())
a2 = map(int, input().split())
(a1, a2) = (list(a1), list(a2))
l1 = [0] * n
l2 = [0] * n
for i in range(n):
	l1[a1[i] - 1] = i
	l2[a2[i] - 1] = i
moddiff = []
for i in range(n):
	moddiff.append((l1[i] - l2[i]) % n)
print(mostFrequent(moddiff, n))


t = 1
import math
delay = []
for _ in range(t):
	n = int(input())
	top = input().split()
	top = [int(t) for t in top]
	bot = input().split()
	bot = [int(b) for b in bot]
	dic = {}
	for (idx, ele) in enumerate(top):
		dic[ele] = idx
	counts = {}
	for (idx, ele) in enumerate(bot):
		num = (idx - dic[ele] + n) % n
		if num in counts:
			counts[num] += 1
		else:
			counts[num] = 1
	ans = 1
	for k in counts:
		if counts[k] > ans:
			ans = counts[k]
	print(ans)


def f():
	return list(map(int, input().split()))
n = int(input())
a = [0] * n
for (i, x) in enumerate(f()):
	a[x - 1] = i
import collections
c = collections.Counter()
for (i, x) in enumerate(f()):
	c[(a[x - 1] - i + n) % n] += 1
print(max(c.values()))


import queue
import math
n = int(input())
a = input().split()
a = [int(x) for x in a]
b = input().split()
b = [int(x) for x in b]
pos = [0 for i in range(n + 1)]
for i in range(n):
	pos[b[i]] = i
cnt = {}
for i in range(n):
	k = pos[a[i]] - i
	if k < 0:
		k += n
	if k not in cnt:
		cnt[k] = 0
	cnt[k] += 1
ans = 0
for value in cnt.values():
	ans = max(ans, value)
print(ans)


from sys import stdin

def main():
	n = int(stdin.readline())
	b1 = [int(i) for i in stdin.readline().split()]
	b2 = [int(i) for i in stdin.readline().split()]
	d = [0 for i in range(n)]
	for i in range(n):
		d[b1[i] - 1] = i
	o = dict()
	for i in range(n):
		s = d[b2[i] - 1]
		if s < i:
			s += n
			m = s - i
		if s == i:
			m = 0
		else:
			m = s - i
		if m in o:
			o[m] += 1
		else:
			o[m] = 1
	print(max(o.values()))
main()


from sys import stdin, stdout
from collections import defaultdict
n = int(stdin.readline().strip())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
pos = [0] * (n + 1)
cntDict = [0] * n
for i in range(n):
	pos[a[i]] = i
for i in range(n):
	r1 = i
	r2 = pos[b[i]]
	d = r2 - r1
	if d < 0:
		d = d + n
	cntDict[d] += 1
print(max(cntDict))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l1p = [-1] * n
l3 = [0] * (n + 1)
for i in range(n):
	l1p[l1[i] - 1] = i
for i in range(n):
	cur = i - l1p[l2[i] - 1]
	if cur < 0:
		cur += n
	l3[cur] += 1
print(max(l3))


n = int(input())
a = [0 for _ in range(n + 20)]
b = [0 for _ in range(n + 20)]
tmp_a = [int(x) for x in input().split()]
tmp_b = [int(x) for x in input().split()]
for i in range(n):
	a[tmp_a[i]] = i
for i in range(n):
	b[((a[tmp_b[i]] - i) % n + n) % n] += 1
ans = -1
for i in range(n):
	ans = max(ans, b[i])
print(ans)


arrLen = int(input())
targetArr = list(map(int, input().split()))
realArr = list(map(int, input().split()))
toMove = [0 for i in range(arrLen)]
pos = [0 for i in range(arrLen + 1)]
for i in range(arrLen):
	pos[targetArr[i]] = i
for i in range(arrLen):
	place = pos[realArr[i]]
	if place - i < 0:
		moves = arrLen - i + place
	else:
		moves = place - i
	toMove[moves] += 1
maxMove = 0
for elemet in toMove:
	maxMove = max(maxMove, elemet)
print(maxMove)


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
for i in range(n):
	C.append(0)
for i in range(n):
	A[i] = (A[i], i)
	B[i] = (B[i], i)
A.sort(key=lambda n: n[0])
B.sort(key=lambda n: n[0])
for i in range(n):
	C[(A[i][1] - B[i][1] + n) % n] += 1
print(max(C))


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = [0] * (n + 1)
b = [0] * (n + 1)
t = list(map(int, input().split()))
for i in range(n):
	a[t[i]] = i
t = list(map(int, input().split()))
for i in range(n):
	b[t[i]] = i
c = list()
for i in range(1, n + 1):
	temp = a[i] - b[i]
	if temp < 0:
		temp = n + temp
	c.append(temp)
c.sort()
mx = 1
curr = 1
for i in range(1, n):
	if c[i] == c[i - 1]:
		curr += 1
	else:
		mx = max(mx, curr)
		curr = 1
mx = max(mx, curr)
print(mx)


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dicA = {i: e for (e, i) in enumerate(a)}
dicB = {i: e for (e, i) in enumerate(b)}
rdata = [0] * N
for i in range(1, N + 1):
	A = dicA[i]
	B = dicB[i]
	if B > A:
		rdata[B - A] += 1
	else:
		rdata[(N - (A - B)) % N] += 1
ans = max(rdata)
print(ans)


for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[b[i]] = i
	d1 = {}
	for i in range(n):
		rz = d[a[i]] - i
		if rz < 0:
			rz = n + rz
		d1[rz] = d1.get(rz, 0) + 1
	print(max(d1.values()))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(test,) = Neo()
A = Neo()
B = Neo()
A = sorted([(j, i) for (i, j) in enumerate(A)])
B = sorted([(j, i) for (i, j) in enumerate(B)])
d = defaultdict(int)
for (i, j) in zip(A, B):
	(a, b) = (i[1], j[1])
	t = a - b
	if b > a:
		(a, b) = (b, a)
		t += test
	d[t] += 1
print(max(d.values()))


from math import ceil

def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

def ar(element, size):
	return [element for i in range(size)]

def yes():
	print('Yes')

def no():
	print('No')
Testcase = 1
for _ in range(Testcase):
	n = inin()
	a = inar()
	b = inar()
	indexofa = [-1 for i in range(n + 1)]
	for i in range(n):
		indexofa[a[i]] = i
	rotations = [0 for x in range(n + 1)]
	for i in range(n):
		temp = indexofa[b[i]] - i
		if temp < 0:
			temp += n
		rotations[temp] += 1
	print(max(rotations))


n = int(input())
lst1 = [int(i) for i in input().split()]
lst2 = [int(i) for i in input().split()]
res = [0] * (n + 1)
d = {}
for i in range(n):
	d[lst1[i]] = i
for i in range(n):
	k = d[lst2[i]] - i
	if k > 0:
		res[k] += 1
	else:
		res[n + k] += 1
print(max(res))


import sys
input = sys.stdin.readline

def N():
	return int(input())

def NM():
	return map(int, input().split())

def L():
	return list(NM())

def LN(n):
	return [N() for i in range(n)]

def LL(n):
	return [L() for i in range(n)]
n = N()
a = L()
b = L()
d = dict()
for (i, j) in enumerate(a):
	d[j] = i
import collections
ans = collections.defaultdict(int)
for (i, j) in enumerate(b):
	ans[(d[j] - i) % n] += 1
print(max(ans.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
bm = {}
for i in range(n):
	bm[b[i]] = i
temp = []
for i in range(n):
	j = bm[a[i]]
	if i < j:
		temp.append(j - i)
	else:
		temp.append(n - i + j)
freq = [0] * (n + 1)
for i in temp:
	freq[i] += 1
print(max(freq))


from sys import stdin
from math import ceil, gcd

def func():
	return
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
d = {}
for i in range(n):
	d[a[i]] = i
for i in range(n):
	d[b[i]] = (d[b[i]] - i) % n
arr = list(d.values())
k = {}
for ele in arr:
	k[ele] = k.get(ele, 0) + 1
print(max(list(k.values())))


import collections
n = int(input())
l = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = {}
d2 = {}
for i in range(0, n):
	d1[l[i]] = i
	d2[b[i]] = i
c = []
for i in range(1, n + 1):
	c.append(d1[i] - d2[i])
	c.append(n + (d1[i] - d2[i]))
k = collections.Counter(c)
print(max(k.values()))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
f1 = {}
f2 = {}
for i in range(n):
	f1[a[i]] = i
for i in range(n):
	f2[b[i]] = i
checker = {}
for i in range(1, n + 1):
	if f1[i] <= f2[i]:
		checker[i] = f2[i] - f1[i]
	else:
		checker[i] = n - f1[i] + f2[i]
mx = Counter(list(checker.values()))
ans = max(mx.values())
print(ans)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
a = ai()
b = ai()
a_ = [-1] * n
b_ = [-1] * n
for i in range(n):
	a_[a[i] - 1] = i + 1
for j in range(n):
	b_[b[j] - 1] = j + 1
new = []
for i in range(n):
	if a_[i] - b_[i] < 0:
		new.append((a_[i] - b_[i]) % n)
	else:
		new.append(a_[i] - b_[i])
final = Counter(new).most_common()[0][1]
print(final)


n = input()
n = int(n)
a = input()
b = input()
a = a.split(' ')
b = b.split(' ')
for k in range(n):
	a[k] = int(a[k])
	b[k] = int(b[k])
c = [0] * n
d = [0] * n
e = [0] * n
for k in range(n):
	c[a[k] - 1] = k
	d[b[k] - 1] = k
for k in range(n):
	e[k] = d[k] - c[k]
	if e[k] < 0:
		e[k] = n + e[k]
f = [0] * n
for k in range(n):
	f[e[k]] += 1
print(max(f))


from math import inf as inf
from math import *
from collections import *
import sys
input = sys.stdin.readline
t = 1
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dic = {}
	dic1 = {}
	ind1 = {}
	ind2 = {}
	for i in range(n):
		ind1[a[i]] = i
	for i in range(n):
		ind2[b[i]] = i
	for i in range(1, n + 1):
		if ind1[i] < ind2[i]:
			try:
				dic[n - ind2[i] + ind1[i]] += 1
			except:
				dic[n - ind2[i] + ind1[i]] = 1
		else:
			try:
				dic[ind1[i] - ind2[i]] += 1
			except:
				dic[ind1[i] - ind2[i]] = 1
	for i in range(1, n + 1):
		if ind1[i] > ind2[i]:
			try:
				dic1[ind1[i] - ind2[i]] += 1
			except:
				dic1[ind1[i] - ind2[i]] = 1
		else:
			try:
				dic1[n - ind1[i] + ind2[i]] += 1
			except:
				dic1[n - ind1[i] + ind2[i]] = 1
	print(max(max(dic.values()), max(dic1.values())))


r = lambda : map(int, input().split())
n = int(input())
a = {}
b = {}
g = [0] * n
for (x, i, j) in zip(range(n), r(), r()):
	a[i] = b[j] = x
for i in range(1, n + 1):
	g[(b[i] - a[i]) % n] += 1
print(max(g))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def most_frequent(List):
	dict = {}
	(count, itm) = (0, '')
	for item in reversed(List):
		dict[item] = dict.get(item, 0) + 1
		if dict[item] >= count:
			(count, itm) = (dict[item], item)
	return itm
for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	va = dict()
	vb = dict()
	for i in range(n):
		va.setdefault(a[i], i)
		vb.setdefault(b[i], i)
	cnt = []
	for (k, v) in va.items():
		val = (v - vb[k]) % n
		cnt.append(val)
	cnt.sort()
	ans = most_frequent(cnt)
	temp1 = b[-ans:] + b[:-ans]
	final2 = 0
	for i in range(n):
		if a[i] == temp1[i]:
			final2 += 1
	print(final2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arr = [0] * n
for i in range(n):
	arr[a[i] - 1] += i
	arr[b[i] - 1] -= i
for i in range(n):
	arr.append(arr[i] - n)
freq = {}
for i in arr:
	freq[i] = freq.get(i, 0) + 1
max = 0
for i in freq:
	if freq[i] > max:
		max = freq[i]
print(max)


n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) - 1 for i in input().split()]
ia = [-1 for i in range(n)]
ib = [-1 for i in range(n)]
for i in range(n):
	ia[a[i]] = i
	ib[b[i]] = i
d = [0 for i in range(n)]
for i in range(n):
	d[i] = ia[i] - ib[i] if ia[i] > ib[i] else ia[i] - ib[i] + n
f = {i: 0 for i in set(d)}
for i in d:
	f[i] += 1
an = max(f.values())
print(an)


import sys
import math
sys.setrecursionlimit(1000000)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')
p2S = lambda x: print(*x, sep=' ')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	n = II()
	sa = LI()
	sb = LI()
	d = {}
	ds = {}
	for i in range(n):
		d[sa[i]] = i
	for i in range(n):
		step = (i - d[sb[i]] + n) % n
		if step in ds:
			ds[step] += 1
		else:
			ds[step] = 1
	ans = 0
	for (i, j) in ds.items():
		ans = max(ans, j)
	print(ans)
main()


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = [0] * n
B = [0] * n
for i in range(n):
	A[a[i] - 1] = i
	B[b[i] - 1] = i
dp = [0] * n
for i in range(n):
	dp[A[i] - B[i]] += 1
print(max(dp))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
res = [0] * (n + 1)
for i in range(n):
	d[a[i]] = [i]
for i in range(n):
	d[b[i]].append(i)
for i in range(n):
	(l, h) = d[a[i]]
	if h > l:
		res[h - l] += 1
	else:
		res[n - l + h] += 1
print(max(res))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
for i in range(n):
	d[i] = [-1, -1]
for i in range(n):
	d[a[i] - 1][0] = i
	d[b[i] - 1][1] = i
ans = dict()
answer = 0
for i in d:
	x = (d[i][0] - d[i][1]) % n
	if x in ans:
		ans[x] += 1
		answer = max(ans[x], answer)
	else:
		ans[x] = 1
		answer = max(ans[x], answer)
print(answer)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
hash1 = defaultdict(int)
hash2 = defaultdict(int)
hash = defaultdict(lambda : [0, 0])
for i in range(n):
	hash[l1[i]][0] = i
	hash[l2[i]][1] = i
for i in range(n):
	(a, b) = hash[l1[i]]
	if b >= a:
		hash1[b - a] += 1
		hash2[n - b + a] += 1
	if a > b:
		hash2[a - b] += 1
		hash1[b + n - a] += 1
maxi = 0
for i in hash1:
	maxi = max(hash1[i], maxi)
for i in hash2:
	maxi = max(hash2[i], maxi)
print(maxi)


from sys import *

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	idx = [0 for _ in range(n + 1)]
	for i in range(n):
		idx[a[i]] = i
	offcnt = {}
	for i in range(n):
		offset = (idx[b[i]] - i) % n
		if not offset in offcnt:
			offcnt[offset] = 1
		else:
			offcnt[offset] += 1
	ans = 0
	for (_, v) in offcnt.items():
		ans = max(ans, v)
	print(ans)
solve()


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_loc = [-1 for i in range(n)]
b_loc = [-1 for i in range(n)]
for i in range(n):
	a_loc[a[i] - 1] = i
	b_loc[b[i] - 1] = i
turn = map(lambda x: x[0] - x[1] if x[0] - x[1] > 0 else x[0] - x[1] + n, zip(a_loc, b_loc))
print(Counter(turn).most_common(1)[0][1])


import sys
from collections import defaultdict
TEST = 0
if TEST == 1:
	input_file = open('inputC.txt', 'r')
	input_from_file = input_file.readlines()

def read_int():
	if TEST:
		return int(input_from_file.pop(0))
	else:
		return int(sys.stdin.readline())

def read_ints():
	if TEST:
		return list(map(int, input_from_file.pop(0).rstrip().split()))
	else:
		return list(map(int, sys.stdin.readline().split()))

def getIndecies(a_ind, b_ind, n, j):
	(cur_a_ind, cur_b_ind) = (a_ind + j, b_ind + j)
	if cur_a_ind >= n:
		cur_a_ind = cur_a_ind - n
	if cur_b_ind >= n:
		cur_b_ind = cur_b_ind - n
	return (cur_a_ind, cur_b_ind)
n = read_int()
a = read_ints()
b = read_ints()
k_dict = defaultdict(int)
b_dict = {b_i: b_ind for (b_ind, b_i) in enumerate(b)}
for (a_ind, a_i) in enumerate(a):
	b_ind = b_dict[a_i]
	k = b_ind - a_ind
	if k < 0:
		k = n + k
	elif k > n:
		k = k - n
	k_dict[k] += 1
max_val = max(k_dict.values())
print(max_val)


for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	e = {}
	for i in range(n):
		d[l[i]] = i
		e[b[i]] = i
	ans = 0
	g = []
	h = []
	for i in range(1, n + 1):
		if d[i] >= e[i]:
			g.append(abs(d[i] - e[i]))
			h.append(n - g[-1])
		else:
			h.append(abs(d[i] - e[i]))
			g.append(n - h[-1])
	ans = 0
	d = {}
	e = {}
	for i in g:
		try:
			d[i] += 1
		except:
			d[i] = 1
	for i in d:
		ans = max(ans, d[i])
	for i in h:
		try:
			e[i] += 1
		except:
			e[i] = 1
	for i in e:
		ans = max(ans, e[i])
	print(ans)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

def li():
	return list(map(int, sys.stdin.readline().split()))

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = 1
	for tt in range(t):
		n = nu()
		a = li()
		b = li()
		x = [0] * (n + 1)
		y = [0] * (n + 1)
		ind1 = [0] * (n + 1)
		ind2 = [0] * (n + 1)
		for i in range(n):
			ind1[a[i]] = i
		for i in range(n):
			ind2[b[i]] = i
		for i in range(1, n + 1):
			if ind1[i] > ind2[i]:
				x[i] = (n - (ind1[i] - ind2[i])) % n
				y[i] = ind1[i] - ind2[i]
				continue
			x[i] = ind2[i] - ind1[i]
			y[i] = (n - (ind2[i] - ind1[i])) % n
		fre1 = [0] * n
		fre2 = [0] * n
		for i in range(1, n + 1):
			fre1[x[i]] += 1
			fre2[y[i]] += 1
		mx = 0
		print(max(max(fre1), max(fre2)))
solve()


import functools

def A():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		a = [[]] * n
		for j in range(n):
			a[j] = list(map(int, input().split()))
		free_str_state = [1] * n
		free_col_state = [1] * m
		for i in range(n):
			for j in range(m):
				if a[i][j]:
					free_str_state[i] = 0
					free_col_state[j] = 0
		res = min(sum(free_str_state), sum(free_col_state))
		if res % 2 == 1:
			print('Ashish')
		else:
			print('Vivek')

def B():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		el0_cnt = len([e for e in b if e == 0])
		el1_cnt = n - el0_cnt
		if el0_cnt == 0 or el1_cnt == 0:
			sorted_a = sorted(a)
			ans = sorted_a == a
		else:
			ans = True
		print('Yes' if ans else 'No')

def C():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_n_to_pos = {}
	b_n_to_pos = {}
	for i in range(n):
		a_n_to_pos[a[i]] = i
		b_n_to_pos[b[i]] = i
	diff_to_cnt = {}
	for val in range(1, n + 1):
		pos_a = a_n_to_pos[val]
		pos_b = b_n_to_pos[val]
		diff = pos_a - pos_b
		if diff < 0:
			diff += n
		if diff not in diff_to_cnt:
			diff_to_cnt[diff] = 0
		diff_to_cnt[diff] += 1
	max_cnt = functools.reduce(lambda a, b: max(a, b), diff_to_cnt.values())
	print(max_cnt)
C()


import sys
from collections import defaultdict

def printMat(mat):
	for i in range(len(mat)):
		mat_str = map(str, mat[i])
		print(' '.join(mat_str))

def printList(l):
	l_str = map(str, l)
	print(' '.join(l_str))

def helper(a, b, n):
	(offset, a2i, ans) = (defaultdict(int), {}, 0)
	for (i, v) in enumerate(a):
		a2i[v] = i
	for (i, v) in enumerate(b):
		off = (i - a2i[v]) % n
		offset[off] += 1
	for (off, cnt) in offset.items():
		ans = max(ans, cnt)
	return ans
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(helper(a, b, n))


n = int(input())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
ll1 = [[l1[i], i] for i in range(n)]
ll2 = [[l2[i], i] for i in range(n)]
ll1 = sorted(ll1, key=lambda x: x[0])
ll2 = sorted(ll2, key=lambda x: x[0])
s = []
for i in range(n):
	s.append((ll1[i][1] - ll2[i][1]) % n)
d = {}
l = [0] * (max(s) + 1)
for i in s:
	if l[i] == 1:
		d[i] += 1
	else:
		d[i] = 1
		l[i] = 1
se = set(s)
m = 0
for i in se:
	m = max(m, d[i])
print(m)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * n
for i in range(n):
	c[a[i] - 1] = i + 1
for i in range(n):
	d[b[i] - 1] = i + 1
e = []
for i in range(n):
	e.append((c[i] - d[i] + n) % n)
g = [0] * (n + 1)
for i in range(n):
	g[e[i]] += 1
print(max(g))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import sqrt, ceil, factorial, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from decimal import Decimal
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
a = l()
b = l()
index = dd(int)
for i in range(n):
	index[a[i]] = i
dp = dd(int)
for i in range(n):
	if index[b[i]] < i:
		dp[n - (i - index[b[i]])] += 1
	else:
		dp[index[b[i]] - i] += 1
out(max(dp.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
idx1 = {}
idx2 = {}
for i in range(n):
	idx1[a[i]] = i
	idx2[b[i]] = i
freq = {}
mx = 0
for i in range(n):
	diff = (idx1[a[i]] - idx2[a[i]]) % n
	if diff not in freq:
		freq[diff] = 0
	freq[diff] += 1
	mx = max(mx, freq[diff])
print(mx)


from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
a = [int(x) for x in inp().split()]
b = [int(x) for x in inp().split()]
index = [0] * (n + 1)
ans = [0] * (n + 5)
for i in range(n):
	index[a[i]] = i + 1
for i in range(n):
	shift = index[b[i]] - i
	if shift < 0:
		shift += n
	ans[shift] += 1
print(max(ans))


from collections import Counter
n = int(input())
t = [0] * n
for (i, v) in enumerate(map(int, input().split())):
	t[v - 1] = i
for (i, v) in enumerate(map(int, input().split())):
	t[v - 1] -= i
	t[v - 1] %= n
print(max(Counter(t).values()))


n = int(input())
a = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))
posa = {}
posb = {}
for i in range(n):
	posa[a[i]] = i
	posb[b[i]] = i
diff_r = {}
diff_l = {}
for i in range(1, n + 1):
	if posa[i] - posb[i] < 0:
		diff_r[i] = n + posa[i] - posb[i]
	else:
		diff_r[i] = posa[i] - posb[i]
	if posb[i] - posa[i] < 0:
		diff_l[i] = n + posb[i] - posa[i]
	else:
		diff_l[i] = posb[i] - posa[i]
dfreq_r = {}
for item in diff_r.values():
	if item in dfreq_r:
		dfreq_r[item] += 1
	else:
		dfreq_r[item] = 1
dfreq_l = {}
for item in diff_l.values():
	if item in dfreq_l:
		dfreq_l[item] += 1
	else:
		dfreq_l[item] = 1
print(max(max(dfreq_r.values()), max(dfreq_l.values())))


import sys
import math
from collections import defaultdict, deque
import heapq
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
dpa = defaultdict(int)
for i in range(n):
	dpa[a[i]] = i
cnt = defaultdict(int)
for i in range(n):
	x = dpa[b[i]]
	if x < i:
		cnt[n - i + x] += 1
	else:
		cnt[x - i] += 1
maxx = 0
k = 0
for i in cnt:
	if cnt[i] > k:
		k = cnt[i]
print(k)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_pol = [-1 for _ in range(n)]
b_pol = [-1 for _ in range(n)]
for i in range(n):
	a_pol[a[i] - 1] = i
	b_pol[b[i] - 1] = i
ans = [0 for _ in range(n)]
for i in range(n):
	k = (a_pol[i] - b_pol[i] + n) % n
	ans[k] += 1
print(max(ans))


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	n = iin()
	a = ain()
	b = ain()
	da = {}
	db = {}
	for i in range(n):
		da[a[i]] = i + 1
		db[b[i]] = i + 1
	suma = {}
	for i in range(1, n + 1):
		if da[i] >= db[i]:
			if da[i] - db[i] in suma:
				suma[da[i] - db[i]] += 1
			else:
				suma[da[i] - db[i]] = 1
		else:
			x = n - db[i] + da[i]
			if x in suma:
				suma[x] += 1
			else:
				suma[x] = 1
	print(max(suma.values()))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = 1
for ab in range(t):
	n = int(input())
	ind = [0] * (n + 1)
	index = [0] * (n + 1)
	m = list(map(int, input().split()))
	x = list(map(int, input().split()))
	for ab in range(n):
		ind[m[ab]] = ab + 1
		index[x[ab]] = ab + 1
	tl = [0 for ac in range(1, n + 1)]
	for tr in range(n):
		tl[tr] = (index[tr + 1] - ind[tr + 1]) % n
	ir = [0] * n
	for xy in tl:
		ir[xy] += 1
	print(max(ir))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mem2 = {}
for i in range(n):
	if b[i] in mem2:
		mem2[b[i]].add(i)
	else:
		mem2[b[i]] = set([i])
iter_dic = {i: 0 for i in range(n)}
for i in range(n):
	if a[i] in mem2:
		for iters in mem2[a[i]]:
			iter_dic[(i - iters) % n] += 1
print(max(iter_dic.values()))


from collections import Counter
from sys import stdin
input = iter(stdin.readlines()).__next__
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ia = [0] * n
ib = [0] * n
for (i, ai) in enumerate(a):
	ia[ai - 1] = i
for (i, bi) in enumerate(b):
	ib[bi - 1] = i
diffs = [a_i - b_i for (a_i, b_i) in zip(ia, ib)]
for (i, diff) in enumerate(diffs):
	if diff < 0:
		diffs[i] = diff + n
counts = Counter(diffs)
print(counts.most_common(1)[0][1])


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
N = INT()
A = [a - 1 for a in LIST()]
B = [b - 1 for b in LIST()]
atoi = {}
for (i, a) in enumerate(A):
	atoi[a] = i
C = Counter()
for (j, b) in enumerate(B):
	C[(atoi[b] - j) % N] += 1
ans = 0
for v in C.values():
	ans = max(ans, v)
print(ans)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
al = [0] * n
bl = [0] * n
for i in range(n):
	al[a[i] - 1] = i + 1
	bl[b[i] - 1] = i + 1
ans = [0] * n
for i in range(n):
	ans[(al[i] - bl[i]) % n] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * (n + 1)
d = [0] * (n + 1)
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
	c[a[i]] = i
	d[b[i]] = i
for i in range(1, n + 1):
	if c[i] < d[i]:
		left[n - d[i] + c[i]] += 1
		right[d[i] - c[i]] += 1
	else:
		left[c[i] - d[i]] += 1
		right[n - c[i] + d[i]] += 1
print(max(max(left), max(right)))


from sys import stdin
from collections import Counter
input = stdin.readline

def main():
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	d = {}
	e = {}
	for i in range(n):
		d[a[i]] = i
		e[b[i]] = i
	l = []
	for i in range(1, n + 1):
		diff = d[i] - e[i]
		if diff < 0:
			diff += n
		l.append(diff)
	d = dict(Counter(l))
	print(max(d.values()))
main()


n = int(input())
a = list(map(int, input().split()))[:n]
b = list(map(int, input().split()))[:n]
pb = [0] * n
pc = [0] * n
for i in range(n):
	pb[b[i] - 1] = i
	pc[a[i] - 1] = i
pa = [0] * n
for i in range(n):
	pa[(pc[i] - pb[i] + n) % n] += 1
print(max(pa))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
right = [0 for i in range(n + 1)]
left = [0 for i in range(n + 1)]
d = {}
for j in range(len(b)):
	d[b[j]] = j
for i in range(n):
	k = d[a[i]] - i
	if k >= 0:
		right[k] = right[k] + 1
		left[n - k] = left[n - k] + 1
	else:
		left[abs(k)] = left[abs(k)] + 1
		right[n - abs(k)] = right[(n - abs(k)) % n] + 1
print(max(max(right), max(left)))


n = int(input())
str1 = {val: id for (id, val) in enumerate(input().split())}
str2 = {val: id for (id, val) in enumerate(input().split())}
dists = {}
for key in str1:
	(d1, d2) = (len(str1) + str1[key] - str2[key], str1[key] - str2[key])
	dist = min(d1, d2) if d2 >= 0 else d1
	if dist not in dists:
		dists[dist] = 0
	dists[dist] += 1
print(max(dists.values()))


no = int(input())
dic = {}
for i in range(no):
	dic[i] = 0
a = input()
a = str(a).split(' ')
a = [int(q) for q in a]
b = input()
b = str(b).split(' ')
b = [int(q) for q in b]
tem = {}
for i in range(len(a)):
	tem[a[i]] = i
for j in range(len(b)):
	k = tem[b[j]] - j
	if k < 0:
		k = no + k
	dic[k] += 1
maxx = -1
for i in range(no):
	maxx = max(dic[i], maxx)
print(maxx)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
n = read_int()
a = list(read_ints())
b = list(read_ints())
cnt = dict()
ad = dict()
bd = dict()
for i in range(n):
	ad[a[i]] = i
	bd[b[i]] = i
for i in range(1, n + 1):
	delta = (bd[i] - ad[i] + n) % n
	if not delta in cnt:
		cnt[delta] = 0
	cnt[delta] += 1
ans = 0
for key in cnt:
	ans = max(ans, cnt[key])
print(ans)


def main():
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	indices1 = [-1] * n
	indices2 = [-1] * n
	for i in range(n):
		a = arr1[i] - 1
		b = arr2[i] - 1
		indices1[a] = i
		indices2[b] = i
	diff = {}
	for i in range(n):
		index1 = indices1[i]
		index2 = indices2[i]
		if index2 >= index1:
			left = index2 - index1
			left *= -1
			right = n - index2 + index1
		else:
			right = index1 - index2
			left = index2 + n - index1
			left *= -1
		if left not in diff.keys():
			diff[left] = 0
		diff[left] += 1
		if right not in diff.keys():
			diff[right] = 0
		diff[right] += 1
	ans = 0
	for i in diff.keys():
		ans = max(ans, diff[i])
	print(ans)
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ind = [0] * n
for i in range(n):
	ind[a[i] - 1] = i
h = [0] * n
g = [0] * n
for i in range(n):
	h[ind[b[i] - 1] - i] += 1
	g[i - ind[b[i] - 1]] += 1
print(max(h + g))


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	a = inlist()
	b = inlist()
	pos_a = [0] * (n + 1)
	for i in range(n):
		pos_a[a[i]] = i
	res = []
	for i in range(n):
		res.append((pos_a[b[i]] - i + n) % n)
	freq = defaultdict(lambda : 0)
	for i in res:
		freq[i] += 1
	count = max(freq.values())
	print(count)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ia = [0] * n
ib = [0] * n
for i in range(n):
	ia[a[i] - 1] = i
	ib[b[i] - 1] = i
ans = dict()
for i in range(n):
	switch = (ia[i] - ib[i]) % n
	res = 0
	ans[switch] = ans.get(switch, 0) + 1
print(max(ans.values()))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
indexes = [0] * (n + 1)
indexes[0] = -1
counter = [0] * n
for i in range(n):
	indexes[l1[i]] = i
for j in range(n):
	if indexes[l2[j]] < j:
		indexes[l2[j]] = indexes[l2[j]] + n - j
	else:
		indexes[l2[j]] -= j
	counter[indexes[l2[j]]] += 1
print(max(counter))


import sys
from collections import Counter
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	n = II()
	aa = LI()
	bb = LI()
	ai = [(a, i) for (i, a) in enumerate(aa)]
	bi = [(b, i) for (i, b) in enumerate(bb)]
	ai.sort()
	bi.sort()
	dd = [(i - j) % n for ((a, i), (b, j)) in zip(ai, bi)]
	dc = Counter(dd)
	print(max(dc.values()))
main()


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
index_a = [0] * n
index_b = [0] * n
for i in range(n):
	index_a[a[i] - 1] = i
	index_b[b[i] - 1] = i
diff = [0] * n
for i in range(n):
	diff[i] = index_a[i] - index_b[i]
	diff[i] = diff[i] % n
occ = Counter(diff)
print(occ.most_common()[0][1])


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
n = nn()
a = lm()
b = lm()
aind = [0] * n
bind = [0] * n
for i in range(n):
	aind[a[i] - 1] = i
	bind[b[i] - 1] = i
diff = dd(int)
for i in range(n):
	diff[(aind[i] - bind[i]) % n] += 1
mdiff = 0
for key in diff:
	mdiff = max(diff[key], mdiff)
print(mdiff)


import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
ls1 = [int(a) for a in input().split()]
ls2 = [int(a) for a in input().split()]
(an1, an2) = ([0] * n, [0] * n)
for i in range(n):
	ss1 = ls1[i] - i - 1
	if ss1 > 0:
		ss1 -= n
	an1[ls1[i] - 1] = ss1
	ss2 = ls2[i] - i - 1
	if ss2 > 0:
		ss2 -= n
	an2[ls2[i] - 1] = ss2
an = []
for i in range(n):
	aa = an1[i] - an2[i]
	if aa < 0:
		aa += n
	an.append(aa)
print(Counter(an).most_common()[0][1])


__multitest = False

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	da = {}
	db = {}
	for i in range(n):
		da[a[i]] = i
		db[b[i]] = i
	dv = {}
	for x in range(n):
		dv[x + 1] = (da[x + 1] - db[x + 1] + n) % n
	da = {}
	ans = 0
	for k in dv.keys():
		da[dv[k]] = da.get(dv[k], 0) + 1
	print(max(da.values()))
t = int(input()) if __multitest else 1
for tt in range(t):
	solve()


import math
from collections import Counter

def i():
	return int(input())

def lii():
	return list(map(int, input().split()))

def lis():
	return list(input())
n = i()
(a, b) = (lii(), lii())
c = []
d_a = {}
d_b = {}
for i in range(n):
	(d_a[a[i]], d_b[b[i]]) = (i, i)
for i in range(n):
	c.append((d_b[a[i]] - d_a[a[i]] + n) % n)
c = Counter(c)
print(max(c.values()))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * n
for i in range(n):
	c[a[i] - 1] += i
	c[b[i] - 1] -= i
for i in c:
	d[i] += 1
print(max(d))


def getMaxMatchingPairs(a, b):
	mapB = {elm: index for (index, elm) in enumerate(b)}
	maxPairs = 0
	countMap = {}
	n = len(a)
	for (i, elm) in enumerate(a):
		dist = mapB[elm] - i if mapB[elm] > i else n + mapB[elm] - i
		countMap[dist] = countMap.get(dist, 0) + 1
		if maxPairs < countMap[dist]:
			maxPairs = countMap[dist]
	return maxPairs
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(getMaxMatchingPairs(a, b))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_dic = {i: j for (j, i) in enumerate(a)}
	b_dic = {i: j for (j, i) in enumerate(b)}
	ans = {}
	for i in range(1, n + 1):
		(x, y) = (a_dic[i], b_dic[i])
		if x <= y:
			ans[i] = y - x
		else:
			ans[i] = n - x + y
	count = {}
	for i in ans.values():
		count[i] = count.get(i, 0) + 1
	ans = max(count.values())
	print(ans)
main()


from sys import stdin
input = stdin.buffer.readline
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
pos_mapping = {}
for (idx, val) in enumerate(brr):
	pos_mapping[val] = idx
ans = {}
mx = 0
for (idx, val) in enumerate(arr):
	j = pos_mapping[val]
	if j <= idx:
		rotation = idx - j
	else:
		rotation = n - j + idx
	ans[rotation] = ans.get(rotation, 0) + 1
	mx = max(mx, ans[rotation])
print(mx)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def solve(n, a, b):
	bi = [0] * (n + 1)
	for i in range(n):
		bi[b[i]] = i
	d = {}
	for i in range(n):
		s = (i - bi[a[i]] + n) % n
		if s not in d:
			d[s] = 1
		else:
			d[s] += 1
	return max(d.values())

def main():
	n = ri()
	a = ria()
	b = ria()
	wi(solve(n, a, b))
main()


from collections import Counter
n = int(input())
d1 = list(map(int, input().split()))
d2 = list(map(int, input().split()))
dm1 = {d1[i]: i for i in range(n)}
dm2 = {d2[i]: i for i in range(n)}
count = {}
for i in range(1, n + 1):
	v = (dm1[i] - dm2[i] + n) % n
	if v not in count:
		count[v] = 1
	else:
		count[v] += 1
maxi = 0
for i in count:
	maxi = max(maxi, count[i])
print(maxi)


def solve():
	T = int(input())
	A = [int(s) for s in input().split(' ')]
	B = [int(s) for s in input().split(' ')]
	lst = [0 for _ in range(len(A))]
	for i in range(len(A)):
		lst[A[i] - 1] += i
		lst[B[i] - 1] -= i
	for i in range(len(lst)):
		lst[i] %= len(A)
	counts = [0 for _ in range(len(A))]
	for num in lst:
		counts[num] += 1
	print(max(counts))
solve()


n = int(input())
a = list(map(int, input().split()))
a1 = [0] * n
inda = a.index(1)
af = a[inda:] + a[:inda]
b = list(map(int, input().split()))
indb = b.index(1)
b1 = [0] * n
bf = b[indb:] + b[:indb]
for i in range(n):
	a1[af[i] - 1] = i
for i in range(n):
	b1[bf[i] - 1] = i
ans = 0
for i in range(n):
	if af[i] == bf[i]:
		ans += 1
l = [0] * n
for i in range(n):
	l[i] = a1[i] - b1[i]
ans = [0] * n
for i in l:
	ans[i] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0] * n
dic = {}
for i in range(n):
	pos[a[i] - 1] = i
for i in range(n):
	c = pos[b[i] - 1] - i
	if c < 0:
		c += n
	dic[c] = dic.get(c, 0) + 1
print(max(dic.values()))


import sys
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(buff_readline())

def read_int_n():
	return list(map(int, buff_readline().split()))

def read_float():
	return float(buff_readline())

def read_float_n():
	return list(map(float, buff_readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, A, B):
	ai = {a: i for (i, a) in enumerate(A)}
	from collections import Counter
	c = Counter()
	for (i, b) in enumerate(B):
		c[(i - ai[b]) % N] += 1
	return c.most_common(n=1)[0][1]

def main():
	N = read_int()
	A = read_int_n()
	B = read_int_n()
	print(slv(N, A, B))
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos_a = [0] * n
pos_b = [0] * n
for i in range(0, n):
	pos_a[a[i] - 1] = i
	pos_b[b[i] - 1] = i
res = []
for i in range(0, n):
	res.append((pos_a[i] - pos_b[i]) % n)
res.sort()
m = 0
cont = 1
for i in range(1, n):
	if res[i - 1] != res[i]:
		m = max(cont, m)
		cont = 1
	else:
		cont += 1
m = max(m, cont)
print(m)


n = int(input())
aa = map(int, input().split())
aid = [0] * (n + 1)
bb = map(int, input().split())
dcount = [0] * n
for (i, a) in enumerate(aa):
	aid[a] = i
for (i, b) in enumerate(bb):
	dcount[(i - aid[b]) % n] += 1
print(max(dcount))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
j = [0 for x in range(n)]
ans = j.copy()
for i in range(n):
	j[a[i] - 1] = i
for i in range(n):
	if j[b[i] - 1] < i:
		ans[b[i] - 1] = n - i + j[b[i] - 1]
	else:
		ans[b[i] - 1] = j[b[i] - 1] - i
ans.sort()
now = 1
res = 0
for i in range(1, n):
	if ans[i] != ans[i - 1]:
		if now > res:
			res = now
		now = 1
	else:
		now += 1
if now > res:
	res = now
print(res)


n = int(input())
a = input()
sp = {}
sp_a = []
ln = 0
for i in enumerate(a.split()):
	sp_a.append(i)
	ln += 1
sp_a.sort(key=lambda x: x[1])
b = input()
sp_b = []
for i in enumerate(b.split()):
	sp_b.append(i)
sp_b.sort(key=lambda x: x[1])
for i in range(ln):
	if sp_a[i][0] < sp_b[i][0]:
		dif = sp_a[i][0] + ln
		sp_a[i] = (dif, sp_a[i][1])
	num = sp.get(sp_a[i][0] - sp_b[i][0], 0)
	sp[sp_a[i][0] - sp_b[i][0]] = num + 1
print(max(sp.values()))


def findPairs(ax, bx):
	diffL = {}
	for i in ax.keys():
		diff = ax[i] - bx[i]
		if diff < 0:
			diff += len(ax)
		if diff not in diffL:
			diffL[diff] = 1
		else:
			diffL[diff] += 1
	print(max(diffL.values()))
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ax = {}
bx = {}
for (idx, ele) in enumerate(a):
	ax[ele] = idx
for (idx, ele) in enumerate(b):
	bx[ele] = idx
findPairs(ax, bx)


t = int(input())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
as1 = [0] * (t + 1)
as2 = [0] * (t + 1)
for j in range(t):
	as1[s1[j]] = j
for k in range(t):
	as2[s2[k]] = k
dic = {}
l1 = []
ma = 1
for i in range(1, t + 1):
	if as2[i] < as1[i]:
		ans = t + as2[i] - as1[i]
	else:
		ans = as2[i] - as1[i]
	if ans not in dic:
		dic[ans] = 1
	else:
		dic[ans] += 1
		ma = max(dic[ans], ma)
print(ma)


import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout
n = int(input())
d1 = defaultdict(int)
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
for i in range(n):
	d1[brr[i]] = i
d2 = defaultdict(int)
for i in range(n):
	temp = 0
	if i > d1[arr[i]]:
		temp = i - d1[arr[i]]
	elif i < d1[arr[i]]:
		temp = n - d1[arr[i]] + i
	d2[temp] += 1
print(max(d2.values()))


import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
seq1 = {}
seq2 = {}
for i in range(n):
	seq1[a[i]] = i
	seq2[b[i]] = i
arr = [0] * n
for i in range(n):
	e = a[i]
	index1 = seq1[e]
	index2 = seq2[e]
	arr[(index1 - index2) % n] += 1
print(max(arr))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
	c[a[i]] = i
d = []
e = []
for i in range(n):
	if c[b[i]] > i:
		x = c[b[i]] - i
		y = n - x
	else:
		y = i - c[b[i]]
		x = n - y
	d.append(x)
	e.append(y)
d.sort()
e.sort()
maxn = 1
cnt = 1
for i in range(n - 1):
	if d[i] == d[i + 1]:
		cnt += 1
	else:
		if maxn < cnt:
			maxn = cnt
		cnt = 1
if maxn < cnt:
	maxn = cnt
cnt = 1
for i in range(n - 1):
	if e[i] == e[i + 1]:
		cnt += 1
	else:
		if maxn < cnt:
			maxn = cnt
		cnt = 1
if maxn < cnt:
	maxn = cnt
print(maxn)


size = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(size):
	A[i] = (A[i], i)
	B[i] = (B[i], i)
A.sort(key=lambda x: x[0])
B.sort(key=lambda x: x[0])
rotations = [0] * size
for i in range(size):
	diff = A[i][1] - B[i][1]
	if diff < 0:
		diff = size + diff
	rotations[diff] += 1
print(max(rotations))


n = int(input())
freq = [0] * n
arr1 = [int(x) for x in input().split()]
arr2 = [int(x) for x in input().split()]
arr1 = sorted(range(len(arr1)), key=lambda k: arr1[k])
arr2 = sorted(range(len(arr2)), key=lambda k: arr2[k])
for x in range(n):
	freq[(arr1[x] - arr2[x]) % n] += 1
print(max(freq))


n = int(input())
arr = list(map(int, input().strip().split()))
brr = list(map(int, input().strip().split()))
d = dict()
e = dict()
for i in range(1, n + 1):
	d[i] = 0
for i in range(n):
	a = arr[i]
	e[a] = i
for j in range(n):
	b = brr[j]
	t = e[b]
	if t > j:
		q = t - j
		d[q] = d[q] + 1
	elif t <= j:
		q = n - j + t
		d[q] = d[q] + 1
out = 0
for i in range(1, n + 1):
	if d[i] >= out:
		out = d[i]
print(out)


from sys import *
setrecursionlimit(100000000)
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
n = int(input())
a = lmi()
b = lmi()
a2 = [0 for i in range(n + 1)]
for i in range(n):
	a2[a[i]] = i + 1
b2 = [0 for i in range(n + 1)]
for i in range(n):
	b2[b[i]] = i + 1
mp = {}
for i in range(1, n + 1):
	tmp = (b2[i] - a2[i]) % n
	if tmp not in mp:
		mp[tmp] = 0
	mp[tmp] += 1
print(mp[max(mp, key=lambda x: mp[x])])


n = int(input())
A = [int(x) for x in input().split(' ')]
B = [int(x) for x in input().split(' ')]
C = [0 for x in range(0, n)]
D = C.copy()
E = C.copy()
E.append(0)
X = []
if len(A) <= 1:
	print(1)
else:
	for i in range(0, n):
		C[A[i] - 1] = i
		D[B[i] - 1] = i
	for i in range(0, n):
		e = (C[i] - D[i]) % n
		E[e] = E[e] + 1
	print(max(E))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[a[i]] = i
ans = [0] * (n + 1)
for j in range(n):
	temp = d[b[j]] - j
	if temp < 0:
		temp = n + temp
	ans[temp] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().rstrip().split()))
b = list(map(int, input().rstrip().split()))
diff = [0 for i in range(n)]
for i in range(n):
	a_el = a[i]
	diff[a_el - 1] += i + n
	b_el = b[i]
	diff[b_el - 1] += -i + n
	diff[a_el - 1] = diff[a_el - 1] % n
	diff[b_el - 1] = diff[b_el - 1] % n
frequency = [0 for i in range(n)]
for i in range(n):
	el = diff[i]
	frequency[el] += 1
print(max(frequency))


n = int(input())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
ll1 = [[l1[i], i] for i in range(n)]
ll2 = [[l2[i], i] for i in range(n)]
ll1 = sorted(ll1, key=lambda x: x[0])
ll2 = sorted(ll2, key=lambda x: x[0])
s = []
for i in range(n):
	s.append((ll1[i][1] - ll2[i][1]) % n)
s.sort()
c = 1
m = 0
a = s[0]
for i in range(1, len(s)):
	if a == s[i]:
		c += 1
	else:
		m = max(m, c)
		c = 1
		a = s[i]
m = max(m, c)
print(m)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l1 = [0] * n
l2 = [0] * n
diff = [0] * n
m = {}
for w in range(n):
	l1[a[w] - 1] = w
for w in range(n):
	l2[b[w] - 1] = w
for w in range(n):
	if l2[w] >= l1[w]:
		diff[w] = l2[w] - l1[w]
	else:
		diff[w] = n - (l1[w] - l2[w])
for w in diff:
	if w not in m:
		m[w] = 1
	else:
		m[w] += 1
ans = -1
for w in m:
	if m[w] > ans:
		ans = m[w]
print(ans)


ll = lambda : list(map(int, input().split()))
s = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
import math
from collections import Counter, defaultdict
x = ii()
a = ll()
b = ll()
d1 = defaultdict(lambda : 0)
d2 = defaultdict(lambda : 0)
d3 = defaultdict(lambda : 0)
for i in range(x):
	d1[b[i]] = i
for i in range(x):
	j = d1[a[i]]
	if j > i:
		d2[i + x - j] += 1
	else:
		d2[i - j] += 1
for i in range(x):
	j = d1[a[i]]
	if j >= i:
		d3[j - i] += 1
	else:
		d3[j + x - i] += 1
m = 0
for i in d2:
	m = max(m, d2[i])
for i in d3:
	m = max(m, d3[i])
print(m)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p = a.copy()
for (i, aa) in enumerate(a):
	p[aa - 1] = i
for (i, bb) in enumerate(b):
	b[i] = (p[bb - 1] + n - i) % n
b = Counter(b)
print(max(b.values()))


R = lambda : map(int, input().split())
n = int(input())
a = R()
b = R()
from collections import defaultdict
max_match = -1
ind = {}
dis = defaultdict(int)
for (i, el) in enumerate(a):
	ind[el] = i
for (i, el) in enumerate(b):
	if i - ind[el] < 0:
		d = -(i - ind[el])
	else:
		d = n - i + ind[el]
	dis[d] += 1
	max_match = max(max_match, dis[d])
print(max_match)


def solve(n, a, b):
	ixs = [None] * (n + 1)
	for (i, v) in enumerate(a):
		ixs[v] = i
	shifts = [0] * n
	for (i, v) in enumerate(b):
		base = i - ixs[v]
		if base < 0:
			base += n
		shifts[base] += 1
	return max(shifts)
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
print(solve(n, a, b))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[a[i]] = i
dc = {}
dac = {}
for i in range(n):
	x = dic[b[i]]
	c = 0
	ac = 0
	if x >= i:
		c = x - i
		ac = n - (x - i)
	else:
		ac = i - x
		c = n - (i - x)
	try:
		dc[c] += 1
	except:
		dc[c] = 1
	try:
		dac[ac] += 1
	except:
		dac[ac] = 1
maxx = 0
for i in dc:
	maxx = max(maxx, dc[i])
for i in dac:
	maxx = max(maxx, dac[i])
print(maxx)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = []
l4 = []
z = 0
from collections import defaultdict, Counter
d1 = defaultdict(int)
d2 = defaultdict(int)
for j in range(n):
	d1[l1[j]] = j
	d2[l2[j]] = j
for j in range(1, n + 1):
	a = d1[j]
	b = d2[j]
	if a > b:
		l3.append(b - a)
		l4.append(n - a + b)
	elif a < b:
		l3.append(n - b + a)
		l4.append(b - a)
	else:
		z += 1
c1 = Counter(l3)
c2 = Counter(l4)
(a, b) = (0, 0)
for (x, y) in c1.most_common(1):
	a = y
for (x, y) in c2.most_common(1):
	b = y
print(max(a, b, z))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for (i, e) in enumerate(a):
	d[e] = i
for (i, e) in enumerate(b):
	d[e] -= i
	if d[e] < 0:
		d[e] += n
v = d.values()
from collections import Counter
c = Counter(v)
print(max(c.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
shift = [0] * (1 + n)
(ida, idb) = ([0] * (1 + n), [0] * (1 + n))
for i in range(n):
	ida[a[i]] = i
	idb[b[i]] = i
for i in range(1, 1 + n):
	shift[(ida[i] - idb[i]) % n] += 1
print(max(shift))


import math

def facts(n):
	ans = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			ans.append(i)
			ans.append(n // i)
	ans = sorted(list(dict.fromkeys(ans)))
	if ans[-1] == n:
		ans = ans[:-1]
	return ans
n = int(input())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
pos = [i for i in range(n + 1)]
d1 = {}
d2 = {}
for i in range(n):
	pos[p1[i]] = i
for i in range(n):
	p = pos[p2[i]]
	v2 = p - i
	if v2 < 0:
		v2 += n
	if v2 not in d2:
		d2[v2] = 1
	else:
		d2[v2] += 1
print(max(d2.values()))


n = int(input())
lis1 = list(map(int, input().split()))
lis2 = list(map(int, input().split()))
m = [0 for i in range(n)]
for (j, i) in enumerate(lis2):
	m[i - 1] = j
lis = [0 for i in range(n)]
for (i, k) in enumerate(lis1):
	ind = m[k - 1]
	if ind >= i:
		lis[ind - i] += 1
	else:
		lis[n - i + ind] += 1
print(max(lis))


n = int(input())
(a, b, ans, aa, bb) = (list(map(int, input().split())), list(map(int, input().split())), [0] * n, [0] * n, [0] * n)
for i in range(n):
	aa[a[i] - 1] = i
	bb[b[i] - 1] = i
for i in range(n):
	if aa[i] - bb[i] >= 0:
		val = aa[i] - bb[i]
	else:
		val = aa[i] - bb[i] + n
	ans[val] += 1
print(max(ans))


from collections import defaultdict
d = defaultdict(list)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
	d[a[i]].append(i)
for i in range(n):
	d[b[i]].append(i)
cnt = [0 for x in range(n)]
ans = 0
for (key, val) in d.items():
	dis = -1
	if val[0] < val[1]:
		dis = n - (val[1] - val[0])
	else:
		dis = val[0] - val[1]
	cnt[dis] += 1
for i in range(n):
	ans = max(ans, cnt[i])
print(ans)


from collections import Counter
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
posA = {}
for (i, el) in enumerate(A):
	posA[el] = i
cc = Counter()
for (i, el) in enumerate(B):
	diff = i - posA[el]
	if diff < 0:
		diff += N
	cc[diff] += 1
print(cc.most_common()[0][1])


import sys

def input():
	return sys.stdin.readline().rstrip()
n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) - 1 for i in input().split()]
initial = [None for i in range(n)]
final = [None for i in range(n)]
for (i, el) in enumerate(a):
	initial[el] = i
for (i, el) in enumerate(b):
	final[el] = i
count = [0 for i in range(n)]
for el in range(n):
	count[(initial[el] - final[el]) % n] += 1
print(max(count))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n = int(input())
fperm = list(map(int, input().split()))
sperm = list(map(int, input().split()))
diu = [0] * n
for i in range(n):
	diu[fperm[i] - 1] += i
	diu[sperm[i] - 1] -= i
out = [0] * n
for v in diu:
	out[v] += 1
print(max(out))


from collections import Counter
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
temp = [-1 for i in range(n)]
m = 0
d = {}
for i in range(n):
	if temp[a[i] - 1] == -1:
		temp[a[i] - 1] = i
	else:
		temp[a[i] - 1] = n - (i - temp[a[i] - 1])
	if temp[b[i] - 1] == -1:
		temp[b[i] - 1] = i
	else:
		temp[b[i] - 1] = i - temp[b[i] - 1]
for i in range(n):
	if temp[i] not in d:
		d[temp[i]] = 1
	else:
		d[temp[i]] += 1
	m = max(m, d[temp[i]])
print(m)


from copy import *
import math as mt

def mostFrequent(arr, n):
	Hash = dict()
	for i in range(n):
		if arr[i] in Hash.keys():
			Hash[arr[i]] += 1
		else:
			Hash[arr[i]] = 1
	max_count = 0
	res = -1
	for i in Hash:
		if max_count < Hash[i]:
			res = i
			max_count = Hash[i]
	return res
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
l = []
for i in range(len(a)):
	d[a[i]] = i
for i in range(len(b)):
	diff = i - d[b[i]]
	if diff == len(a) - 1:
		diff = [1]
		l.extend(diff)
	elif diff == -(len(a) - 1):
		diff = [len(a) - 1]
		l.extend(diff)
	elif diff <= 0:
		l.append(d[b[i]] - i)
	else:
		l.append(len(a) - i + d[b[i]])
dad = mostFrequent(l, n)
print(l.count(dad))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ass = [0] * n
for i in range(n):
	ass[a[i] - 1] = i
m = [0] * n
mx = 0
for i in range(n):
	x = i - ass[b[i] - 1]
	x %= n
	m[x] += 1
	mx = max(mx, m[x])
print(mx)


(n, m) = (int(input()), set())
(s, v, d, a) = (input().split(), input().split(), dict(), dict())
for i in range(n):
	d[s[i]] = i
for i in range(n):
	if i - d[v[i]] < 0:
		a[n + i - d[v[i]]] = a.get(n + i - d[v[i]], 0) + 1
	else:
		a[i - d[v[i]]] = a.get(i - d[v[i]], 0) + 1
for i in a:
	m.add(a[i])
print(max(m))


def input_as_list():
	return list(map(int, input().split()))
[n] = input_as_list()
a = input_as_list()
b = input_as_list()
mapping = dict()
for i in range(n):
	mapping[b[i]] = i
diffs = dict()
for i in range(n):
	key = i - mapping[a[i]]
	if key < 0:
		key = n + key
	if key in diffs:
		diffs[key] += 1
	else:
		diffs[key] = 1
solution = 0
for k in diffs:
	if diffs[k] > solution:
		solution = diffs[k]
print(solution)


n = int(input())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
right = [0] * (n + 1)
dicti = {}
for i in range(n):
	dicti[list1[i]] = i
for i in range(n):
	k = dicti[list2[i]] - i
	if k > 0:
		right[k] += 1
	else:
		right[n + k] += 1
print(max(right))


n = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
da = dict()
db = dict()
i = 0
for el in a:
	da[el] = i
	i += 1
i = 0
for el in b:
	db[el] = i
	i += 1
delta = dict()
for i in range(1, n + 1):
	if db[i] - da[i] not in delta:
		delta[db[i] - da[i]] = 1
	else:
		delta[db[i] - da[i]] += 1
c = 0
for key in delta:
	if key - n in delta and delta[key] + delta[key - n] > c:
		c = delta[key] + delta[key - n]
	elif delta[key] > c:
		c = delta[key]
print(c)


def maxPairs(arr1, arr2):
	n = len(arr1)
	index = dict()
	for i in range(n):
		index[arr2[i]] = i
	freq = dict()
	for i in range(n):
		if index[arr1[i]] > i:
			rightShiftsRequired = n - 1 - index[arr1[i]] + 1 + i
		else:
			rightShiftsRequired = i - index[arr1[i]]
		freq[rightShiftsRequired] = freq.get(rightShiftsRequired, 0) + 1
	maxFreq = None
	for i in freq:
		if maxFreq is None or freq[i] > maxFreq:
			maxFreq = freq[i]
	ans = 2
	return maxFreq
temp = input('').strip().split()
n = int(temp[0])
arr1 = list()
arr2 = list()
temp = input('').strip().split()
for i in range(n):
	arr1.append(int(temp[i]))
temp = input('').strip().split()
for i in range(n):
	arr2.append(int(temp[i]))
print(maxPairs(arr1, arr2))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
h = [0] * n
for i in range(n):
	h[a[i] - 1] = i
l = []
for i in range(n):
	x = h[b[i] - 1] - i
	if x < 0:
		x = n + x
	l.append(x)
o = [0] * (n + 1)
for i in range(n):
	o[l[i]] += 1
print(max(o))


from sys import stdin, stdout
from collections import defaultdict as dd
from collections import Counter as ctr
n = int(stdin.readline().strip())
a = list(map(int, stdin.readline().strip().split()))
b = list(map(int, stdin.readline().strip().split()))
d = dd(int)
ans = []
for i in range(n):
	d[a[i]] = i
for i in range(n):
	ans.append((i - d[b[i]] + n) % n)
p = ctr(ans).most_common()[0][1]
stdout.write(str(p) + '\n')


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
idx = dict()
for i in range(n):
	idx[a[i]] = i + 1
cnt = dict()
for i in range(n):
	diff = idx[b[i]] - (i + 1)
	if diff < 0:
		diff += n
	if diff in cnt:
		cnt[diff] += 1
	else:
		cnt[diff] = 1
print(max(cnt.values()))


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools
import math
import operator
import string
ALPHABET = string.ascii_lowercase
DIGITS = string.digits

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def solve():
	n = read_int()
	a = read_int_arr()
	b = read_int_arr()
	shifts = collections.defaultdict(int)
	idxs = collections.defaultdict(int)
	for (i, v) in enumerate(a):
		idxs[v] = i
	for (i, v) in enumerate(b):
		shifts[(i - idxs[v]) % n] += 1
	print(max(shifts.values()))

def main():
	T = 1
	for _ in range(T):
		solve()
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
li = []
d = {}
di = {}
maxi = 0
k = 0
for i in range(n):
	if a[i] in di.keys():
		di[a[i]][0] = i
	else:
		di[a[i]] = [0, 0]
		di[a[i]][0] = i
	if b[i] in di.keys():
		di[b[i]][1] = i
	else:
		di[b[i]] = [0, 0]
		di[b[i]][1] = i
for i in di.keys():
	if di[i][0] - di[i][1] < 0:
		value = n - (di[i][1] - di[i][0])
	else:
		value = di[i][0] - di[i][1]
	if value in d.keys():
		d[value] = d[value] + 1
		if maxi < d[value]:
			maxi = d[value]
	else:
		d[value] = 1
		if maxi < d[value]:
			maxi = d[value]
print(maxi)


x = int(input())
I1 = [item for item in map(int, input().split())]
I2 = [item for item in map(int, input().split())]
sign1 = [0] * x
for j in range(x):
	sign1[I1[j] - 1] += j
	sign1[I2[j] - 1] -= j
final = [0] * x
for k in range(x):
	final[sign1[k] % x] += 1
print(max(final))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
posA = {}
for i in range(n):
	posA[a[i]] = i
ans = {}
for i in range(n):
	moves = posA[b[i]] - i if posA[b[i]] >= i else n - i + posA[b[i]]
	if moves in ans:
		ans[moves] += 1
	else:
		ans[moves] = 1
high = 0
for key in ans:
	high = max(ans[key], high)
print(high)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
p = [0] * n
q = [0] * n
for i in range(n):
	p[a[i] - 1] = i
	q[b[i] - 1] = i
for i in range(n):
	c[(p[i] - q[i]) % n] += 1
print(max(c))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dp = [0 for _ in range(n + 1)]
	for i in range(n):
		dp[a[i]] = i
	offset = [0 for _ in range(n)]
	for i in range(n):
		off = dp[b[i]] - i
		if off < 0:
			off = n + off
		offset[off] += 1
	mx = -1
	for i in range(n):
		mx = max(mx, offset[i])
	print(mx)
	return
main()


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = dd(int)
	for i in range(n):
		d[a[i]] = i
	b = b + b
	ans = 0
	x = dd(int)
	for i in range(len(b)):
		q = i - d[b[i]]
		x[q] += 1
		if x[q] > ans:
			ans = x[q]
	print(ans)


import sys, collections, math

def in_out():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def check(a, b):
	count = 0
	for i in range(0, len(a)):
		if a[i] == b[i]:
			count += 1
	return count
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = check(a, b)
A = [0] * n
B = [0] * n
dic = {}
for i in range(n):
	A[a[i] - 1] = i
	B[b[i] - 1] = i
for i in range(0, n):
	idx = (A[i] - B[i]) % n
	dic[idx] = dic.get(idx, 0) + 1
print(max(sorted(dic.values())))


from math import sqrt
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [0] * n
d = [0] * n
for i in range(n):
	c[a[i] - 1] = i
for i in range(n):
	k = c[b[i] - 1] - i
	if k < 0:
		k += n
	d[k] += 1
m = 0
for i in d:
	m = max(i, m)
print(m)


n = int(input())
d1 = {}
d2 = {}
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
d3 = {}
for i in range(n):
	d1[l1[i]] = i
	d2[l2[i]] = i
for i in range(n):
	if d1[i + 1] - d2[i + 1] in d3 and d1[i + 1] - d2[i + 1] > 0:
		d3[d1[i + 1] - d2[i + 1]] = d3[d1[i + 1] - d2[i + 1]] + 1
	elif n + d1[i + 1] - d2[i + 1] in d3:
		d3[n + (d1[i + 1] - d2[i + 1])] = d3[n + (d1[i + 1] - d2[i + 1])] + 1
	elif d1[i + 1] - d2[i + 1] > 0:
		d3[d1[i + 1] - d2[i + 1]] = 1
	else:
		d3[n + (d1[i + 1] - d2[i + 1])] = 1
z = float('-inf')
for i in d3:
	z = max(z, d3[i])
print(z)


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):
	for _ in range(1):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		ls = [0] * n
		rs = [0] * n
		pos = [0] * n
		for i in range(n):
			pos[b[i] - 1] = i
			a[i] -= 1
		for i in range(n):
			if pos[a[i]] < i:
				ls[pos[a[i]] + n - i] += 1
			else:
				ls[pos[a[i]] - i] += 1
		print(max(ls))


n = int(input())
a = [int(p) for p in input().split()]
b = [int(p) for p in input().split()]
index = {}
for i in range(len(a)):
	index[a[i]] = i
diff = {}
for i in range(len(b)):
	d = index[b[i]] - i
	if d < 0:
		d = n + d
	try:
		diff[d] += 1
	except KeyError:
		diff[d] = 1
print(max(diff.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
indexa = [0 for i in range(n + 1)]
indexb = [0 for i in range(n + 1)]
for i in range(n):
	indexa[a[i]] = i
	indexb[b[i]] = i
pairs = [0 for i in range(n)]
for num in range(1, n + 1):
	k = indexa[num] - indexb[num]
	if k < 0:
		k += n
	pairs[k] += 1
print(max(pairs))


import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
table = [0] * (N + 1)
for i in range(N):
	table[a[i]] = i
for i in range(N):
	table[b[i]] = (i - table[b[i]]) % N
res = [0] * (N + 1)
for i in range(1, N + 1):
	res[table[i]] += 1
print(max(res))


def solve(a, b):
	d = {}
	for i in range(len(b)):
		d[b[i]] = i
	arr = []
	for i in range(len(a)):
		val = d[a[i]]
		if val >= i:
			arr.append(val - i)
		else:
			arr.append(len(a) - i + val)
	d = {}
	for i in arr:
		d[i] = d.get(i, 0) + 1
	ans = 0
	for key in d:
		ans = max(ans, d[key])
	return ans
n = input()
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
print(solve(a, b))


n = int(input())
a = [int(i) - 1 for i in input().split()]
s = input().split()
ans = dict()
b = [0 for i in range(n)]
for i in range(n):
	b[int(s[i]) - 1] = i
	ans[i] = 0
for i in range(n):
	if i >= b[a[i]]:
		ans[i - b[a[i]]] += 1
	else:
		ans[n - b[a[i]] + i] += 1
m = 0
for i in ans.keys():
	if ans[i] > ans[m]:
		m = i
print(ans[m])


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0] * n
for i in range(n):
	pos[a[i] - 1] = i
store = defaultdict(int)
for i in range(n):
	cur = pos[b[i] - 1] - i
	if cur < 0:
		cur += n
	store[cur] += 1
mx = 0
for k in store:
	if store[k] > mx:
		mx = store[k]
print(mx)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
index = defaultdict(lambda : 0)
for i in range(n):
	index[a[i]] = i
ans = 0
shift = defaultdict(lambda : 0)
for i in range(n):
	temp = index[b[i]]
	if temp <= i:
		shift[i - temp] += 1
		ans = max(ans, shift[i - temp])
	else:
		right = temp - i
		shift[n - right] += 1
		ans = max(ans, shift[n - right])
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
db = {b[i]: i for i in range(n)}
l = {}
for i in range(n):
	try:
		l[(i - db[a[i]] + n) % n] += 1
	except KeyError:
		l[(i - db[a[i]] + n) % n] = 1
ans = max(l.values())
print(ans)


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [a - 1 for a in A]
B = [b - 1 for b in B]
d = {}
for (i, b) in enumerate(B):
	d[b] = i
D = {}
for (i, a) in enumerate(A):
	j = i - d[a]
	if j < 0:
		j += n
	if j not in D:
		D[j] = 1
	else:
		D[j] += 1
ans = max(D.values())
print(ans)


ind = [-1 for i in range(200005)]
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
	ind[a[i]] = i
d = dict()
for i in range(n):
	x = ind[b[i]]
	z = 0
	if x >= i:
		z = x - i
	else:
		z = n - i + x
	d[z] = d.get(z, 0) + 1
l = d.values()
print(max(l))


from collections import defaultdict
n = int(input())
arr = [0 for i in range(n)]
brr = [0 for i in range(n)]
temp = list(map(int, input().split()))
for i in range(n):
	arr[temp[i] - 1] = i
temp = list(map(int, input().split()))
for i in range(n):
	brr[temp[i] - 1] = i
d = defaultdict(int)
for i in range(n):
	if brr[i] <= arr[i]:
		d[arr[i] - brr[i]] += 1
	else:
		val1 = n - brr[i] - 1
		val2 = arr[i] + 1
		d[val1 + val2] += 1
ans = 1
for i in d:
	ans = max(ans, d[i])
print(ans)


import math

def solve(n, a, b):
	ind_a = [0] * n
	ind_b = [0] * n
	diff = [0] * n
	for i in range(0, n):
		a[i] -= 1
		b[i] -= 1
		ind_a[a[i]] = i
		ind_b[b[i]] = i
	for i in range(n):
		x = ind_a[i] - ind_b[i]
		if x < 0:
			x += n
		diff[x] += 1
	print(max(diff))
	return
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
solve(n, a, b)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	n = ii()
	a = li()
	b = li()
	f = [0] * (n + 1)
	for i in range(n):
		f[a[i]] = i
	x = []
	for i in range(n):
		if f[b[i]] <= i:
			x.append(i - f[b[i]])
		else:
			x1 = n - f[b[i]] + (i - 0)
			x.append(x1)
	f = [0] * (n + 1)
	for i in x:
		f[i] += 1
	x1 = max(f)
	print(min(x1, n))
solve()


from sys import stdin
input = stdin.readline
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
elt_to_pos1 = [0] * n
elt_to_pos2 = [0] * n
for i in range(n):
	elt_to_pos1[l1[i] - 1] = i
	elt_to_pos2[l2[i] - 1] = i
dupa = [0] * n
for i in range(n):
	if elt_to_pos1[i] <= elt_to_pos2[i]:
		dupa[elt_to_pos2[i] - elt_to_pos1[i]] += 1
	else:
		dupa[n - elt_to_pos1[i] + elt_to_pos2[i]] += 1
print(max(dupa))


r = lambda : map(int, input().split())
n = int(input())
a = {}
b = {}
for (x, i, j) in zip(range(n), r(), r()):
	a[i] = x
	b[j] = x
g = {}
for i in range(1, n + 1):
	o = (b[i] - a[i]) % n
	g[o] = g[o] + 1 if g.get(o) else 1
print(max((g[i] for i in g)))


def solve(n, a, b):
	indexOfB = [0] * n
	right = [0 for _ in range(n)]
	left = [0 for _ in range(n)]
	for i in range(n):
		indexOfB[b[i] - 1] = i
	for i in range(n):
		k = i - indexOfB[a[i] - 1]
		if k < 0:
			right[abs(k)] += 1
			left[n - abs(k)] += 1
		elif k == 0:
			right[0] += 1
			left[0] += 1
		else:
			right[n - k] += 1
			left[k] += 1
	return max(max(right), max(left))
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(solve(n, a, b))


n = int(input())
pos = [0] * (n + 1)
dp = [0] * (n + 1)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(0, len(a)):
	pos[a[i]] = i
for i in range(0, len(b)):
	tt = pos[b[i]]
	dp[(tt - i) % n] += 1
print(max(dp))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	off = {}
	pos = [0 for _ in range(n)]
	for i in range(n):
		pos[a[i] - 1] = i
	for i in range(n):
		cur = pos[b[i] - 1] - i
		if cur < 0:
			cur += n
		if cur in off:
			off[cur] += 1
		else:
			off[cur] = 1
	ans = 0
	for (key, value) in off.items():
		ans = max(ans, value)
	print(ans)
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
first = [0] * n
for i in range(n):
	first[a[i] - 1] += i
	first[b[i] - 1] -= i
second = [0] * n
for i in first:
	second[i] += 1
print(max(second))


import sys
from sys import stdin
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
n = int(input())
A = Neo()
B = Neo()
mp1 = {}
mp2 = {}
for i in range(n):
	mp1[B[i]] = i
for i in range(n):
	if mp1[A[i]] >= i:
		if mp2.get(mp1[A[i]] - i, 0) == 0:
			mp2[mp1[A[i]] - i] = 1
		else:
			mp2[mp1[A[i]] - i] += 1
	elif mp2.get(n - i + mp1[A[i]], 0) == 0:
		mp2[n - i + mp1[A[i]]] = 1
	else:
		mp2[n - i + mp1[A[i]]] += 1
print(max(mp2.values()))


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	n = int(stdin.readline())
	a = [int(x) - 1 for x in stdin.readline().split()]
	b = [int(x) - 1 for x in stdin.readline().split()]
	posa = [0] * n
	posb = [0] * n
	for i in range(n):
		posa[a[i]] = i
		posb[b[i]] = i
	res = 0
	stats = [0] * n
	for k in range(n):
		i = posa[k]
		j = posb[k]
		stats[(j - i + n) % n] += 1
	res = max(stats)
	stdout.write('%d\n' % res)
	return 0
main()


from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
val_to_idx = {}
counter = Counter()
for (idx, val) in enumerate(a):
	val_to_idx[val] = idx
for (idx, val) in enumerate(b):
	distance = val_to_idx[val] - idx
	distance = distance + n if distance < 0 else distance
	counter[distance] += 1
print(counter.most_common()[0][1])


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def matching(a, b, d):
	left = C()
	right = C()
	n = len(a)
	for i in range(n):
		index = d[b[i]]
		if index > i:
			left[index - i] += 1
			right[n - index + i] += 1
		else:
			left[index + n - i] += 1
			right[i - index] += 1
	return max(left.most_common(1)[0][1], right.most_common(1)[0][1])

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	da = {}
	db = {}
	for i in range(n):
		da[a[i]] = i
		db[b[i]] = i
	ans = max(matching(a, b, da), matching(b, a, db))
	print(ans)
main()


import sys
input = sys.stdin.readline
n = int(input())
l1 = list(map(int, input().split(' ')))
l2 = list(map(int, input().split(' ')))
d = {}
for i in range(n):
	d[l2[i]] = i
lshift = {}
rshift = {}
for i in range(n):
	j = d[l1[i]]
	if j > i:
		rshift[j - i] = rshift.get(j - i, 0) + 1
		lshift[i + n - j] = lshift.get(i + n - j, 0) + 1
	else:
		rshift[j + n - i] = rshift.get(j + n - i, 0) + 1
		lshift[i - j] = lshift.get(i - j, 0) + 1
m1 = 0
for i in lshift:
	m1 = max(lshift[i], m1)
m2 = 0
for i in rshift:
	m2 = max(rshift[i], m2)
print(max(m1, m2))


import sys
from collections import Counter
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
(k, kb) = (0, 0)
a_i = {}
b_i = {}
index = {}
for (ind, key) in enumerate(a):
	if key not in a_i:
		a_i[key] = 0
	a_i[key] = ind
for (ind, key) in enumerate(b):
	if key not in a_i:
		b_i[key] = 0
	b_i[key] = ind
for (key, val) in a_i.items():
	if key in b_i:
		k = val - b_i[key]
		if k < 0:
			k = k + n
		if k not in index:
			index[k] = 0
		index[k] += 1
print(Counter(index).most_common()[0][1])


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
pos = [0] * n
moves = [0] * n
for i in range(n):
	pos[a[i] - 1] = i + 1
for i in range(n):
	if pos[b[i] - 1] > i + 1:
		moves[n - pos[b[i] - 1] + i + 1] += 1
	else:
		moves[i + 1 - pos[b[i] - 1]] += 1
print(max(moves))


(lista, ansR, ansL) = ([], [], [])

def f(i, n):
	right = (lista[i][1] - lista[i][0] + n) % n
	left = (lista[i][0] - lista[i][1] + n) % n
	ansR[right] += 1
	ansL[left] += 1

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(0, n):
		lista.append([None, None])
		ansR.append(0)
		ansL.append(0)
	for i in range(0, n):
		lista[a[i] - 1][0] = i
		lista[b[i] - 1][1] = i
	for i in range(0, n):
		f(i, n)
	r = 0
	for i in range(0, n):
		r = max(r, max(ansL[i], ansR[i]))
	print(r)
main()


n = int(input())
transposes = [list(map(lambda el: int(el) - 1, input().split())), list(map(lambda el: int(el) - 1, input().split()))]
poses = [[0 for i in range(n)], [0 for i in range(n)]]
for pos_i in range(2):
	for i in range(n):
		poses[pos_i][transposes[pos_i][i]] = i
overlays = [0 for i in range(n)]
for i in range(n):
	dif = poses[0][i] - poses[1][i]
	if dif < 0:
		dif += n
	overlays[dif] += 1
print(max(overlays))


import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
mod = 1000000007
ch = 'abcdefghijklmnopqrstuvwxyz'
lcm = lambda a, b: a * b // gcd(a, b)
setbit = lambda x: bin(x)[2:].count('1')
input = lambda : sys.stdin.readline()

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	for i in range(n):
		d[a[i]] = i
	track = defaultdict(lambda : 0)
	for i in range(n):
		curr = d[b[i]] - i
		if curr < 0:
			curr += n
		track[curr] += 1
	ans = 0
	for (k, v) in track.items():
		ans = max(ans, v)
	print(ans)
solve()


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A, B):
	valToIndex = {}
	for (i, x) in enumerate(A):
		valToIndex[x] = i
	rotateToMatches = defaultdict(int)
	for (i, x) in enumerate(B):
		j = valToIndex[x]
		rotateToMatches[(j - i) % N] += 1
	return max(rotateToMatches.values())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N,) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = solve(N, A, B)
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b_index = [-1] * (n + 1)
for i in range(n):
	b_index[b[i]] = i
c = []
for i in range(n):
	c.append((b_index[a[i]] - i) % n)
count = [0] * (n + 1)
for i in range(n):
	count[c[i]] += 1
print(max(count))


n = int(input())
l = list(map(int, input().split(' ')))
m = list(map(int, input().split(' ')))
dic = {}
tt = {}
for x in range(n):
	tt[m[x]] = x
for x in range(n):
	t = tt[l[x]]
	if (t - x) % n not in dic.keys():
		dic[(t - x) % n] = 1
	else:
		dic[(t - x) % n] = dic[(t - x) % n] + 1
print(max(dic.values()))


import sys
from collections import defaultdict as dc
input = sys.stdin.readline
N = int(input())
L1 = list(map(int, input().split()))
L2 = list(map(int, input().split()))
d = dc(lambda : 0)
d2 = dc(lambda : 0)
for i in range(N):
	d[L2[i]] = i
for i in range(N):
	DIFFERENCE = d[L1[i]] - i
	if DIFFERENCE < 0:
		DIFFERENCE = DIFFERENCE + N
	d2[DIFFERENCE] += 1
res = 0
for (i, j) in d2.items():
	res = max(res, j)
print(res)


import sys
import math
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dic_a = {}
dic_b = {}
for (i, num) in enumerate(a):
	dic_a[num] = i
for (j, num) in enumerate(b):
	dic_b[num] = j
arr = [0] * (n + 1)
for num in a:
	if dic_a[num] - dic_b[num] >= 0:
		arr[dic_a[num] - dic_b[num]] += 1
	else:
		arr[n + (dic_a[num] - dic_b[num])] += 1
print(max(arr))


import os
import sys
import time
import math as mt
import pprint
import itertools as it
import operator as op
import bisect as bs
import functools as fn
from collections import deque, defaultdict, OrderedDict, Counter, ChainMap
(maxx, localsys, mod) = (1 << 60, 0, int(1000000000.0 + 7))

def nCr(n, r):
	return reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)

def ceil(n, x):
	return (n + x - 1) // x
(osi, oso) = ('/home/priyanshu/Documents/cp/input.txt', '/home/priyanshu/Documents/cp/output.txt')
if os.path.exists(osi):
	sys.stdin = open(osi, 'r')
	sys.stdout = open(oso, 'w')
input = sys.stdin.readline

def maps():
	return map(int, input().split())

def Kth_beautiful_string():
	for _ in range(int(input())):
		(n, k) = maps()
		arr = ['a'] * n
		for i in range(n - 1, -1, -1):
			if n - i - 1 >= k:
				arr[i] = arr[i + (n - i - 1) - (k - 1)] = 'b'
				print(''.join(arr))
				break
			k -= n - i - 1

def subhate():
	for _ in range(*maps()):
		s = input().rstrip('\n')
		(s1, s0) = (0, 0)
		for i in s:
			s1 += i == '1'
			s0 += i == '0'
		(p1, p0) = (0, 0)
		ans = maxx
		for i in s:
			p1 += i == '1'
			p0 += i == '0'
			s1 -= i == '1'
			s0 -= i == '0'
			ans = min(ans, p1 + s0, p0 + s1)
		print(ans)
(n,) = maps()
a = [*maps()]
b = [*maps()]
(d, cnt) = ({b[i]: i for i in range(n)}, {})
for i in range(n):
	x = d[a[i]] - i
	if x < 0:
		x += n
	cnt[x] = cnt.get(x, 0) + 1
print(max((cnt[v] for v in cnt)))


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d = [0] * (n + 1)
	for i in range(n):
		d[b[i]] = i
	val = []
	for i in range(n):
		if i - d[a[i]] < 0:
			val.append(n - abs(i - d[a[i]]))
		else:
			val.append(i - d[a[i]])
	d = {}
	for i in range(n):
		if val[i] not in d:
			d[val[i]] = 0
		d[val[i]] += 1
	print(max(d.values()))


import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
dic1 = collections.defaultdict(list)
dic2 = collections.defaultdict(list)
for i in range(n):
	dic1[a[i]].append(i)
	dic2[b[i]].append(i)
dic3 = collections.defaultdict(int)
for key in dic1:
	pos1 = dic1[key]
	pos2 = dic2[key]
	for p1 in pos1:
		for p2 in pos2:
			diff = p2 - p1
			if diff < 0:
				diff += n
			dic3[diff] += 1
print(max(dic3.values()))


n = int(input())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list()
dict1 = {}
for i in range(n):
	list3.append(0)
	dict1[list1[i]] = i
for i in range(n):
	p = list2[i]
	q = dict1[p]
	if q >= i:
		list3[q - i] += 1
	else:
		list3[n - i + q] += 1
print(max(list3))


import sys
input = sys.stdin.readline
from collections import *
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
idx1 = [-1] * n
idx2 = [-1] * n
for i in range(n):
	idx1[a[i] - 1] = i
for i in range(n):
	idx2[b[i] - 1] = i
cnt = [0] * n
for i in range(n):
	k = (idx1[i] - idx2[i]) % n
	cnt[k] += 1
print(max(cnt))


def readintlst():
	return list(map(int, input().split(' ')))

def readn():
	return int(input())
n = readn()
A = readintlst()
B = readintlst()
ans = 0
import collections
dct = collections.defaultdict(list)
for (i, v) in enumerate(A):
	dct[v].append(i)
for (i, v) in enumerate(B):
	dct[v].append(i)
cnt = collections.defaultdict(int)
for v in dct.values():
	a = v[0] - v[1]
	if a < 0:
		a += n
	cnt[a] += 1
print(max(cnt.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_to_pos = {}
b_to_pos = {}
for i in range(n):
	a_to_pos[a[i]] = i
	b_to_pos[b[i]] = i
diff_count = [0 for i in range(n)]
for a_item in a:
	diff = (a_to_pos[a_item] - b_to_pos[a_item]) % n
	diff_count[diff] += 1
print(max(diff_count))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(a_index, b_index) = ({}, {})
for i in range(n):
	a_index[a[i]] = i
	b_index[b[i]] = i
matches = [0] * n
for ai in a:
	distance = (a_index[ai] - b_index[ai]) % n
	matches[distance] += 1
print(max(matches))


n = int(input())
arr = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
a = dict()
right = dict()
for i in range(n):
	a[arr[i]] = i
for idxB in range(n):
	val = b[idxB]
	idxA = a[val]
	k = idxA - idxB
	if k < 0:
		try:
			right[abs(k)] += 1
		except KeyError:
			right[abs(k)] = 1
	else:
		try:
			right[n - k] += 1
		except KeyError:
			right[n - k] = 1
ans = 1
for (k, v) in right.items():
	ans = max(ans, v)
print(ans)


from collections import defaultdict

def read_list():
	return list(map(int, input().split(' ')))

def print_list(l):
	print(' '.join(map(str, l)))
n = int(input())
(a, b) = (read_list(), read_list())
da = {}
db = {}
for i in range(n):
	da[a[i]] = i
	db[b[i]] = i
dic = defaultdict(int)
for i in range(1, n + 1):
	tmp = da[i] - db[i]
	if tmp < 0:
		tmp += n
	dic[tmp] += 1
print(max(dic.values()))


from sys import *
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = [0] * (n + 1)
for i in range(n):
	d[b[i]] = i
e = [0] * (n + 1)
for i in range(n):
	ind = d[a[i]]
	if ind >= i:
		e[i] = ind - i
	else:
		e[i] = ind + 1 + (n - 1 - i)
d = [0] * n
for i in range(n):
	d[e[i]] += 1
mx = -1
for i in range(n):
	mx = max(mx, d[i])
stdout.write(str(mx) + '\n')


from collections import Counter
length = int(input())
first = list(map(int, input().split()))
second = [0] * length
for (ind, i) in enumerate(map(int, input().split())):
	second[i - 1] = ind
shifts = Counter()
for (ind, i) in enumerate(first):
	i -= 1
	otherind = second[i]
	diff = otherind - ind
	if diff < 0:
		diff = length + diff
	shifts[diff] += 1
print(max(shifts.values()))


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
d = {}
for i in range(0, n):
	d[a[i]] = [i]
for i in range(0, n):
	d[b[i]].append(i)
for i in range(0, n):
	h = d[a[i]][1]
	h = i - h
	if h < 0:
		h += n
	l.append(h)
v = {}
for i in range(0, n):
	if l[i] not in v:
		v[l[i]] = 1
	else:
		v[l[i]] += 1
Keymax = max(v, key=v.get)
print(v[Keymax])


n = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
A1 = [0] * (n + 1)
B1 = [0] * (n + 1)
for i in range(n):
	A1[A[i]] = i
	B1[B[i]] = i
ans = 0
D = [0] * n
for i in range(1, n + 1):
	diff = A1[i] - B1[i]
	if diff < 0:
		diff += n
	D[diff] += 1
	ans = max(ans, D[diff])
print(ans)


def solve():
	n = int(input())
	a = [0] + list(map(int, input().split()))
	b = [0] + list(map(int, input().split()))
	ind = [0 for _ in range(n + 5)]
	ans = [0 for _ in range(n + 5)]
	for (i, v) in enumerate(a):
		ind[v] = i
	for i in range(1, n + 1):
		ans[(ind[b[i]] - i + n) % n] += 1
	print(max(ans))
solve()


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dct = {}
for i in range(n):
	dct[a[i]] = i
lst = []
for j in range(n):
	if b[j] in dct.keys():
		if dct[b[j]] < j:
			x = n - j + dct[b[j]]
		else:
			x = dct[b[j]] - j
		lst.append(x)
dct1 = Counter(lst)
print(dct1.most_common()[0][1])


def main():
	n = int(input())
	shifts = [0] * n
	for (i, j) in zip(*[sorted(range(n), key=list(map(int, input().split())).__getitem__) for _ in 'ab']):
		shifts[i - j] += 1
	print(max(shifts))
main()


def count(arr1, arr2):
	value = 0
	for i in range(len(arr1)):
		if arr1[i] == arr2[i]:
			value += 1
	return value
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos_in_a = dict()
for j in range(n):
	pos_in_a[a[j]] = j
num_of_shifts = dict()
for i in range(0, n):
	num_of_shifts[i] = []
for i in range(n):
	difference = pos_in_a[b[i]] - i
	if difference >= 0:
		num_of_shifts[difference].append(b[i])
	else:
		num_of_shifts[n + difference].append(b[i])
final_ans = [-1, -1]
for key in num_of_shifts.keys():
	if len(num_of_shifts[key]) > final_ans[1]:
		final_ans[0] = key
		final_ans[1] = len(num_of_shifts[key])
print(final_ans[1])


n = int(input())
a = [int(i) - 1 for i in input().split()]
b = [int(i) - 1 for i in input().split()]
aindex = [0] * n
for i in range(n):
	aindex[a[i]] = i
bindex = [0] * n
for i in range(n):
	bindex[b[i]] = i
shifts = [0] * n
for i in range(n):
	if a[i] == b[i]:
		shifts[0] += 1
	elif i < bindex[a[i]]:
		shifts[bindex[a[i]] - i] += 1
	elif i > bindex[a[i]]:
		shifts[n - i + bindex[a[i]]] += 1
print(max(shifts))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = list(zip(a, range(n)))
b = list(zip(b, range(n)))
a.sort()
b.sort()
import math
ans = [0] * n
for i in range(n):
	ans[(a[i][1] - b[i][1]) % n] += 1
print(max(ans))


def f(n, A, B):
	PosA = {}
	PosB = {}
	Shift = {}
	for i in range(n):
		Shift[i] = 0
	for i in range(n):
		PosA[int(A[i])] = i
		PosB[int(B[i])] = i
	for i in range(n):
		Shift[(PosA[i + 1] - PosB[i + 1]) % n] += 1
	x = 1
	for i in range(n):
		if x < Shift[i]:
			x = Shift[i]
	return x
n = int(input())
A = input().split(' ')
B = input().split(' ')
print(f(n, A, B))


import sys
from collections import Counter
ip = lambda : sys.stdin.readline().rstrip()
n = int(ip())
a = list(map(int, ip().split()))
b = list(map(int, ip().split()))
d = {a[i]: i for i in range(n)}
e = {b[i]: i for i in range(n)}
c = []
for i in range(1, n + 1):
	c.append(d[i] - e[i])
ans = 0
c = Counter(c)
for i in c:
	if i < 0:
		ans = max(ans, c[i] + c.get(n + i, 0))
	else:
		ans = max(ans, c[i] + c.get(-n + i, 0))
print(ans)


n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
d = [0] * (n + 1)
brr1 = {}
for i in range(n):
	brr1[brr[i]] = i
max1 = 0
for i in range(n):
	z = brr1[arr[i]] - i
	if z < 0:
		z = n + z
	d[z] += 1
print(max(d))


numbers = int(input())
arrayA = list([int(x) for x in input().split()])
arrayB = list([int(x) for x in input().split()])
totalmatch = [0] * numbers
for i in range(numbers):
	totalmatch[arrayA[i] - 1] = i
checkerr = [0] * numbers
x = 0
for i in range(numbers):
	x = i - totalmatch[arrayB[i] - 1]
	x %= numbers
	checkerr[x] += 1
print(max(checkerr))


import math
from sys import stdin
from collections import Counter, defaultdict, deque
input = stdin.readline
mod = pow(10, 9) + 7

def solve():
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d1 = dict()
	d2 = dict()
	g = defaultdict(int)
	for i in range(n):
		d1[l1[i]] = i
		d2[l2[i]] = i
	for i in range(n):
		v = d1[l1[i]] - d2[l1[i]]
		if v < 0:
			v = v + n
		g[v] += 1
	x = max(g.values())
	print(x)
solve()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ga = {}
gb = {}
for i in range(n):
	ga[a[i]] = i
	gb[b[i]] = i
g = {}
for i in range(1, n + 1):
	o = (gb[i] - ga[i]) % n
	g[o] = g[o] + 1 if g.get(o) else 1
print(max((g[i] for i in g)))


import sys
input = sys.stdin.readline
n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split())) * 2
pos = [0] * (2 * n)
u = {}
l = {}
for i in range(n):
	u[arr1[i]] = i
for i in range(n):
	l[arr2[i]] = i
for i in range(n):
	pos[(l[arr1[i]] - u[arr1[i]]) % n] += 1
print(max(pos))


n = int(input())
l = [int(j) for j in input().split()]
m = [int(j) for j in input().split()]
d = dict()
for i in range(n):
	d[m[i]] = i
ans = dict()
for i in range(n):
	tmp = i - d[l[i]]
	if tmp < 0:
		tmp = n + tmp
	if tmp in ans:
		ans[tmp] += 1
	else:
		ans[tmp] = 1
print(max(ans.values()))


import sys
input = lambda : sys.stdin.buffer.readline().rstrip()
n = int(input())
q = list(map(int, input().split()))
w = list(map(int, input().split()))
e = [0] * (n + 1)
for i in range(n):
	e[q[i]] = i
t = [0] * n
for i in range(n):
	t[(i - e[w[i]]) % n] += 1
print(max(t))


b = int(input())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
ci = [0] * b
for i in range(b):
	ci[c[i] - 1] = i
dict = dict()
max = 1
for i in range(b):
	diff = ci[d[i] - 1] - i
	if diff < 0:
		diff += b
	if diff in dict:
		dict[diff] += 1
	else:
		dict[diff] = 1
	if dict[diff] > max:
		max = dict[diff]
print(max)


def solve_2(D):
	n = len(D)
	cnts = [0] * n
	for (i, v) in enumerate(D):
		cnts[(v - i - 1 + n) % n] += 1
	return max(cnts)

def solve(n, A, B):
	a_d = {v: i + 1 for (i, v) in enumerate(A)}
	C = [a_d[v] for v in B]
	C_1 = C.index(1)
	D = C[C_1:] + C[:C_1]
	return solve_2(D)

def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	print(solve(n, A, B))
main()


def answer(n, A, B):
	dp1 = [0] * (n + 1)
	dp2 = [0] * (n + 1)
	for i in range(n):
		dp1[A[i]] = i
		dp2[B[i]] = i
	d = [0] * n
	for i in range(1, n + 1):
		if dp1[i] - dp2[i] >= 0:
			d[dp1[i] - dp2[i]] += 1
		else:
			d[n - dp2[i] + dp1[i]] += 1
	return max(d)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(answer(n, a, b))


n = int(input())
arr = [0] + list(map(int, input().split()))
bbs = [0] + list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d[arr[i]] = i
count = {}
for i in range(1, n + 1):
	curr = d[bbs[i]] - i
	if curr < 0:
		curr += n
	count[curr] = count.get(curr, 0) + 1
res = max(count.values())
print(res)


def help():
	n = int(input())
	arr1 = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	indices = [[0, 0] for i in range(n)]
	dist = [0] * n
	for i in range(n):
		indices[arr1[i] - 1][0] = i
		indices[arr2[i] - 1][1] = i
	for i in range(n):
		dist[i] = indices[i][0] - indices[i][1]
		if dist[i] < 0:
			dist[i] += n
	dicti = {}
	for i in range(n):
		dicti[dist[i]] = dicti.get(dist[i], 0) + 1
	print(max(dicti.values()))
help()


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
from itertools import *
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
n = val()
l1 = li()
l2 = li()
index = {}
for i in range(n):
	index[l2[i]] = i
i = 0
d = defaultdict(int)
for i in range(n):
	d[(i - index[l1[i]] + n + n) % n] += 1
print(max(d.values()))


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, accumulate
from heapq import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = I()
a = lint()
b = lint()
(d, d1, d2, ans) = (defaultdict(int), {}, {}, 0)
for i in range(n):
	d1[a[i]] = i + 1
	d2[b[i]] = i + 1
for i in range(1, n + 1):
	x = d1[i] - d2[i]
	if x < 0:
		x += n
		d[x] += 1
	else:
		d[x] += 1
	ans = max(ans, d[x])
print(ans)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


n = int(input())
num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
pos = (n + 1) * [0]
dis = (n + 1) * [0]
for i in range(n):
	pos[num2[i]] = i
ans = 0
for i in range(n):
	x = (i - pos[num1[i]] + n) % n
	dis[x] += 1
	ans = max(ans, dis[x])
print(ans)


import sys
from collections import Counter

def read_ints():
	return [int(i) for i in input().strip().split()]

def solve():
	pass

def intersection(left, right, mn, mx):
	if right < mn or left > mx:
		return None
	else:
		return [max(left, mn), min(right, mx)]

def main():
	n = int(input())
	a = read_ints()
	b = read_ints()
	d = dict()
	for (idx, i) in enumerate(a):
		d[i] = idx
	diff = []
	for (idx, i) in enumerate(b):
		idx1 = d[i]
		delta = (idx1 - idx) % n
		diff.append(delta)
	data = Counter(diff)
	print(data.most_common(1)[0][1])
main()


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = defaultdict(lambda : 0)
temp = [0] * (n + 1)
for i in range(n):
	temp[a[i]] = i
for (i, v) in enumerate(b):
	cur = temp[v] - i
	if cur < 0:
		cur += n
	dp[cur] += 1
ans = 0
for (i, j) in dp.items():
	ans = max(ans, j)
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [0 for i in range(n + 1)]
y = [0 for i in range(n + 1)]
z = [0 for i in range(2 * n + 10)]
for i in range(n):
	x[a[i]] = i + 1
for i in range(n):
	y[b[i]] = i + 1
for i in range(1, n + 1):
	if x[i] - y[i] > 0:
		z[x[i] - y[i] + 1] += 1
	else:
		z[x[i] - y[i] + n + 1] += 1
ans = 0
for i in z:
	ans = max(ans, i)
print(ans)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = defaultdict(int)
for i in range(n):
	pos[a[i]] = i
for i in range(n):
	if i <= pos[b[i]]:
		pos[b[i]] -= i
	else:
		pos[b[i]] = n - i + pos[b[i]]
temp = 0
count = defaultdict(int)
for (k, v) in pos.items():
	if v == 0:
		temp += 1
	else:
		count[v] += 1
if len(count) > 0:
	m = max(count.values())
else:
	m = 0
if m > temp:
	ans1 = m
else:
	ans1 = temp
print(ans1)


import collections
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = dict.fromkeys(list(range(1, n + 1)), 0)
ind = [-1] * (n + 1)
for i in range(n):
	ind[b[i]] = i
for i in range(n):
	r = ind[a[i]]
	if r > i:
		d[a[i]] = r - i
	elif r < i:
		d[a[i]] = n - (i - r)
z = collections.Counter(d.values())
print(max(z.values()))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
mp1 = [0] * (n + 2)
mp2 = [0] * (n + 2)
for i in range(n):
	mp1[l1[i]] = i
for i in range(n):
	mp2[l2[i]] = i
a = []
for i in range(1, n + 1):
	if mp1[i] - mp2[i] < 0:
		a.append(mp1[i] - mp2[i] + n)
	else:
		a.append(mp1[i] - mp2[i])
a.sort()
mx = 0
cnt = 1
for i in range(1, n):
	if a[i] == a[i - 1]:
		cnt += 1
	else:
		mx = max(mx, cnt)
		cnt = 1
mx = max(mx, cnt)
print(mx)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
best = 0
atoi = dict()
shifts_map = [0 for i in range(0, n)]
for i in range(0, n):
	atoi[a[i]] = i
for i in range(0, n):
	curr = 0
	off = (atoi[b[i]] - i) % n
	shifts_map[off] += 1
	if shifts_map[off] > best:
		best = shifts_map[off]
print(best)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = dict()
d2 = dict()
for i in range(n):
	d1[a[i]] = i
	d2[b[i]] = i
ans = dict()
for i in range(n):
	id1 = d1[b[i]]
	id2 = d2[b[i]]
	if id1 > id2:
		if ans.get(id1 - id2) is None:
			ans[id1 - id2] = 1
		else:
			ans[id1 - id2] += 1
	elif ans.get(n + id1 - id2) is None:
		ans[n + id1 - id2] = 1
	else:
		ans[n + id1 - id2] += 1
print(max(ans.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ind = [0 for i in range(n + 1)]
for i in range(len(b)):
	ind[b[i]] = i
diff = [0 for i in range(n + 1)]
for i in range(n):
	x = (i - ind[a[i]]) % n
	diff[x] += 1
print(max(diff))


n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
inda = dict()
indb = dict()
for (i, val) in enumerate(a):
	inda[val] = i
for (i, val) in enumerate(b):
	indb[val] = i
from collections import defaultdict
maks = 0
cnt = defaultdict(int)
for i in range(1, n + 1):
	diff = (inda[i] - indb[i]) % n
	cnt[diff] += 1
	if cnt[diff] > maks:
		maks = cnt[diff]
print(maks)


import collections
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = {}
d1 = {}
for i in range(n):
	d1[a[i]] = i
for i in range(n):
	if i > d1[b[i]]:
		d1[b[i]] = i - d1[b[i]]
	else:
		d1[b[i]] = n - (d1[b[i]] - i)
ct = collections.Counter(d1.values())
print(max(ct.values()))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
a = []
pos = [None] * n
shift = [0] * n
a = inlist()
for i in range(0, n):
	pos[a[i] - 1] = i
b = inlist()
for i in range(0, n):
	cur = pos[b[i] - 1] - i
	if cur < 0:
		cur = cur + n
	shift[cur] = shift[cur] + 1
max = -1
for i in shift:
	if max < i:
		max = i
print(max)


n = int(input())
a = input().split()
b = input().split()
occ1 = [0 for i in range(n + 2)]
occ2 = [0 for i in range(n + 2)]
for i in range(n):
	occ1[int(a[i])] = i
	occ2[int(b[i])] = i
indsal = [0 for i in range(2 * n + 1)]
for i in range(1, n + 1):
	a_occ = occ1[i]
	b_occ = occ2[i]
	tmp = a_occ - b_occ
	if tmp > 0:
		tmp2 = tmp - n
	else:
		tmp2 = (n + tmp) % n
	indsal[tmp + n] += 1
	if tmp != tmp2:
		indsal[n + tmp2] += 1
print(max(indsal))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {a[i]: i for i in range(n)}
for i in range(n):
	v = i - d[b[i]]
	if v >= 0:
		d[b[i]] = v
	else:
		d[b[i]] = n + v
print(max(Counter(d.values()).values()))


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 2)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k))))
from collections import deque, defaultdict
import heapq

def solution(a, b, n):
	ais = defaultdict(int)
	bis = defaultdict(int)
	for i in range(n):
		ais[a[i]] = i
		bis[b[i]] = i
	diffs = defaultdict(int)
	for i in range(1, n + 1):
		k = (ais[i] - bis[i]) % n
		diffs[k] += 1
	max_k = -1
	max_value = -1
	for k in diffs:
		if diffs[k] > max_value:
			max_value = diffs[k]
			max_k = k
	return max_value

def main():
	T = 1
	for i in range(T):
		n = ri()
		a = ria()
		b = ria()
		x = solution(a, b, n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dica = dict()
dicb = dict()
ks = dict()
for i in range(n):
	dica[a[i]] = i
	dicb[b[i]] = i
for i in dica.keys():
	t = dicb[i] - dica[i]
	if t > 0:
		if t not in ks:
			ks[t] = 0
		ks[t] += 1
	else:
		if n + dicb[i] - dica[i] not in ks:
			ks[n + dicb[i] - dica[i]] = 0
		ks[n + dicb[i] - dica[i]] += 1
print(max(ks.values()))


from collections import defaultdict as dc
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = dc(int)
y = dc(int)
for i in range(n):
	x[a[i]] = i
for j in range(n):
	y[b[j]] = j
p = [0] * n
m = 0
for k in x.keys():
	if y[k] >= x[k]:
		p[y[k] - x[k]] += 1
		m = max(m, p[y[k] - x[k]])
	else:
		p[n - abs(x[k] - y[k])] += 1
		m = max(m, p[n - abs(x[k] - y[k])])
print(m)


from sys import stdin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
res = ['YES', 'NO']
test_case = 1
while test_case:
	test_case -= 1
	n = ii()
	a = li()
	p = [-1] * (n + 1)
	for i in range(n):
		p[a[i]] = i
	a = li()
	v = [0] * n
	for i in range(n):
		x = i - p[a[i]]
		if x < 0:
			x += n
		v[x] += 1
	print(max(v))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = {}
bb = {}
for i in range(n):
	aa[a[i]] = i
	bb[b[i]] = i
ans = 1
dic = {}
for i in range(n):
	ind = bb[a[i]]
	temp = 0
	if ind < i:
		temp = n + ind - i
	else:
		temp = ind - i
	if temp in dic:
		dic[temp] += 1
	else:
		dic[temp] = 1
	ans = max(ans, dic[temp])
print(ans)


import sys

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n = II()
a = LI()
b = LI()
x = [0] * (n + 1)
y = [0] * (n + 1)
d = {}
for i in range(n):
	x[a[i]] = i
	y[b[i]] = i
m = 0
for i in range(1, n + 1):
	z = x[i] - y[i]
	if z < 0:
		z += n
	if z not in d:
		d[z] = 1
	else:
		d[z] += 1
	m = max(m, d[z])
print(m)


from collections import defaultdict
n = int(input())
A = [int(i) - 1 for i in input().split()]
B = [int(i) - 1 for i in input().split()]
A_map = dict()
B_map = dict()
for i in range(n):
	A_map[A[i]] = i
	B_map[B[i]] = i
k_dict = defaultdict(int)
for i in range(n):
	k_dict[(B_map[i] - A_map[i]) % n] += 1
ans = 0
for i in k_dict:
	ans = max(ans, k_dict[i])
print(ans)


arr_size = int(input())
dict_a = dict()
for (i, a) in enumerate(list(map(int, input().split())), start=1):
	dict_a[a] = i
dict_b = dict()
for (i, b) in enumerate(list(map(int, input().split())), start=1):
	key = (i - dict_a[b]) % arr_size
	if key in dict_b:
		dict_b[key] += 1
	else:
		dict_b[key] = 1
result = max(dict_b.values())
print(result)


number = int(input())
col_a = list(map(int, input().split()))
col_b = list(map(int, input().split()))
mark = [0 for i in range(number)]
dic_b = [0 for i in range(number)]
for i in range(number):
	dic_b[col_b[i] - 1] = i
match = [0 for i in range(number)]
for i in range(number):
	diff = (dic_b[col_a[i] - 1] - i) % number
	match[diff] += 1
match_max = max(match)
print(match_max)


n = int(input())
a_trans = [0] * (n + 1)
for (i, ai) in enumerate(input().split()):
	a_trans[int(ai)] = i
matches = [0] * n
for (i, bi) in enumerate(input().split()):
	matches[(i - a_trans[int(bi)]) % n] += 1
print(max(matches))


import sys
from sys import stdin
import math
input = sys.stdin.readline
for _ in range(1):
	n = int(input())
	arr = [int(j) for j in input().split()]
	brr = [int(j) for j in input().split()]
	dic1 = {}
	for i in range(n):
		dic1[arr[i]] = i
	dic = {}
	for i in range(n):
		t = dic1[brr[i]]
		r = (i - t) % n
		if r not in dic:
			dic[r] = 1
		else:
			dic[r] += 1
	dic = sorted(dic.items(), key=lambda x: x[1])
	print(dic[-1][1])


def solve(t, d, e):
	arr1 = [0] * (3 * 10 ** 5)
	arr2 = [0] * (3 * 10 ** 5)
	for i in range(t):
		arr1[d[i]] = i
		arr2[e[i]] = i
	shifts = {}
	for i in range(t):
		dind = arr1[e[i]]
		if dind >= i:
			shift = dind - i
		else:
			shift = dind - i + t
		if shift in shifts:
			shifts[shift] += 1
		else:
			shifts[shift] = 1
	maxer = 0
	for i in shifts:
		maxer = max(maxer, shifts[i])
	return maxer

def main():
	t = int(input())
	d = input()
	d = [int(i) for i in d.split()]
	e = input()
	e = [int(i) for i in e.split()]
	ans = solve(t, d, e)
	print(ans)
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_ind = [i[0] for i in sorted(enumerate(a), key=lambda x: x[1])]
b_ind = [i[0] for i in sorted(enumerate(b), key=lambda x: x[1])]
right_shifts = n * [0]
counts = n * [0]
for i in range(n):
	if b_ind[i] >= a_ind[i]:
		right_shifts[i] = b_ind[i] - a_ind[i]
	else:
		right_shifts[i] = n - abs(b_ind[i] - a_ind[i])
	counts[right_shifts[i] - 1] += 1
print(max(counts))


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from collections import deque, Counter, defaultdict
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	n = int(input())
	a = read()
	b = read()
	dic = {a[i]: i for i in range(n)}
	c = defaultdict(int)
	for i in range(n):
		if i <= dic[b[i]]:
			c[dic[b[i]] - i] += 1
		else:
			c[n - abs(dic[b[i]] - i)] += 1
	print(max(c.values()))
solve()


n = int(input())
A = list(map(int, input('').split()))
B = list(map(int, input('').split()))
ans = 0
indexA = dict()
indexB = dict()
for i in range(n):
	indexB[B[i]] = i
count = dict()
for i in range(n):
	x = indexB[A[i]] - i
	if x < 0:
		x += n
	count[x] = count.get(x, 0) + 1
print(max(count.values()))


def f(n, a, b):
	smax = 0
	for d in range(n):
		s = 0
		for i in range(n):
			j = (i + d) % n
			if a[i] == b[j]:
				s += 1
		if s > smax:
			smax = s
	return smax
n = int(input())
a = [int(x) - 1 for x in input().split()]
b = [int(x) - 1 for x in input().split()]
r = [0] * n
for (i, x) in enumerate(a):
	r[x] = i

def recod(a):
	for i in range(n):
		a[i] = r[a[i]]
recod(b)
for i in range(n):
	r[i] = (b[i] - i + n) % n
c = [0] * n
for i in range(n):
	c[r[i]] += 1
print(max(c))


import math
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = I()
a = LI()
b = LI()
c = []
d = {}
e = {}
for i in range(n):
	d[a[i]] = i + 1
for i in range(n):
	e[b[i]] = i + 1
for i in range(1, n + 1):
	c += [(n - e[i] + d[i]) % n]
f = Counter(c)
ans = max(f.values())
print(ans)


n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
index_map = {}
for (i, aa) in enumerate(a):
	index_map[aa] = i
offset_list = []
for (i, bb) in enumerate(b):
	if index_map[bb] < i:
		offset_list.append(n - (i - index_map[bb]))
	else:
		offset_list.append(index_map[bb] - i)
fre_dict = {}
most_occur = 0
for oo in offset_list:
	if oo not in fre_dict:
		fre_dict[oo] = 1
	else:
		fre_dict[oo] += 1
	if fre_dict[oo] > most_occur:
		most_occur = fre_dict[oo]
print(most_occur)


n = int(input())
a = input()
A = list(map(int, list(a.split())))
b = input()
B = list(map(int, list(b.split())))
f = [0] * n
table = [0] * (n + 1)
for i in range(n):
	table[A[i]] = i
for i in range(n):
	k = table[B[i]]
	if k - i >= 0:
		f[k - i] = f[k - i] + 1
	else:
		f[n - (i - k)] = f[n - (i - k)] + 1
print(max(f))


import sys
from collections import Counter
fast_reader = sys.stdin.readline

def input():
	return fast_reader().strip()

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())
n = int(input())
a = list_input()
b = list_input()
da = {}
db = {}
for i in range(n):
	da[a[i]] = i
	db[b[i]] = i
r = {}
for i in range(1, n + 1):
	if da[i] - db[i] >= 0:
		r[i] = da[i] - db[i]
	else:
		r[i] = n + (da[i] - db[i])
p1 = list(r.values())
d1 = Counter(p1)
print(max(list(d1.values())))


from collections import defaultdict as dft
import sys
import math

def ml():
	return list(map(int, input().split()))

def mp():
	return map(int, input().split())

def debug(name, val):
	print(name, ':', val)

def solve():
	n = int(input())
	a = ml()
	b = ml()
	aind = [-1] * (n + 1)
	bind = [-1] * (n + 1)
	for i in range(n):
		aind[a[i]] = i
		bind[b[i]] = i
	shift = []
	lf = dft(int)
	rt = dft(int)
	for num in range(1, n + 1):
		i = aind[num]
		j = bind[num]
		if i <= j:
			r = j - i
			l = n - j + i
			rt[r] += 1
			lf[l] += 1
		else:
			l = i - j
			r = n - i + j
			rt[r] += 1
			lf[l] += 1
	mx = -1
	for (key, val) in lf.items():
		if val > mx:
			ans = key
			mx = val
	for (key, val) in rt.items():
		if val > mx:
			ans = key
			mx = val
	print(mx)
t = 1
for _ in range(t):
	solve()


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
bIndexes = {}
for i in range(n):
	bIndexes[b[i]] = i
values = [0 for i in range(n)]
for i in range(n):
	values[(bIndexes[a[i]] - i) % n] += 1
print(max(values))


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		n = int(R())
		a = [int(x) for x in R().split()]
		b = [int(x) for x in R().split()]
		a_pos = {}
		for i in range(n):
			a_pos[a[i]] = i
		left_shift = {}
		right_shift = {}
		for i in range(n):
			pos = a_pos[b[i]]
			if pos > i:
				r_dis = pos - i
				l_dis = n - (pos - i)
			elif pos < i:
				r_dis = n - (i - pos)
				l_dis = i - pos
			else:
				r_dis = l_dis = 0
			if r_dis not in right_shift:
				right_shift[r_dis] = 1
			else:
				right_shift[r_dis] += 1
			if l_dis not in left_shift:
				left_shift[l_dis] = 1
			else:
				left_shift[l_dis] += 1
		W('%d\n' % max(max(left_shift.values()), max(right_shift.values())))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


n = int(input())
a = [0 for _ in range(n + 5)]
i = 0
for x in input().split():
	a[int(x)] = i
	i += 1
ans = [0 for _ in range(2 * n + 5)]
i = 0
for x in input().split():
	offset = i - a[int(x)]
	ans[offset if offset > 0 else offset + n] += 1
	i += 1
print(max(ans))


n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
a_idx = {v: i for (i, v) in enumerate(a)}
diffs = {}
for (i, v) in enumerate(b):
	diff = (a_idx[v] - i) % n
	diffs.setdefault(diff, 0)
	diffs[diff] += 1
print(max(diffs.values()))


import bisect
import sys
import math
input = sys.stdin.readline
from collections import defaultdict
from collections import Counter

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(case):
	n = inp()
	aa = inlt()
	bb = inlt()
	c = Counter()
	aaidx = [0] * (n + 1)
	bbidx = [0] * (n + 1)
	for (i, a) in enumerate(aa):
		aaidx[a] = i
	for (i, b) in enumerate(bb):
		bbidx[b] = i
	for i in range(1, n + 1):
		diff = (bbidx[i] + n - aaidx[i]) % n
		c[diff] += 1
	return c.most_common(1)[0][1]
if len(sys.argv) > 1 and sys.argv[1].startswith('input'):
	f = open('./' + sys.argv[1], 'r')
	input = f.readline
res = solve(0)
print(str(res))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_indices = [0] * n
for i in range(n):
	a_indices[a[i] - 1] = i
counts = [0] * n
for (i, num) in enumerate(b):
	num = num - 1
	shift = (a_indices[num] - i + n) % n
	counts[shift] += 1
print(max(counts))


from sys import stdin, gettrace
from collections import Counter
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	bb = [int(a) for a in inputi().split()]
	aapos = [0] * n
	for (i, a) in enumerate(aa):
		aapos[a - 1] = i
	bbpos = [0] * n
	for (i, b) in enumerate(bb):
		bbpos[b - 1] = i
	dpos = map(lambda a, b: (a - b) % n, aapos, bbpos)
	dpc = Counter(dpos)
	(_, res) = dpc.most_common(1)[0]
	print(res)
main()


t = 1
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	e = {}
	for (i, k) in enumerate(a):
		d[k] = i
	for (i, k) in enumerate(b):
		e[k] = i
	l = []
	for i in a:
		k = d[i] - e[i]
		if k < 0:
			k += n
		l.append(k)
	ans = 0
	temp = {}
	for i in l:
		try:
			temp[i] += 1
		except:
			temp[i] = 1
		ans = max(ans, temp[i])
	print(ans)


def solve():
	n = int(input())
	posinarr = [0] * n
	posinbrr = [0] * n
	mp = {}
	ans = 0
	arr = [int(v) - 1 for v in input().split()]
	brr = [int(v) - 1 for v in input().split()]
	for i in range(n):
		posinarr[arr[i]] = i
		posinbrr[brr[i]] = i
	j = 0
	for i in range(2 * n - 1):
		idx = i % n
		diag = posinarr[brr[idx]] - i
		mp.setdefault(diag, 0)
		mp[diag] += 1
		if i >= n:
			diagrem = posinarr[brr[j]] - posinbrr[brr[j]]
			mp[diagrem] -= 1
			j += 1
		ans = max(mp[diag], ans)
	print(ans)
solve()


import sys, math
import io, os
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.buffer.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
mod = int(1000000000.0) + 7

def main():
	n = int(data())
	a = mdata()
	b = mdata()
	s = [0] * n
	d = dd(int)
	for i in range(n):
		s[a[i] - 1] += i
		s[b[i] - 1] -= i
	for i in range(n):
		if s[i] < 0:
			s[i] += n
		d[s[i]] += 1
	out(max(d.values()))
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
temp = dict()
for i in range(n):
	temp[b[i]] = i
temp2 = dict()
for i in range(n + 1):
	temp2[i] = 0
for i in range(n):
	j = temp[a[i]]
	if j > i:
		temp2[j - i] += 1
	else:
		temp2[n - i + j] += 1
ans = 0
for i in range(n + 1):
	ans = max(ans, temp2[i])
print(ans)


import math, sys, bisect
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
A = alele()
B = alele()
mark = {}
for i in range(N):
	mark[A[i]] = i
C = []
for i in range(N):
	z = mark.get(B[i], -1)
	if z < i:
		z += N
	C.append(z - i)
e = Counter(C)
print(e.most_common(1)[0][1])


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
left = [0] * n
right = [0] * n
hm_a = {key: val for (key, val) in zip(a, range(n))}
for i in range(n):
	r_r = (hm_a[b[i]] - i) % n
	l_r = n - (hm_a[b[i]] - i) % n
	left[l_r % n] += 1
	right[r_r] += 1
print(max(max(left), max(right)))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0] * (n + 1)
fre = [0] * n
for i in range(n):
	pos[a[i]] = i + 1
for i in range(n):
	x = i + 1
	y = pos[b[i]]
	fre[(x - y + n) % n] += 1
print(max(fre))


import os
import sys
from io import BytesIO, IOBase
profile = 0
pypy = 1

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	T = 1
	while T:
		T -= 1
		n = iin()
		a = [[j, i] for (i, j) in enumerate(lin())]
		b = [[j, i] for (i, j) in enumerate(lin())]
		(a1, b1) = ([0] * n, [0] * n)
		for (i, j) in a:
			a1[i - 1] = j
		for (i, j) in b:
			b1[i - 1] = j
		dc = [0] * n
		for i in range(n):
			(i1, i2) = (a1[i], b1[i])
			dc[(i2 - i1) % n] += 1
		print(max(dc))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if pypy:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
if profile:
	import cProfile
	cProfile.run('main()')
else:
	main()


import sys
import math
import operator as op
from functools import reduce
from bisect import *
from collections import deque

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().split()]

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
N = int(1000000.0) + 10
fenwick = [0] * N

def add(i, x, n):
	while i < n:
		fenwick[i] += x
		i = i | i + 1

def fsum(i, n):
	res = 0
	while i >= 0:
		res += fenwick[i]
		i = (i & i + 1) - 1
	return res

def fsum_range(i, j, n):
	return fsum(j, n) - fsum(i - 1, n)
mod = int(1000000000.0) + 7
mod2 = 998244353
t = 1
for i in range(t):
	n = read_int()
	a = read_int_line()
	b = read_int_line()
	ans = -1
	a1 = [0] * (n + 1)
	a2 = [0] * (n + 1)
	for i in range(n):
		a1[a[i]] = i
		a2[b[i]] = i
	c = [0] * (n + 1)
	for i in range(1, n + 1):
		if a1[i] < a2[i]:
			c[i] = a2[i] - a1[i]
		else:
			c[i] = n - a1[i] + a2[i]
	d = {}
	for i in c[1:]:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	ans = max(list(d.values()))
	print(ans)


import math

def Divisors(n):
	l = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	result.append(n)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	d1 = {}
	for j in range(0, n):
		d1[a[j]] = j
	d2 = {}
	for j in range(0, n):
		d2[b[j]] = j
	l = []
	for j in range(1, n + 1):
		if d1[j] - d2[j] < 0:
			l.append(n + d1[j] - d2[j])
		else:
			l.append(d1[j] - d2[j])
	d = {}
	for j in l:
		d[j] = 0
	for j in l:
		d[j] += 1
	m = 0
	for j in l:
		if d[j] > m:
			m = d[j]
	print(m)
t = 1
for i in range(0, t):
	main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = list(zip(a, range(n)))
b = list(zip(b, range(n)))
a.sort()
b.sort()
temp = [0] * n
for i in range(n):
	temp[(a[i][1] - b[i][1]) % n] += 1
print(max(temp))


from collections import Counter
import operator
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arrA = [0] * n
arrB = [0] * n
arr = [0] * n
for i in range(n):
	currA = a[i]
	currB = b[i]
	arrA[currA - 1] = i + 1
	arrB[currB - 1] = i + 1
for i in range(n):
	diff = arrA[i] - arrB[i]
	if diff < 0:
		diff += n
	arr[i] = diff
new = Counter(arr)
c = {}
for (key, value) in new.items():
	c[key] = value
most = c[max(c.items(), key=operator.itemgetter(1))[0]]
print(most)


elem = int(input())
ar = []
for i in input().split(' '):
	ar.append(int(i))
ar2 = []
for i in input().split(' '):
	ar2.append(int(i))
diff = {}
m = 0
t = []
acc = {}
for i in range(len(ar)):
	acc[ar[i]] = i + 1
for i in range(len(ar)):
	temp = (i - acc[ar2[i]]) % elem
	if temp in diff:
		diff[temp] = diff[temp] + 1
	else:
		diff[temp] = 1
	if diff[temp] > m:
		m = diff[temp]
print(m)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ram = [0 for i in range(n + 1)]
shiv = [0 for i in range(n + 1)]
for i in range(1, n + 1):
	d = a[i - 1]
	ram[d] = i
for i in range(1, n + 1):
	d = b[i - 1]
	shiv[d] = i
store = [0 for i in range(n)]
for i in range(1, n + 1):
	if ram[i] < shiv[i]:
		ram[i] += n
	e = ram[i] - shiv[i]
	store[e] += 1
maxi = 0
for i in store:
	maxi = max(maxi, i)
print(maxi)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
h = [0] * (n + 2)
indexArray = [0] * n
for i in range(n):
	indexArray[a[i] - 1] = i
for i in range(n):
	f = indexArray[b[i] - 1]
	if i <= f:
		d.append(f - i)
	else:
		d.append(n - i + f)
for i in range(n):
	h[d[i]] += 1
H = 1
for i in range(n):
	H = max(H, h[i])
print(H)


import sys
input = sys.stdin.readline

def shift_left(n, ai, bi):
	if ai == bi:
		return n
	elif ai < bi:
		return bi - ai
	else:
		return n - (ai - bi)

def right_shift(n, ai, bi):
	if ai == bi:
		return n
	elif ai > bi:
		return ai - bi
	else:
		return n - (bi - ai)

def solve(n, a, b):
	num_idx = {ai: i for (i, ai) in enumerate(a)}
	zero_dist = 0
	dist1 = dict()
	dist2 = dict()
	for (i, bi) in enumerate(b):
		if bi in num_idx:
			if num_idx[bi] == i:
				zero_dist += 1
			d1 = shift_left(n, num_idx[bi], i)
			d2 = right_shift(n, num_idx[bi], i)
			if d1 in dist1:
				dist1[d1].append(bi)
			else:
				dist1[d1] = [bi]
			if d2 in dist2:
				dist2[d2].append(bi)
			else:
				dist2[d2] = [bi]
	mx = 0
	for (k, lst) in dist1.items():
		mx = max(mx, len(lst))
	for (k, lst) in dist2.items():
		mx = max(mx, len(lst))
	return max(mx, zero_dist)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(solve(n, a, b))


import sys

def input():
	return sys.stdin.readline()[:-1]

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	A = [(a[k], k) for k in range(n)]
	B = [(b[k], k) for k in range(n)]
	A = sorted(A, key=lambda x: x[0])
	B = sorted(B, key=lambda x: x[0])
	C = [0] * n
	for k in range(n):
		C[(A[k][1] - B[k][1]) % n] += 1
	print(max(C))
main()


n = int(input())
in1 = list(map(int, input().split()))
in2 = list(map(int, input().split()))
pos1 = [0] * n
out1 = [0] * n
for i in range(n):
	pos1[in1[i] - 1] += i
for i in range(n):
	pos1[in2[i] - 1] -= i
for v in pos1:
	out1[v] += 1
print(max(out1))


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
n = int(ri())
a = Ri()
b = Ri()
dic1 = {}
dic2 = {}
for i in range(len(a)):
	dic1[a[i]] = i
for i in range(len(b)):
	dic2[b[i]] = i
dic = {}
for i in range(1, n + 1):
	if (dic2[i] - dic1[i]) % n in dic:
		dic[(dic2[i] - dic1[i]) % n] += 1
	else:
		dic[(dic2[i] - dic1[i]) % n] = 1
maxx = max([dic[i] for i in dic])
print(maxx)


import math
from collections import Counter, defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = defaultdict(lambda : 0)
d2 = defaultdict(lambda : 0)
d3 = defaultdict(lambda : 0)
for i in range(n):
	d1[b[i]] = i
for i in range(n):
	j = d1[a[i]]
	if j > i:
		d2[i + n - j] += 1
	else:
		d2[i - j] += 1
for i in range(n):
	j = d1[a[i]]
	if j >= i:
		d3[j - i] += 1
	else:
		d3[j + n - i] += 1
m = 0
for i in d2:
	m = max(m, d2[i])
for i in d3:
	m = max(m, d3[i])
print(m)


for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	right = [0 for i in range(n + 1)]
	for i in range(n):
		right[a[i]] = i + 1
	for i in range(n):
		c = b[i]
		if right[c] >= i + 1:
			right[c] -= i + 1
		else:
			right[c] = n - (i + 1) + right[c]
	left = [0 for i in range(n + 1)]
	for i in range(n):
		left[a[i]] = i + 1
	for i in range(n):
		c = b[i]
		if left[c] <= i + 1:
			left[c] -= i + 1
			left[c] = abs(left[c])
		else:
			left[c] = i + 1 + n - left[c]
	c = [0 for i in range(n + 1)]
	for i in left[1:]:
		c[i] += 1
	ans = max(c)
	c = [0 for i in range(n + 1)]
	for i in range(1, n):
		c[right[i]] += 1
	print(max(ans, max(c)))


import sys
import os
import heapq
import math
try:
	path = './file/input.txt'
	if os.path.exists(path):
		sys.stdin = open(path, 'r')
except:
	pass
t = 1

def printd(value):
	pass

def case():
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	mapp = [0] * (n + 1)
	for (index, value) in enumerate(a):
		mapp[value] = index
	result = 0
	right = [0] * (n + 1)
	for (index, value) in enumerate(b):
		pos = mapp[value]
		if pos < index:
			pos += n
		right[pos - index] += 1
		result = max(result, right[pos - index])
	print(result)
for _ in range(t):
	case()


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	index = {}
	for i in range(n):
		index[b[i]] = i
	r = defaultdict(int)
	for i in range(n):
		shift = index[a[i]] - i
		if shift < 0:
			r[n + shift] += 1
		else:
			r[shift] += 1
	res = 0
	for k in r:
		if r[k] > res:
			res = r[k]
	print(res)
t = 1
for _ in range(t):
	main()


n = int(input())
d = {}
arr = input().split()
for i in range(n):
	arr[i] = int(arr[i])
	d[arr[i]] = i
arr2 = input().split()
ans = 0
shifts = [0 for i in range(n)]
for i in range(n):
	arr2[i] = int(arr2[i])
	shift = i - d[arr2[i]]
	shifts[shift] += 1
	ans = max(ans, shifts[shift])
print(ans)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
pos = defaultdict(lambda : 0)
for i in range(n):
	d[a[i]] = i
for i in range(n):
	cur = d[b[i]] - i
	if cur < 0:
		cur += n
	pos[cur] += 1
s = max(pos.values())
print(s)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dif = [0] * n
a = list(enumerate(a))
b = list(enumerate(b))
a.sort(key=lambda x: x[1])
b.sort(key=lambda x: x[1])
for i in range(n):
	q1 = a[i][0]
	q2 = b[i][0]
	if q2 - q1 < 0:
		dif[i] = n + (q2 - q1)
	else:
		dif[i] = q2 - q1
maxi = 0
difmax = [0] * n
for s in dif:
	difmax[s] += 1
	if difmax[s] > maxi:
		maxi = difmax[s]
print(maxi)


from sys import stdin
A = int(stdin.readline())
C = stdin.readline().split()
D = stdin.readline().split()
E = dict()
G = dict()
S = set()
for j in range(0, A):
	E[C[j]] = j
MAX = 0
for t in range(0, A):
	if E[D[t]] >= t:
		p = len(S)
		S.add(int(E[D[t]]) - t)
		if p == len(S):
			G[int(E[D[t]]) - t] += 1
		else:
			G[int(E[D[t]]) - t] = 1
		MAX = max(MAX, G[int(E[D[t]]) - t])
	else:
		p = len(S)
		S.add(int(E[D[t]]) + A - t)
		if p == len(S):
			G[int(E[D[t]]) + A - t] += 1
		else:
			G[int(E[D[t]]) + A - t] = 1
		MAX = max(MAX, G[int(E[D[t]]) + A - t])
print(MAX)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = list(mapi())
b = list(mapi())
c = defaultdict(int)
for i in range(n):
	c[b[i]] = i
mp = defaultdict(int)
for i in range(n):
	if c[a[i]] > i:
		mp[n - c[a[i]] + i] += 1
	else:
		mp[i - c[a[i]]] += 1
res = 0
for i in mp.keys():
	res = max(res, mp[i])
print(res)


from collections import Counter
size = int(input())
first_array = list(map(int, input().split()))
second_array = list(map(int, input().split()))
out_comes = []
counter = 0
data = {}
for (index, val) in enumerate(second_array):
	data[val] = index
for (index, value) in enumerate(first_array):
	temp_val = data[value] - index
	if temp_val >= 0:
		out_comes.append(temp_val)
	else:
		out_comes.append(size + temp_val)
new_list = Counter(out_comes).most_common()
print(new_list[0][1])


from collections import Counter
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
a_indices = {}
b_indices = {}
for i in range(n):
	a_indices[a[i]] = i
	b_indices[b[i]] = i
shifts = []
for elem in a:
	shifts.append((a_indices[elem] - b_indices[elem] + n) % n)
c = Counter(shifts)
print(max(c.values()))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d1 = {}
d2 = {}
l = [0] * n
for i in range(n):
	d1[a[i]] = i
for i in range(n):
	d2[b[i]] = i
for i in a:
	k = d1[i] - d2[i]
	if k < 0:
		k += n
	l[k] += 1
print(max(l))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mp = dict()
cnt = [0 for _ in range(int(200000.0 + 5))]
for i in range(n):
	mp[a[i]] = i
for i in range(n):
	t = mp[b[i]]
	if t >= i:
		cnt[t - i] += 1
	else:
		cnt[t + n - i] += 1
ans = max(cnt)
print(ans)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = [-1] * (n + 1)
a2 = [-1] * (n + 1)
for i in range(n):
	a1[a[i]] = i
	a2[b[i]] = i
l1 = []
l2 = []
for i in range(1, 1 + n):
	l1.append((a1[i] - a2[i]) % n)
	l2.append((a2[i] - a1[i]) % n)
c1 = Counter(l1).most_common()
c2 = Counter(l2).most_common()
print(max(c1[0][1], c2[0][1]))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d1 = dict()
d2 = dict()
for i in range(len(a)):
	d1[a[i]] = i
for i in range(len(b)):
	d2[b[i]] = i
ans = []
pp = dict()
for i in range(len(a)):
	r = d1[a[i]] - d2[a[i]]
	if r < 0:
		r += len(a)
	if r in pp:
		pp[r] += 1
	else:
		pp[r] = 1
	ans.append(r)
all_values = pp.values()
max_value = max(all_values)
print(max_value)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
inds = {}
for i in range(len(a)):
	inds[a[i]] = i
diffs = {}
out = 0
for i in range(len(b)):
	dif = (inds[b[i]] - i) % n
	if dif in diffs:
		diffs[dif] += 1
	else:
		diffs[dif] = 1
	out = max(out, diffs[dif])
print(out)


import copy
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = {}
for i in range(len(b)):
	d[b[i]] = i
c = {}
for i in range(len(a)):
	p = (i - d[a[i]] + n) % n
	if p in c:
		c[p] += 1
	else:
		c[p] = 1
print(max(list(c.values())))


n = int(input())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
P1 = [0 for _ in range(n)]
P2 = [0 for _ in range(n)]
for i in range(n):
	P1[p1[i] - 1] = p1[i] - i - 1
	if P1[p1[i] - 1] < 0:
		P1[p1[i] - 1] += n
	P2[p2[i] - 1] = p2[i] - i - 1
	if P2[p2[i] - 1] < 0:
		P2[p2[i] - 1] += n
D = [n + P1[i] - P2[i] if P2[i] > P1[i] else P1[i] - P2[i] for i in range(n)]
S = [0 for _ in range(n)]
for i in D:
	S[i] += 1
print(max(S))


from sys import stdin
input = stdin.readline
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {j: i for (i, j) in enumerate(b)}
ds = []
for i in range(n):
	ds.append((d[a[i]] - i) % n)
print(max(Counter(ds).values()))


def fn(n):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(d, d1, d2) = ({}, {}, {})
	for i in range(n):
		d1[a[i]] = i
		d2[b[i]] = i
	for i in range(n):
		di = d1[a[i]] - d2[a[i]]
		if di < 0:
			di = n - abs(di)
		try:
			d[di] += 1
		except:
			d[di] = 1
	m = 0
	for i in d:
		m = max(m, d[i])
	print(m)
n = int(input())
fn(n)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
positions = [0] * (n + 1)
for i in range(n):
	positions[a[i]] = i
steps = dict()
steps = defaultdict(lambda : 0, steps)
for i in range(1, n + 1):
	steps[positions[b[i - 1]] - i if positions[b[i - 1]] >= i else positions[b[i - 1]] - (i - n)] += 1
print(max(steps.values()))


import sys
input = sys.stdin.readline
from collections import Counter
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().strip().split())

def from_file(f):
	return f.readline

def solution(n, A, B):
	deltas = [0] * n
	for (i, a) in enumerate(A):
		deltas[a - 1] = i
	for (i, b) in enumerate(B):
		b -= 1
		deltas[b] = i - deltas[b]
		if deltas[b] < 0:
			deltas[b] += n
	counter = Counter(deltas)
	return counter.most_common(1)[0][1]
n = inp()
A = inlt()
B = inlt()
print(solution(n, A, B))


from collections import Counter
n = int(input())
a = {}
b = {}
match = []
c = 0
for i in [int(i) for i in input().split()]:
	a[i] = c
	c += 1
c = 0
for i in [int(i) for i in input().split()]:
	b[i] = c
	c += 1
for i in range(1, n + 1):
	match.append((b.get(i) - a.get(i) + n) % n)
occu = Counter(match)
ans = 0
for i in set(occu.values()):
	if i > ans:
		ans = i
print(ans)


import sys
import math
from collections import defaultdict

def solve(test):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	rec = {}
	for i in range(n):
		rec[a[i]] = i
	freq = defaultdict(int)
	for i in range(n):
		diff = i - rec[b[i]]
		diff = (diff + n) % n
		freq[diff] += 1
	ans = max(freq.values())
	print(ans)
test_cases = 1
for t in range(1, test_cases + 1):
	solve(t)


n = int(input())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
dict1 = {}
dict2 = {}
for i in range(n):
	a = list1[i]
	b = list2[i]
	if a not in dict1:
		dict1[a] = i
	else:
		x = dict1[a] + i
		if x not in dict2:
			dict2[x] = 1
		else:
			dict2[x] += 1
	if b not in dict1:
		dict1[b] = -i
	else:
		y = dict1[b] - i + n
		if y not in dict2:
			dict2[y] = 1
		else:
			dict2[y] += 1
print(max(dict2.values()))


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
(n,) = mp()
a = mp()
b = mp()
pos = [0] * (n + 1)
ans = [0] * n
for i in range(n):
	pos[b[i]] = i
k = 0
for i in range(n):
	ans[(pos[a[i]] - i) % n] += 1
cout(str(sorted(ans, reverse=True)[0]))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from bisect import bisect_left

def main():
	n = N()
	arra = RLL()
	arrb = RLL()
	rec = {v: i for (i, v) in enumerate(arra)}
	dic = defaultdict(int)
	for (i, v) in enumerate(arrb):
		dif = rec[v] - i
		dic[dif] += 1
		if dif < 0:
			dic[n + dif] += 1
	print(max(dic.values()))
main()


a = int(input())
old = list(map(int, input().split()))
dic = {}
for i in range(a):
	dic[old[i]] = i + 1
new = list(map(int, input().split()))
distance = []
for i in range(a):
	distance.append((dic[new[i]] - (i + 1) + a) % a)
didi = {}
for j in distance:
	if j not in didi:
		didi[j] = 1
	else:
		didi[j] += 1
print(max(didi.values()))


from collections import defaultdict
length = int(input())
x = list(map(int, input().split()))
x_dict = defaultdict(lambda : -1)
for index in range(length):
	x_dict[x[index]] = index
y = list(map(int, input().split()))
shifts = [0] * length
for index in range(length):
	temp = index - x_dict[y[index]]
	if temp >= 0:
		shifts[temp] += 1
	else:
		shifts[length + temp] += 1
print(max(shifts))


from math import *
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
for i in range(n):
	d[a[i]] = i
dif = dict()
for i in range(n):
	x = (i - d[b[i]]) % n
	if x in dif:
		dif[x] += 1
	else:
		dif[x] = 1
print(max(dif.values()))


import math as mt
import sys, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
from collections import defaultdict
t = I()
t = 1
for _ in range(t):
	l = L()
	m = L()
	d = {}
	for i in range(len(l)):
		d[l[i]] = i
	for i in range(len(m)):
		m[i] = d[m[i]]
	x = defaultdict(int)
	ans = 0
	for i in range(len(m)):
		if i <= m[i]:
			e = m[i] - i
			if e < 0:
				e += m[i]
			x[e] += 1
			ans = max(ans, x[e])
		if i > m[i]:
			e = len(l) - i + m[i]
			if e < 0:
				e += len(m)
			x[e] += 1
			ans = max(ans, x[e])
	y = defaultdict(int)
	for i in range(len(m)):
		if i >= m[i]:
			e = i - m[i]
			if e < 0:
				e += len(m)
			y[e] += 1
			ans = max(ans, y[e])
		if i < m[i]:
			e = i + len(l) - m[i]
			if e < 0:
				e += len(m)
			y[e] += 1
			ans = max(ans, y[e])
	print(ans)


import sys

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	n = int(ii())
	a = idata()
	b = idata()
	(a1, b1) = ([0] * n, [0] * n)
	for i in range(n):
		a1[a[i] - 1] = i
		b1[b[i] - 1] = i
	slov = dict()
	for i in range(n):
		s = (a1[i] - b1[i]) % n
		if s not in slov:
			slov[s] = 1
		else:
			slov[s] += 1
	print(max(slov.values()))
	return
for ______ in range(1):
	solve_of_problem()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = [0] * (n + 1)
for i in range(n):
	cnt[a[i]] = i + 1
freq = []
for i in range(n):
	start = i + 1
	target = cnt[b[i]]
	if start < target:
		moves = start - 1 + 1 + n - target
	else:
		moves = start - target
	freq.append(moves)
freq.sort()
ans = 0
cnt = 1
for i in range(1, len(freq)):
	if freq[i] == freq[i - 1]:
		cnt -= -1
	else:
		ans = max(ans, cnt)
		cnt = 1
ans = max(ans, cnt)
print(ans)


import time, math, bisect
from sys import stdin, stdout

def I():
	return int(stdin.readline())

def Is():
	return str(stdin.readline())

def In():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def Si():
	return sorted(list(map(int, stdin.readline().split())))

def Si():
	return sorted(list(map(int, stdin.readline().split())), reverse=True)

def P(x):
	return stdout.write(str(x) + ' ')

def Pi(x):
	return stdout.write(str(x))

def solve():
	n = I()
	l1 = L()
	l2 = L()
	d = {}
	d1 = {}
	for i in range(0, len(l2)):
		d1[l2[i]] = i
	for i in range(0, len(l1)):
		m = d1[l1[i]]
		k = len(l1) - m + i
		if i - m >= 0:
			k = min(len(l1) - m + i, i - m)
		if k not in d:
			d[k] = 1
		else:
			d[k] += 1
	P(d[max(d, key=d.get)])
solve()


from collections import Counter

def ind(arr):
	l = [0 for i in range(len(arr))]
	for i in range(len(arr)):
		temp = arr[i]
		l[temp - 1] = i
	return l

def most_frequent(List):
	dict = {}
	(count, itm) = (0, '')
	for item in reversed(List):
		dict[item] = dict.get(item, 0) + 1
		if dict[item] >= count:
			(count, itm) = (dict[item], item)
	return itm

def match(a, b, n):
	x = ind(a)
	y = ind(b)
	z = [0] * n
	for i in range(n):
		if x[i] - y[i] >= 0:
			z[i] = x[i] - y[i]
		else:
			z[i] = n + x[i] - y[i]
	myvalue = most_frequent(z)
	print(z.count(myvalue))

def maximum(arr):
	temp = arr[0]
	for i in range(n):
		if arr[i] > temp:
			temp = arr[i]
	print(temp)
n = int(input(''))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
match(a, b, n)


import sys
input = sys.stdin.readline
t = 1
while t > 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	d = [0 for i in range(n + 1)]
	for i in range(n):
		d[a[i]] = i
	for i in range(n):
		b[i] = d[b[i]]
	d = {}
	for i in range(n):
		if (b[i] - i + n) % n not in d:
			d[(b[i] - i + n) % n] = 0
		d[(b[i] - i + n) % n] += 1
	maxi = 0
	for i in d:
		maxi = max(maxi, d[i])
	print(min(maxi, n))


def solve(n, a, b):
	mp = [-1] * n
	for (i, x) in enumerate(a):
		mp[x - 1] = i + 1
	for i in range(n):
		b[i] = mp[b[i] - 1]
	bb = b + b
	mdiff = {}
	sol = 0
	for (i, x) in enumerate(bb):
		bbdiff = i - x
		mdiff[bbdiff] = mdiff.get(bbdiff, 0) + 1
		if i >= n:
			ii = i - n
			mdiff[ii - bb[ii]] -= 1
		sol = max(sol, mdiff[bbdiff])
	return sol
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(solve(n, a, b))


from sys import stdin
input = stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
z = [0] * (n + 1)
for i in range(n):
	z[a[i]] = i
c = [0] * (n + 1)
ans = 0
for i in range(n):
	x = z[b[i]] - i
	if x < 0:
		x += n
	c[x] += 1
	ans = max(ans, c[x])
print(ans)


import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Da = {v: i for (i, v) in enumerate(A)}
C = Counter()
for (i, b) in enumerate(B):
	diff = i - Da[b]
	if diff < 0:
		diff += n
	C[diff] += 1
print(max(C.values()))


n = int(input())
a = [0] * (n + 1)
for (i, num) in enumerate(map(int, input().split())):
	a[num] = i + 1
d = {}
for (i, num) in enumerate(map(int, input().split())):
	t = a[num] - (i + 1)
	if t < 0:
		t = n + t
	d[t] = d.get(t, 0) + 1
ans = max(d.values())
print(ans)


n = int(input())
n2idx = {}
for (i, v) in enumerate(input().split()):
	v = int(v)
	n2idx[v] = i
offsets = {}
for (i, v) in enumerate(input().split()):
	v = int(v)
	t = n2idx[v]
	if t >= i:
		d = t - i
	else:
		d = n - i + t
	if d not in offsets:
		offsets[d] = 1
	else:
		offsets[d] += 1
print(max(offsets.values()))


import sys
max_int = 1000000001
min_int = -max_int
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
shift = {}
a_dict = {elem: num for (num, elem) in enumerate(a)}
for (num, elem) in enumerate(b):
	diff = num - a_dict[elem]
	if diff < 0:
		diff += n
	if diff in shift:
		shift[diff] += 1
	else:
		shift[diff] = 1
out = -1
for one in shift:
	out = max(out, shift[one])
print(out)


def solve():
	n = int(input())
	ll = list(map(int, input().split()))
	mp = {}
	for i in range(n):
		mp[ll[i]] = i + 1
	ll1 = list(map(int, input().split()))
	ans = 0
	mp1 = {}
	for i in range(n):
		temp = mp[ll1[i]] - i - 1
		if temp < 0:
			temp += n
		if temp in mp1:
			mp1[temp] += 1
		else:
			mp1[temp] = 1
		ans = max(ans, mp1[temp])
	return ans
t = 1
while t != 0:
	res = solve()
	print(res)
	t -= 1


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ind = [0 for i in range(n)]
for i in range(n):
	ind[a[i] - 1] += i
for i in range(n):
	ind[b[i] - 1] -= i
for i in range(n):
	if ind[i] < 0:
		ind[i] += n
from collections import Counter
c = Counter(ind)
ans = 1
for i in c:
	ans = max(ans, c[i])
print(ans)


from sys import stdin
input = stdin.readline
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = [0] * (n + 1)
for (i, j) in enumerate(a):
	d[j] = i
for (i, j) in enumerate(b):
	if d[j] - i < 0:
		d[j] += n
	d[j] = d[j] - i
d = Counter(d[1:])
print(max(list(d.values())))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {i: 0 for i in range(n)}
pos = [-1] * (n + 1)
for i in range(n):
	pos[b[i]] = i
for i in range(n):
	j = pos[a[i]]
	if i < j:
		d[n + i - j] += 1
	else:
		d[i - j] += 1
print(max(d.values()))


n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
ai = [-1] * n
for i in range(n):
	ai[a[i] - 1] = i
c = [0] * n
for i in range(n):
	ia = ai[b[i] - 1]
	if ia == i:
		c[0] += 1
	elif ia > i:
		c[ia - i] += 1
	else:
		c[n + ia - i] += 1
print(max(c))


n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
arr = list(zip(arr, range(0, n)))
arr.sort()
brr = list(zip(brr, range(0, n)))
brr.sort()
cnt = [0] * n
for i in range(n):
	cnt[(arr[i][1] - brr[i][1]) % n] += 1
print(max(cnt))


from collections import defaultdict, Counter
n = int(input())
a = map(int, input().split())
b = map(int, input().split())
brev = {}
for (i, bi) in enumerate(b):
	brev[bi] = i
shifts = Counter(((brev[ai] - i + n) % n for (i, ai) in enumerate(a)))
print(shifts.most_common(1)[0][1])


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
places = [0] * n
placesB = [0] * n
diff = [0] * n
for i in range(n):
	places[a[i] - 1] = i
for i in range(n):
	placesB[b[i] - 1] = i
for i in range(n):
	diff[i] = (n - places[i] + placesB[i]) % n
ats = [0] * n
for d in diff:
	ats[d] += 1
print(max(ats))


def maxRepeating(Arr, n, k):
	arr = Arr[:]
	for i in range(0, n):
		arr[arr[i] % k] += k
	max = arr[0]
	result = 0
	for i in range(1, n):
		if arr[i] > max:
			max = arr[i]
			result = i
	return result
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aindex = [0] * n
bindex = [0] * n
difarr = [0] * n
for i in range(n):
	aindex[a[i] - 1] = i
	bindex[b[i] - 1] = i
for i in range(n):
	if aindex[i] >= bindex[i]:
		difarr[i] = aindex[i] - bindex[i]
	else:
		difarr[i] = n - (bindex[i] - aindex[i])
print(difarr.count(maxRepeating(difarr, n, n)))


tam = int(input())
A = [(int(elem), i) for (i, elem) in enumerate(input().split())]
B = [(int(elem), i) for (i, elem) in enumerate(input().split())]
A.sort()
B.sort()
diff = [0 for i in range(tam)]
desl = tam - 1
for i in range(tam):
	if A[i][1] <= B[i][1]:
		pos = B[i][1] - A[i][1]
		diff[pos] += 1
	else:
		pos = tam - (A[i][1] - B[i][1])
		diff[pos] += 1
print(max(diff))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
indA = [0] * n
for i in range(n):
	indA[a[i] - 1] = i
indB = [0] * n
for i in range(n):
	indB[b[i] - 1] = i
left = []
for i in range(n):
	left.append((indA[i] - indB[i] + n) % n)
cnt = [0] * n
for i in range(n):
	cnt[left[i]] += 1
print(max(cnt))


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
n = inputnum()
a = inputlist()
b = inputlist()
d = {}
for i in range(n):
	d[a[i]] = i
for i in range(n):
	b[i] = (i - d[b[i]] + n) % n
b.sort()
cur = 1
most = 1
for i in range(1, n):
	if b[i] == b[i - 1]:
		cur += 1
	else:
		most = max(most, cur)
		cur = 1
print(max(cur, most))


n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
tmp = [0] * n
ans = [0] * n
for i in range(n):
	tmp[arr[i] - 1] += i
	tmp[brr[i] - 1] -= i
for i in range(n):
	ans[tmp[i] % n] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
dd = dict()
for i in range(n):
	d[a[i]] = i
	dd[b[i]] = i
l = []
from collections import defaultdict
l = defaultdict(int)
maxc = 0
for i in range(1, n + 1):
	l[(n + d[i] - dd[i]) % n] += 1
	maxc = max(maxc, l[(n + d[i] - dd[i]) % n])
print(maxc)


n = int(input())
a = {}
b = {}
totals = [0] * n
hold = [int(x) for x in input().split(' ')]
for i in range(len(hold)):
	a[hold[i]] = i
hold = [int(x) for x in input().split(' ')]
for i in range(len(hold)):
	b[hold[i]] = i
for (key, value) in b.items():
	totals[value - a[key]] += 1
print(max(totals))


n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
seg = []
dic = {}
for i in range(n):
	dic[arr1[i]] = [i]
for j in range(n):
	if dic[arr2[j]][0] > j:
		dic[arr2[j]].append(n + j)
	else:
		dic[arr2[j]].append(j)
dic2 = {}
for key in dic:
	if dic[key][1] - dic[key][0] not in dic2:
		dic2[dic[key][1] - dic[key][0]] = 1
	else:
		dic2[dic[key][1] - dic[key][0]] += 1
print(dic2[max(dic2.keys(), key=lambda k: dic2[k])])


import sys
from collections import Counter as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
a = I()
b = I()
idx = [0] * (n + 1)
x = [0] * (n + 1)
for i in range(n):
	idx[b[i]] = i
	x[a[i]] = i
an = 0
k = [0] * n
for i in range(1, n + 1):
	k[i - 1] = (x[i] - idx[i]) % n
c = cc(k)
print(max(c.values()))


import sys
sys.setrecursionlimit(10 ** 8)
try:
	FILE_POINTER = open('input.inpt')
	input = FILE_POINTER.readline
except:
	FILE_POINTER = None
	input = sys.stdin.readline
from collections import defaultdict
n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
d = {}
for i in range(n):
	d[a[i]] = i
dist = defaultdict(int)
for i in range(n):
	pos = d[b[i]]
	if i <= pos:
		k = pos - i
	else:
		k = n - i + pos
	dist[k] += 1
ans = 0
for (k, v) in dist.items():
	ans = max(ans, v)
print(ans)
if FILE_POINTER:
	FILE_POINTER.close()


def ans(arr1, arr2, n):
	d1 = {}
	for i in range(1, n + 1):
		d1[i] = 0
	for i in range(n):
		d1[arr1[i]] = i + 1
	d2 = {}
	for i in range(1, n + 1):
		d2[i] = 0
	for i in range(n):
		d2[arr2[i]] = i + 1
	v1 = list(d1.values())
	v2 = list(d2.values())
	d3 = {}
	for i in range(n):
		x = (v1[i] - v2[i] + n) % n
		if x not in d3:
			d3[x] = 1
		else:
			d3[x] += 1
	v3 = list(d3.values())
	return max(v3)
for j in range(1):
	n = int(input())
	A = input().split()
	B = input().split()
	arr1 = []
	arr2 = []
	for i in A:
		arr1.append(int(i))
	for i in B:
		arr2.append(int(i))
	print(ans(arr1, arr2, n))


(z, zz) = (input, lambda : list(map(int, z().split())))
(n, a, b) = (int(z()), zz(), zz())
h = [0] * n
l = [0] * n
for i in range(n):
	l[a[i] - 1] += i
	l[b[i] - 1] -= i
for i in range(n):
	h[l[i] % n] += 1
print(max(h))


R1 = lambda : list(map(int, input().split()))
R2 = lambda : int(input())
(n, a, b) = (R2(), R1(), R1())
c = [0] * n
d = [0] * n
for i in range(n):
	c[a[i] - 1] += i
	c[b[i] - 1] -= i
for i in c:
	d[i] += 1
print(max(d))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ad = {}
bd = {}
for i in range(n):
	ad[a[i]] = i
	bd[a[i]] = i
left = []
for i in range(n):
	temp = ad[b[i]]
	if i <= temp:
		left.append(abs(temp - i))
	else:
		left.append(n - abs(temp - i))
freq = [0] * (max(left) + 1)
for i in range(n):
	freq[left[i]] += 1
print(max(freq))


from math import *
from sys import stdin, stdout
input = stdin.buffer.readline
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
posa = []
posb = []
ans = []
for i in range(n):
	posa.append(-1)
	posb.append(-1)
	ans.append(0)
for i in range(n):
	posa[a[i] - 1] = i
	posb[b[i] - 1] = i
for i in range(n):
	ans[(posa[i] - posb[i]) % n] += 1
m = 0
for i in range(n):
	if ans[i] > m:
		m = ans[i]
print(m)


for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	inda = [0] * (n + 1)
	for i in range(n):
		inda[a[i]] = i
	ans = [0] * n
	for i in range(n):
		ind = inda[b[i]]
		if ind >= i:
			ans[ind - i] += 1
		else:
			ans[n - i + ind] += 1
	print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ia = [0] * n
ib = [0] * n
for i in range(n):
	ia[a[i] - 1] = i
	ib[b[i] - 1] = i
d = {}
for i in range(n):
	x = (ia[i] - ib[i] + n) % n
	d[x] = d.get(x, 0) + 1
print(max(d.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = [0] * (n + 3)
for i in range(n):
	r[b[i]] = i
l = [0] * (n + 3)
for i in range(n):
	if i < r[a[i]]:
		l[r[a[i]] - i] += 1
	else:
		l[r[a[i]] + n - i] += 1
ans = 0
for i in range(n + 1):
	ans = max(ans, l[i])
print(ans)


n = int(input())
a = input().split(' ')
b = input().split(' ')
mapA = [0] * (n + 1)
for i in range(n):
	mapA[int(a[i])] = i
mapB = [0] * (n + 1)
for i in range(n):
	ta = mapA[int(b[i])]
	tb = i
	k = -1
	if ta < tb:
		k = n - tb + ta
	else:
		k = ta - tb
	mapB[k] += 1
print(max(mapB))


def solution():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	vaIndex = [0 for i in range(n + 1)]
	vbIndex = [0 for i in range(n + 1)]
	for i in range(n):
		vaIndex[a[i]] = i
		vbIndex[b[i]] = i
	difCount = [0 for i in range(n)]
	maxCount = 0
	for i in range(1, n + 1):
		v = vaIndex[i] - vbIndex[i]
		if v < 0:
			v = v + n
		difCount[v] += 1
		maxCount = max(maxCount, difCount[v])
	print(maxCount)
solution()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = l()[0]
A = l()
B = l()
x = A.index(1)
y = B.index(1)
d1 = {}
for i in range(n):
	d1[A[i]] = i
d2 = {}
for i in range(n):
	d2[B[i]] = i
count = []
for i in range(1, n + 1):
	idx = d1[i] - d2[i]
	if idx < 0:
		idx += n
	count.append(idx)
m = {}
for i in range(n):
	if count[i] not in m:
		m[count[i]] = 0
	m[count[i]] += 1
mx = 0
for ks in m:
	if m[ks] > mx:
		mx = m[ks]
print(mx)


from collections import defaultdict

def solve(n, a, b):
	mapa = {}
	mapb = {}
	for i in range(n):
		mapa[a[i]] = i
		mapb[b[i]] = i
	ans = defaultdict(int)
	for (key, val) in mapa.items():
		apos = val
		bpos = mapb[key]
		if apos <= bpos:
			ans[bpos - apos] += 1
		else:
			ans[n - apos + bpos] += 1
	ans = ans.values()
	return max(ans)
inp = input().split()
n = int(inp[0])
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
print(solve(n, a, b))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
x = {}
y = {}
for i in range(n):
	d[b[i]] = i
for i in range(n):
	t = i - d[a[i]]
	if t > 0:
		if t in x:
			x[t] += 1
		else:
			x[t] = 1
		if n - t in y:
			y[n - t] += 1
		else:
			y[n - t] = 1
	else:
		t = abs(t)
		if t in y:
			y[t] += 1
		else:
			y[t] = 1
		if n - t in x:
			x[n - t] += 1
		else:
			x[n - t] = 1
print(max(max(x.values()), max(y.values())))


n = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
dis = {}
L = {}
R = {}
(maxL, maxR) = (0, 0)
k = 0
for i in B:
	dis[i] = k
	k += 1
for i in range(n):
	p = A[i]
	ind = dis[p]
	if ind - i > 0:
		l = ind - i
		r = n - l
	elif i - ind > 0:
		r = i - ind
		l = n - r
	elif i == ind:
		l = r = 0
	if l in L:
		L[l] += 1
	else:
		L[l] = 1
	if r in R:
		R[r] += 1
	else:
		R[r] = 1
	maxL = max(maxL, L[l])
	maxR = max(maxR, R[r])
print(max(maxL, maxR))


n = int(input())
(a, b) = ([int(i) for i in input().split()], [int(i) for i in input().split()])
list = [0] * (n + 1)
for (ind, el) in enumerate(a):
	list[el] += ind
for (ind, el) in enumerate(b):
	list[el] -= ind
del list[0]
for ind in range(n):
	list[ind] += n if list[ind] < 0 else 0
counting = [0] * (n + 1)
for ind in range(n):
	counting[list[ind]] += 1
print(max(counting))


from collections import Counter
n = int(input())
sa = list(map(int, input().split()))
sb = list(map(int, input().split()))
q = [-10] * (n + 1)
for i in range(n):
	q[sa[i]] = i
for i in range(n):
	b = i - q[sb[i]]
	if b < 0:
		b = b + n
	q[sb[i]] = b
ans = dict(Counter(q))
print(max(ans.values()))


def count_equals(arr1, arr2, x):
	n = len(arr1)
	ct = 0
	for i in range(n):
		if arr1[i] == arr2[(i + x) % n]:
			ct += 1
	return ct
n = int(input())
arr1 = list(map(lambda x: int(x) - 1, input().split()))
arr2 = list(map(lambda x: int(x) - 1, input().split()))
ma = 0
pos1 = [0] * n
pos2 = [0] * n
for i in range(n):
	pos1[arr1[i]] = i
	pos2[arr2[i]] = i
ct = [0] * n
for i in range(n):
	ct[(pos1[i] - pos2[i] + n) % n] += 1
print(max(ct))


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
from collections import defaultdict as dd, Counter
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
db = dd(int)
for i in range(n):
	db[b[i]] = i
ans = []
for i in range(n):
	ans.append(i - db[a[i]])
for i in range(n):
	ans[i] = ans[i] % n
d = Counter(ans)
print(max(d.values()))


from bisect import bisect_left as lower_bound, bisect_right as upper_bound
from sys import stdin, stdout
from collections import defaultdict

def solve(arr, n):
	pass

def main():
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	ma = {i: [] for i in range(1, n + 1)}
	for (index, num) in enumerate(a):
		ma[num].append(index)
	for (index, num) in enumerate(b):
		ma[num].append(index)
	cnt = {}
	ret = 0
	for i in range(1, n + 1):
		diff = ma[i][1] - ma[i][0]
		if diff < 0:
			diff = n - abs(diff)
		cnt[diff] = cnt.get(diff, 0) + 1
		ret = max(ret, cnt[diff])
	print(ret)
main()


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
right = {}
aindex = {}
bindex = {}
for i in range(n):
	aindex[a[i]] = i
for i in range(n):
	bindex[b[i]] = i
for i in range(1, n + 1):
	if bindex[i] > aindex[i]:
		right[i] = bindex[i] - aindex[i]
	else:
		right[i] = n - aindex[i] + bindex[i]
left = {}
for i in range(1, n + 1):
	if bindex[i] > aindex[i]:
		left[i] = aindex[i] + (n - bindex[i])
	else:
		left[i] = aindex[i] - bindex[i]
aindexcount = {}
bindexcount = {}
for i in left:
	if left[i] in aindexcount:
		aindexcount[left[i]] += 1
	else:
		aindexcount[left[i]] = 1
for i in right:
	if right[i] in bindexcount:
		bindexcount[right[i]] += 1
	else:
		bindexcount[right[i]] = 1
(firstmax, secondmax) = (0, 0)
for i in aindexcount:
	firstmax = max(firstmax, aindexcount[i])
for i in bindexcount:
	secondmax = max(secondmax, bindexcount[i])
print(max(firstmax, secondmax))


from collections import Counter
am = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
am = len(a)
swap = [0] * am
swapSec = [0] * am
for i in range(am):
	swap[a[i] - 1] = i
	swapSec[a[i] - 1] = i
for i in range(am):
	swap[b[i] - 1] -= i
	if swap[b[i] - 1] < 0:
		swap[b[i] - 1] = abs(am + swap[b[i] - 1])
print(Counter(swap).most_common()[0][1])
print()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = [0] * (n + 1)
for i in range(n):
	diff[a[i]] += i
	diff[b[i]] -= i
del diff[0]
for i in range(n):
	diff[i] %= n
from collections import *
print(max(Counter(diff).values()))


n = int(input())
B = list(map(int, input().split()))
A = list(map(int, input().split()))
C = [0 for i in range(n + 1)]
D = [0 for i in range(n + 1)]
for i in range(n):
	C[B[i]] = i
	D[A[i]] = i
CD = [0 for i in range(n + 1)]
for i in range(1, n + 1):
	if D[i] - C[i] <= 0:
		CD[D[i] - C[i] + n] = CD[D[i] - C[i] + n] + 1
	else:
		CD[D[i] - C[i]] = CD[D[i] - C[i]] + 1
mv = 0
for i in range(n + 1):
	mv = max(mv, CD[i])
print(mv)


from sys import stdin, stdout
n = int(stdin.readline())
arr = list(map(int, stdin.readline().strip().split()))
per = list(map(int, stdin.readline().strip().split()))
perr = dict()
for i in range(n):
	perr[per[i]] = i
pos = [0] * 200002
for i in range(n):
	x = perr.get(arr[i])
	if x >= i:
		pos[x - i] += 1
	else:
		pos[n - i + x] += 1
print(max(pos))


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	n = int(input())
	a = inar()
	b = inar()
	dp = defaultdict(int)
	for i in range(n):
		dp[a[i]] = i
	dL = defaultdict(int)
	dR = defaultdict(int)
	for i in range(n):
		u = dp[b[i]]
		l = i
		if u <= l:
			dL[abs(u - l)] += 1
			dR[n - abs(u - l)] += 1
		else:
			dR[abs(u - l)] += 1
			dL[n - abs(u - l)] += 1
	mx = 0
	for i in dL.keys():
		mx = max(mx, max(dL[i], dR[i]))
	print(mx)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import statistics
from statistics import mode
n = int(input())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
dct = {}
lst3 = []
for (i, item) in enumerate(lst1):
	dct[item] = i
for (i, item) in enumerate(lst2):
	if i > dct[item]:
		lst3.append(dct[item] + n - i)
	else:
		lst3.append(dct[item] - i)
c = mode(lst3)
print(lst3.count(c))


import sys
import string
input = sys.stdin.readline
import math
from operator import xor
p = 10 ** 9 + 7
n = int(input())
a_ind = {}
b_ind = {}
counter = [0 for i in range(2 * n)]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for j in range(len(a)):
	a_ind[a[j]] = j
for j in range(len(b)):
	b_ind[b[j]] = j + 1
for j in range(1, n + 1):
	counter[n + a_ind[j] - b_ind[j]] += 1
for j in range(n):
	counter[j + n] += counter[j]
print(max(counter))


import math as mt
import sys, string
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heapify, heappop
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
a = L()
b = L()
ans = 1
d = defaultdict(int)
d2 = defaultdict(int)
d3 = defaultdict(int)
g = 0
for i in range(n):
	d[a[i]] = i
m = 1
for i in range(n):
	x = d[b[i]] - i
	if x <= 0:
		x += n
	d2[d[x]] += 1
	m = max(m, d2[d[x]])
print(m)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
j = 0
ans = 0
pos = {}
for i in range(n):
	pos[a[i]] = i
rec = {}
for i in range(n):
	temp = pos[b[i]] - i
	if temp < 0:
		temp += n
	rec[temp] = rec.get(temp, 0) + 1
ans = 0
for i in rec.keys():
	ans = max(ans, rec[i])
print(ans)


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
indA = [None] * (n + 1)
indB = [None] * (n + 1)
for i in range(n):
	indA[a[i]] = i
	indB[b[i]] = i
dic = {}
ans = [0] * n
for i in range(1, n + 1):
	now = (indA[i] - indB[i]) % n
	ans[now] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dic = {}
z = {}
x = {}
cnt = 1
for i in range(n):
	z[a[i]] = i
for i in range(n):
	x[b[i]] = i
for i in range(1, n + 1):
	d = x[i] - z[i]
	if d > 0:
		d = d - n
	try:
		dic[d] += 1
	except:
		dic[d] = 1
print(max(dic.values()))


from collections import defaultdict as dd
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dd(int)
for i in range(n):
	d[b[i]] = i
ans = Counter()
for i in range(n):
	p = d[a[i]]
	if p >= i:
		ans.update({p - i: 1})
	else:
		ans.update({n - (i - p): 1})
print(max(ans.values()))


import sys
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
a = I()
b = I()
idx = {}
for i in range(n):
	idx[a[i]] = i
count = dd(int)
ans = 1
for i in range(n):
	count[(idx[b[i]] - i) % n] += 1
	ans = max(ans, count[(idx[b[i]] - i) % n])
print(ans)


x = int(input())
lt = list(map(int, input().split()))
mt = list(map(int, input().split()))
ans = [0] * x
mp = [-1] * (x + 1)
for i in range(x):
	mp[lt[i]] = i
for i in range(x):
	j = mp[mt[i]]
	if j - i >= 0:
		ans[j - i] += 1
	else:
		ans[x + j - i] += 1
print(max(ans))


import sys
n = int(sys.stdin.readline())
a = [int(i) for i in sys.stdin.readline().split()]
b = [int(i) for i in sys.stdin.readline().split()]
d = {}
for (i, ai) in enumerate(a):
	d[ai] = i
	offsets = {}
for (i, bi) in enumerate(b):
	aloc = d[bi]
	offsets[(i - aloc + n) % n] = offsets.get((i - aloc + n) % n, 0) + 1
ans = 0
for k in offsets.keys():
	ans = max(ans, offsets[k])
print(ans)


import sys
import collections
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(a_loc, b_loc) = ([0] * (n + 1), [0] * (n + 1))
for i in range(n):
	a_loc[a[i] - 1] = i
	b_loc[b[i] - 1] = i
c = [a_loc[i] - b_loc[i] for i in range(n)]
res = 0
cnt = collections.Counter(c)
for k in cnt.keys():
	res = max(res, cnt[k] + cnt[k - n], cnt[k] + cnt[k + n])
print(res)


from sys import stdin

def readline():
	return stdin.readline()

def solve(n, a, b):
	shifts = []
	pos = [0] * n
	for i in range(0, n):
		pos[b[i]] = i
	for i in range(0, n):
		shift = i - pos[a[i]]
		if shift < 0:
			shift += n
		shifts.append(shift)
	shifts.sort()
	result = 1
	shifts = [-1, *shifts]
	for i in range(1, n + 1):
		if shifts[i] != shifts[i - 1]:
			pos = i + 1
			while pos < n + 1 and shifts[i] == shifts[pos]:
				pos += 1
			result = max(result, pos - i)
	return result
n = int(readline().rstrip('\n'))
a = list(map(lambda x: int(x) - 1, readline().split(' ')))
b = list(map(lambda x: int(x) - 1, readline().split(' ')))
print(solve(n, a, b))


import sys

def arr():
	return list(map(int, input().split()))
input = sys.stdin.readline
from collections import defaultdict
import math
N = int(input())
L1 = arr()
L2 = arr()
Hash = defaultdict(lambda : 0)
for i in range(N):
	Hash[L2[i]] = i
Ha = defaultdict(lambda : 0)
for i in range(N):
	diff = Hash[L1[i]] - i
	if diff < 0:
		diff = diff + N
	Ha[diff] += 1
ma = 0
for (i, j) in Ha.items():
	ma = max(ma, j)
print(ma)


from math import *

def r1(t):
	return t(input())

def r2(t):
	return [t(i) for i in input().split()]

def r3(t):
	return [t(i) for i in input()]
n = r1(int)
a = r2(int)
b = r2(int)
m1 = {}
m2 = {}
for i in range(n):
	m1[i] = 0
	m2[i] = 0
ia = [0] * n
ib = [0] * n
for i in range(n):
	ia[a[i] - 1] = i
	ib[b[i] - 1] = i
for i in range(n):
	x = ib[i]
	y = ia[i]
	i1 = (x - y + n) % n
	i2 = (y - x + n) % n
	m1[i1] += 1
	m2[i2] += 1
print(max(max(m1.values()), max(m2.values())))


n = int(input())
first = {key: value for (key, value) in zip(map(int, input().split()), range(n))}
second = list(map(int, input().split()))
values = {}
for i in range(n):
	p = second[i]
	value_right = f"{abs(n - abs(i - first[p]))} {('r' if i - first[p] > 0 else 'l')}"
	value_left = f"{abs(i - first[p])} {('l' if i - first[p] > 0 else 'r')}"
	if value_left not in values:
		values[value_left] = 0
	if value_right not in values:
		values[value_right] = 0
	values[value_left] += 1
	values[value_right] += 1
print(max(values.values()))


s = int(input())
a = input().split()
b = input().split()
a_positions = {a: i for (i, a) in enumerate(a)}
distances = [0] * s
for (i, b) in enumerate(b):
	distances[(a_positions[b] - i) % s] += 1
print(max(distances))


import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
table = [0] * (N + 1)
for i in range(N):
	table[b[i]] = i
shift = [0] * N
for i in range(N):
	shift[i] = (table[a[i]] - i) % N
c = [0] * N
for x in shift:
	c[x] += 1
print(max(c))


from sys import stdin, stdout
import math
n = int(stdin.readline().strip())
a = list(map(int, stdin.readline().strip().split(' ')))
b = list(map(int, stdin.readline().strip().split(' ')))
ia = {}
ib = {}
for i in range(len(a)):
	ia[a[i]] = i
for i in range(len(b)):
	ib[b[i]] = i
diffarr = []
for i in range(1, n + 1):
	if ia[i] < ib[i]:
		diffarr.append(ib[i] - ia[i])
	else:
		diffarr.append(ib[i] + (n - ia[i]))
d = {}
ans = -1
for i in diffarr:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	if d[i] > ans:
		ans = d[i]
stdout.write(str(ans) + '\n')


import sys
input = sys.stdin.readline
from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split() if i != '\n']
b = [int(i) for i in input().split() if i != '\n']
inda = [0] * n
indb = [0] * n
for i in range(n):
	inda[a[i] - 1] = i
	indb[b[i] - 1] = i
diff = defaultdict(int)
for i in range(n):
	if inda[i] - indb[i] < 0:
		pq = n + (inda[i] - indb[i])
	else:
		pq = inda[i] - indb[i]
	diff[pq] += 1
maxa = 0
for i in diff:
	maxa = max(maxa, diff[i])
sys.stdout.write(str(maxa) + '\n')


import sys
input = sys.stdin.readline
n = int(input())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
posix = [0] * (n + 1)
for i in range(n):
	posix[a[i]] = i
moveVal = [0] * (n + 1)
for i in range(n):
	move = posix[b[i]] - i
	if move < 0:
		move += n
	moveVal[move] += 1
print(max(moveVal))


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l1 = [0] * n
for j in range(n):
	l1[b[j] - 1] = j
l = {}
for j in range(n):
	right = l1[a[j] - 1]
	if right < j:
		d = n - j + right
	else:
		d = right - j
	if l.get(d) == None:
		l[d] = 0
	l[d] += 1
print(max(l.values()))


n = int(input())
a = {}
i = 0
for j in list(map(int, input().split())):
	a[j] = i
	i += 1
b = {}
i = 0
for j in list(map(int, input().split())):
	b[j] = i
	i += 1
c = {}
for i in range(n):
	c[i] = 0
for i in range(1, n + 1):
	if a[i] == b[i]:
		c[0] += 1
	elif a[i] < b[i]:
		c[b[i] - a[i]] += 1
	else:
		c[n - a[i] + b[i]] += 1
print(max(c.values()))


from collections import defaultdict

class Solution:

	def __init__(self):
		n = int(input())
		a = list(map(lambda x: int(x) - 1, input().split()))
		b = list(map(lambda x: int(x) - 1, input().split()))
		self.solve(n, a, b)

	def solve(self, n, a, b):
		px = [0 for i in range(n)]
		py = [0 for i in range(n)]
		for i in range(n):
			px[a[i]] = i
			py[b[i]] = i
		d = defaultdict(lambda : 0)
		for (x, y) in zip(px, py):
			d[(x - y + n) % n] += 1
		print(max(d.values()))
Solution()


n = int(input())
arr1 = [int(c) for c in input().split()]
arr2 = [int(c) for c in input().split()]
dic1 = {}
dic2 = {}
for i in range(n):
	dic1[arr1[i]] = i
	dic2[arr2[i]] = i
lshift = [0 for i in range(n)]
rshift = [0 for i in range(n)]
lcount = {}
rcount = {}
for i in range(n):
	dig = arr1[i]
	ind = dic2[dig]
	if ind <= i:
		lsh = i - ind
	else:
		lsh = i + (n - ind)
	if ind >= i:
		rsh = ind - i
	else:
		rsh = ind + n - i
	lshift[i] = lsh
	rshift[i] = rsh
for i in range(n):
	lcount[lshift[i]] = lcount.get(lshift[i], 0) + 1
	rcount[rshift[i]] = rcount.get(rshift[i], 0) + 1
ans = 1
for i in lcount.keys():
	ans = max(ans, lcount[i])
for i in rcount.keys():
	ans = max(ans, rcount[i])
print(ans)


from operator import sub
n = int(input())
shifts = [0] * n
for i in map(sub, *[sorted(range(n), key=list(map(int, input().split())).__getitem__) for _ in 'ab']):
	shifts[i] += 1
print(max(shifts))


def main():
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	offset = {}
	pos = {}
	for i in range(N):
		pos[B[i]] = i
	for i in range(N):
		cur = pos[A[i]] - i
		if cur < 0:
			cur += N
		if cur not in offset:
			offset[cur] = 1
		else:
			offset[cur] += 1
	print(max(offset.values()))
main()


from collections import Counter
n = int(input())
ai = list(map(int, input().split()))
bi = list(map(int, input().split()))
indexlist = [0] * (n + 1)
clockwise = []
for i in range(n):
	indexlist[bi[i]] = i
for i in range(0, n):
	if ai[i] == bi[i]:
		clockwise.append(0)
	elif indexlist[ai[i]] < i:
		clockwise.append(abs(i - indexlist[ai[i]]))
	elif indexlist[ai[i]] > i:
		clockwise.append(n - indexlist[ai[i]] + i)
print(Counter(clockwise).most_common()[0][1])


def main():
	import sys
	from collections import defaultdict
	input = sys.stdin.readline
	sys.setrecursionlimit(10 ** 6)
	N = int(input())
	an = {int(x): i for (i, x) in enumerate(input().strip().split())}
	bn = {int(x): i for (i, x) in enumerate(input().strip().split())}
	diff = defaultdict(int)
	ans = 0
	for n in range(1, N + 1):
		diff[(an[n] - bn[n]) % N] += 1
		ans = max(ans, diff[(an[n] - bn[n]) % N])
	print(ans)
main()


from collections import defaultdict
e = defaultdict(int)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = {}
d = {}
for i in range(n):
	c[a[i]] = i
	d[b[i]] = i
for i in range(n):
	s = d[a[i]]
	if s > i:
		e[i + n - s] += 1
	else:
		e[i - s] += 1
res = 0
for i in e.keys():
	res = max(res, e[i])
print(res)


n = int(input())
a = list(map(int, input().split()))
revA = []
b = list(map(int, input().split()))
revB = []
diffCount = []
for i in range(n):
	revA.append(-1)
	revB.append(-1)
	diffCount.append(0)
for i in range(n):
	revA[a[i] - 1] = i
	revB[b[i] - 1] = i
for i in range(n):
	diffCount[(revA[i] - revB[i]) % n] += 1
maxMatch = 0
for i in range(n):
	if maxMatch < diffCount[i]:
		maxMatch = diffCount[i]
print(maxMatch)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l1 = [0] * (n + 1)
l2 = [0] * (n + 1)
for i in range(n):
	l1[a[i]] = i
for i in range(n):
	l2[b[i]] = i
t = [0] * (n + 1)
for i in range(1, n + 1):
	x = l1[i] - l2[i]
	if x >= 0:
		y = x - n
	else:
		y = x + n
	if abs(x) == min(abs(x), abs(y)):
		t[x + n // 2] += 1
	elif abs(y) == min(abs(x), abs(y)):
		t[y + n // 2] += 1
print(max(t))


def diff(a, b, num):
	n = a[num]
	d = num - c[n] % len(a)
	if d < 0:
		d = len(a) + d
	return d
n = int(input())
a = [int(i) - 1 for i in input().split(' ')]
b = [int(i) - 1 for i in input().split(' ')]
c = [None for i in range(n)]
for (p, e) in enumerate(b):
	c[e] = p
diffs = [diff(a, c, i) for i in range(n)]
distances = {}
maximum = 0
for d in diffs:
	if d in distances:
		distances[d] += 1
	else:
		distances[d] = 1
	maximum = max(maximum, distances[d])
print(maximum)


n = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = i
x = [0] * n
for i in range(n):
	j = d[b[i]]
	if j < i:
		x[i] = n - i + j
	else:
		x[i] = j - i
z = [0] * (n + 1)
for i in range(n):
	z[x[i]] += 1
print(max(z))


from math import *
from collections import *
from operator import itemgetter
import bisect
from heapq import *
i = lambda : input()
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
chrIdx = lambda x: ord(x) - 96
idxChr = lambda x: chr(96 + x)
t = 1
for _ in range(t):
	n = ii()
	a = iia()
	b = iia()
	c = [0] * n
	d = [0] * n
	for i in range(n):
		c[a[i] - 1] = i + 1
	for i in range(n):
		d[b[i] - 1] = c[b[i] - 1] - i
	for i in range(n):
		if d[i] < 0:
			d[i] = d[i] % n
	x = dict(Counter(d))
	y = list(x.values())
	y.sort()
	print(y[-1])


import sys
input = sys.stdin.buffer.readline
n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
if arr1 == arr2:
	print(n)
else:
	da = dict()
	db = dict()
	for i in range(n):
		da.update({arr1[i]: i})
		db.update({arr2[i]: i})
	ans = []
	for i in range(1, n + 1):
		ans.append((da[i] - db[i]) % n)
	ans.sort()
	anss = 0
	count = 1
	for i in range(n - 1):
		if ans[i] == ans[i + 1]:
			count += 1
		else:
			if count > anss:
				anss = count
			count = 1
	if count > anss:
		anss = count
	print(anss)


from sys import stdin
from collections import defaultdict
n = int(stdin.readline())
a = list(map(int, stdin.readline().rstrip().split(' ')))
b = list(map(int, stdin.readline().rstrip().split(' ')))
ad = {}
bd = {}
for i in range(n):
	ad[a[i]] = i
	bd[b[i]] = i
diffs = defaultdict(lambda : 0)
keys = list(ad.keys())
for i in range(n):
	key = keys[i]
	idx1 = i
	idx2 = bd[key]
	if idx2 >= idx1:
		diff = idx2 - idx1
	else:
		diff = n - (idx1 - idx2)
	diffs[diff] += 1
keymax = max(diffs, key=diffs.get)
print(diffs[keymax])


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
xl1 = [0] * n
xl2 = [0] * n
xl = [0] * n
champ = 0
for i in range(n):
	xl1[l1[i] - 1] = i
	xl2[l2[i] - 1] = i
for i in range(n):
	temp = xl1[i] - xl2[i]
	if temp < 0:
		temp += n
	xl[temp] += 1
print(max(xl))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = [0] * n
id_a = [0] * n
id_b = [0] * n
for i in range(n):
	id_a[a[i] - 1] = i
for i in range(n):
	id_b[b[i] - 1] = i
for i in range(n):
	cnt[(id_a[i] - id_b[i] + n) % n] += 1
ans = 0
for i in range(n):
	ans = max(ans, cnt[i])
print(ans)


import sys
import math
import collections
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split(' ')))
b = list(map(int, sys.stdin.readline().strip().split(' ')))
aa = {}
bb = {}
for i in range(n):
	aa[a[i]] = i + 1
	bb[b[i]] = i + 1
res = collections.defaultdict(int)
for i in range(1, n + 1):
	distanceRight = bb[i] - aa[i]
	distanceLeft = distanceRight
	if distanceRight < 0:
		distanceLeft = distanceRight % n
	else:
		distanceLeft -= n
	res[distanceRight] += 1
	res[distanceLeft] += 1
print(max(res.values()))


import sys
input = sys.stdin.readline
import heapq
import copy
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

class Node:

	def _init_(self, val):
		self.data = val
		self.left = None
		self.right = None

def pre_sum(arr):
	p = [0]
	for i in arr:
		p.append(p[-1] + i)
	p.pop(0)
	return p

def pre_back(arr):
	p = [0]
	for i in arr:
		p.append(p[-1] + i)
	p.pop(0)
	return p

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def search_leftmost(arr, val):

	def helper(arr, l, r, val):
		print(l, r)
		if arr[l] == val:
			return l
		if r - l <= 1:
			if arr[r] == val:
				return r
			else:
				print('not found')
				return
		mid = int((r + l) / 2)
		if arr[mid] >= val:
			return helper(arr, l, mid, val)
		else:
			return helper(arr, mid, r, val)
	return helper(arr, 0, len(arr) - 1, val)

def search_rightmost(arr, val):

	def helper(arr, l, r, val):
		print(l, r)
		if arr[r] == val:
			return r
		if r - l <= 1:
			if arr[l] == val:
				return r
			else:
				print('not found')
				return
		mid = int((r + l) / 2)
		if arr[mid] > val:
			return helper(arr, l, mid, val)
		else:
			return helper(arr, mid, r, val)
	return helper(arr, 0, len(arr) - 1, val)

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = 1
	mod = 1000000007
	limit = 10 ** 18
	for test in range(tests):
		n = inp()
		a = inlt()
		b = inlt()
		hashm = {}
		for i in range(len(a)):
			hashm[a[i]] = i
		ans = [0 for i in range(n)]
		for i in range(len(b)):
			ans[(i - hashm[b[i]]) % n] += 1
		print(max(ans))
main()


t = int(input())
code_a = list(map(int, input().split(' ')))
code_b = list(map(int, input().split(' ')))

def from_list_to_dict(perm):
	pos = dict()
	length = len(perm)
	for i in range(length):
		pos[perm[i]] = i
	return pos
pos_a = from_list_to_dict(code_a)
pos_b = from_list_to_dict(code_b)
shift = [0] * t
for i in range(1, t + 1):
	shift[(pos_a[i] - pos_b[i]) % t] += 1
print(max(shift))


import sys
input = sys.stdin.buffer.readline
from collections import Counter

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = [0] * (n + 1)
	r = [0] * (n + 1)
	da = [0] * (n + 1)
	db = [0] * (n + 1)
	ansl = [0] * 1000000
	ansr = [0] * 1000000
	for i in range(n):
		da[a[i]] = i + 1
		db[b[i]] = i + 1
	else:
		for i in range(1, n + 1):
			if da[i] > db[i]:
				x = da[i] - db[i]
				l[i] = x
				y = n - da[i] + db[i]
				r[i] = y
			else:
				x = abs(da[i] - db[i])
				r[i] = x
				y = da[i] + n - db[i]
				l[i] = y
			ansl[l[i]] += 1
			ansr[r[i]] += 1
		print(max(max(ansl), max(ansr)))
solution()


from sys import stdin
n = int(input())
l1 = list(map(int, stdin.readline().rstrip().split(' ')))
l2 = list(map(int, stdin.readline().rstrip().split(' ')))
d1 = {}
d2 = {}
d3 = {}
for i in range(1, n + 1):
	d1[l1[i - 1]] = i
	d2[l2[i - 1]] = i
for i in range(1, n + 1):
	if d2[i] - d1[i] < 0:
		val = n + d2[i] - d1[i]
	else:
		val = d2[i] - d1[i]
	if not d3.get(val, 0):
		d3[val] = 0
	d3[val] += 1
extra = max(d3.get(-n + 1, 0) + d3.get(1, 0), d3.get(-1, 0) + d3.get(n - 1, 0))
print(max(extra, max(d3.values())))


num = int(input())
ft = list(map(int, input().split()))
st = list(map(int, input().split()))
ans = [0] * (num + 1)
for i in range(num):
	ans[ft[i]] = i
mx = [0] * (num + 1)
for i in range(num):
	j = ans[st[i]]
	if i - j > 0:
		mx[i - j] += 1
	else:
		mx[num + (i - j)] += 1
print(max(mx))


n = int(input())
count = {}
arr_a = list(map(int, input().split()))
arr_b = list(map(int, input().split()))
for i in range(0, n):
	ele_a = arr_a[i]
	ele_b = arr_b[i]
	if ele_a in count:
		count[ele_a] += i
	else:
		count[ele_a] = i
	if ele_b in count:
		count[ele_b] -= i
	else:
		count[ele_b] = -i
rotation = {}
for i in count:
	val = count[i]
	if val < 0:
		val += n
	if val in rotation:
		rotation[val] += 1
	else:
		rotation[val] = 1
ans = 0
for i in rotation:
	val = rotation[i]
	ans = max(ans, val)
print(ans)


import sys
import collections as cc
import bisect as bi
I = lambda : list(map(int, input().split()))
for tc in range(1):
	(n,) = I()
	a = I()
	b = I()
	if a == b:
		print(n)
		break
	x = cc.defaultdict(int)
	y = cc.defaultdict(int)
	for i in range(n):
		x[a[i]] = i
		y[b[i]] = i
	l = [0] * (n + 1)
	r = [0] * (n + 1)
	for i in range(1, n + 1):
		tem = y[i] - x[i]
		if tem > 0:
			l[abs(tem)] += 1
			r[n - abs(y[i] - x[i])] += 1
		elif tem < 0:
			r[abs(tem)] += 1
			l[n - abs(y[i] - x[i])] += 1
	aa = max(l)
	bb = max(r)
	print(max(aa, bb))


import sys
import math

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def printspx(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')

def printchk(*args):
	return print(*args, end=' \\ ')
MODPRIME = int(1000000000.0 + 7)
BABYMODPR = 998244353
from collections import defaultdict
n = int(input())
a = get_list()
b = get_list()
d1 = {}
d2 = {}
for i in range(n):
	d1[a[i]] = i
	d2[b[i]] = i
ans = {}
for i in range(1, n + 1):
	val = d1[i] - d2[i]
	if val < 0:
		val += n
	try:
		ans[val] += 1
	except:
		ans[val] = 1
ansmax = 1
for (k, v) in ans.items():
	if v > ansmax:
		ansmax = v
print(ansmax)


import math as mt

def m(arr, n):
	Hash = dict()
	for i in range(n):
		if arr[i] in Hash.keys():
			Hash[arr[i]] += 1
		else:
			Hash[arr[i]] = 1
	max_count = 0
	res = -1
	for i in Hash:
		if max_count < Hash[i]:
			res = i
			max_count = Hash[i]
	return res
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
d = {}
dp = []
for i in range(n):
	d[a[i]] = i
for i in range(n):
	if d[b[i]] > i:
		x = i + n - d[b[i]]
	else:
		x = i - d[b[i]]
	dp.append(x)
d = m(dp, n)
print(dp.count(d))


from collections import defaultdict

def match_twist(arr1, arr2):
	map2 = {arr2[i]: i for i in range(len(arr2))}
	buckets = defaultdict(lambda : 0)
	for index1 in range(len(arr2)):
		index2 = map2[arr1[index1]]
		diff = index1 - index2
		if diff < 0:
			diff += len(arr1)
		buckets[diff] += 1
	return max(buckets.values())

def get_arr():
	arr = input().split()
	return [int(el) for el in arr]
_ = input()
(arr1, arr2) = (get_arr(), get_arr())
print(match_twist(arr1, arr2))


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in range(base ** n):
		s = [tb // base ** bt % base for bt in range(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, ls=None, init=True, index=1):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			if ls == None:
				self.stdin(inp_size, index=index)
			else:
				self.size = len(ls) + 1
				(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.size = int(input())
		else:
			self.size = inp_size
		(self.edges, _) = GI(self.size, self.size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.size = len(ls) + 1
		(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def dfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def bfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.size
		v[x] = root_v
		while q:
			c = q.popleft()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def parent(self, x):
		return self.dfs(0, func=lambda pr, prv, nx, dist: pr, root_v=-1)

	def topological_sort(self, x):
		tps = []
		q = deque([x])
		v = [None] * self.size
		v[x] = 0
		while q:
			c = q.popleft()
			tps.append(c)
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = 0
		return tps

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.size
		self.ETout = [-1] * self.size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

	def __str__(self):
		return str(self.edges)

	def show(self):
		if all([all([d == 1 for (nd, d) in edge]) for edge in self.edges]):
			print([[nd for (nd, d) in edge] for edge in self.edges])
		else:
			print(self)

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))])

	def query_id(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][max(0, r - (1 << N))])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))]):
			b = a
		return b

	def right_bound(self, pos, x):
		k = (self.size - pos).bit_length()
		for j in range(k)[::-1]:
			nx = pos + (1 << j)
			if nx < n and self.query(pos, nx + 1) <= x:
				pos += 1 << j
		return pos

	def left_bound(self, pos, x):
		k = pos.bit_length()
		for j in range(k)[::-1]:
			nx = pos - (1 << j)
			if 0 <= nx and self.query(nx, pos + 1) <= x:
				pos -= 1 << j
		return pos

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)
show_flg = False
show_flg = True
ans = 0
for _ in range(1):
	ans = 0
	n = I()
	a = LI_()
	b = LI_()
	p = [0] * n
	m = [0] * n
	for i in range(n):
		p[a[i]] = i
	for i in range(n):
		m[(p[b[i]] - i) % n] += 1
	ans = max(m)
	print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0] * (n + 1)
shifts = [0] * n
for i in range(len(a)):
	pos[a[i]] = i
for i in range(len(b)):
	sh = pos[b[i]] - i
	if sh < 0:
		sh += n
	shifts[sh] += 1
print(max(shifts))


import sys
from collections import defaultdict, deque

def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	p = {}
	for i in range(n):
		p[a[i]] = i
	c = defaultdict(int)
	b = [int(x) for x in input().split()]
	for i in range(n):
		e = b[i]
		c[(n + p[e] - i) % n] += 1
	ans = 0
	for k in c:
		ans = max(ans, c[k])
	print(ans)
t = 1
for case in range(1, t + 1):
	ans = solve()


import sys
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = list(map(int, input().split()))
am = [0] * n
for i in range(n):
	am[a[i] - 1] = i
b = list(map(int, input().split()))
bm = [0] * n
for i in range(n):
	bm[b[i] - 1] = i
ans = 0
cm = [0] * n
for i in range(n):
	if bm[i] > am[i]:
		cm[n - bm[i] + am[i]] += 1
	else:
		cm[am[i] - bm[i]] += 1
print(max(cm))


import math

def bin_search(l, target):
	start = 0
	end = len(l) - 1
	while start <= end:
		mid = (start + end) // 2
		if l[mid] < target:
			start = mid + 1
		elif l[mid] > target:
			end = mid - 1
		else:
			return mid
n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
c = []
b_dict = {}
for i in range(len(b)):
	b_dict[b[i]] = i
for i in range(len(a)):
	rel_ind = b_dict[a[i]]
	c.append((i - rel_ind) % n)
d = {}
for i in c:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
print(max(list(d.values())))


n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
a_t = [0] * (n + 1)
for (idx, val) in enumerate(a):
	if idx == 0:
		continue
	a_t[val] = idx
res = 0
d = {}
for (idx, val) in enumerate(b):
	if idx == 0:
		continue
	t = a_t[val] - idx
	if t < 0:
		t += n
	if t not in d:
		d[t] = 1
	else:
		d[t] += 1
	if d[t] > res:
		res = d[t]
print(res)


n = int(input())
lisa = list(map(int, input().split()))
lisb = list(map(int, input().split()))
inda = [0] * 200005
indb = [0] * 200005
rotr = [0] * 200005
for i in range(n):
	inda[lisa[i]] = i
	indb[lisb[i]] = i
for i in range(1, n + 1):
	if inda[i] >= indb[i]:
		rotr[inda[i] - indb[i]] += 1
	else:
		rotr[n - indb[i] + inda[i]] += 1
print(max(rotr))


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
n = oint()
a = list(rint())
b = list(rint())
a_dict = dict()
for (i, aa) in enumerate(a):
	a_dict[aa] = i
b_dict = dict()
for (i, bb) in enumerate(b):
	b_dict[bb] = i
diff = [0 for _ in range(n)]
for i in range(1, n + 1):
	diff[(a_dict[i] - b_dict[i] + n) % n] += 1
print(max(diff))


def solve(n, seqA, seqB):
	table = {x: index for (index, x) in enumerate(seqA, 0)}
	diff = {}
	for indexB in range(n):
		res = table[seqB[indexB]] - indexB
		if res < 0:
			if res * -1 > n // 2:
				res = n - res * -1
		elif res > n // 2:
			res = n - res
			res *= -1
		if diff.get(res) == None:
			diff[res] = 1
		else:
			diff[res] += 1
	return max(diff.values())
n = int(input())
seqA = input().split()
seqB = input().split()
print(solve(n, seqA, seqB))


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	A = rl()
	B = rl()
	perm = {}
	for (i, a) in enumerate(A):
		perm[a] = i
	dists = dd(int)
	for (j, b) in enumerate(B):
		dist = (perm[b] - j) % n
		dists[dist] += 1
	print(max(dists.values()))
mode = 'S'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
s1 = list(map(int, stdin.readline().strip().split()))
ans = [0 for i in range(n)]
pos = [0 for i in range(n + 1)]
for i in range(n):
	pos[s1[i]] = i
for i in range(n):
	x = pos[s[i]]
	if x <= i:
		ans[i - x] += 1
	else:
		ans[n + i - x] += 1
print(max(ans))


dict1 = {}
dict2 = {}
n = int(input())
p1 = list(map(int, input().split()))
for i in range(n):
	dict1[p1[i]] = i
p2 = list(map(int, input().split()))
for i in range(n):
	dict2[p2[i]] = i
d = []
for i in range(1, n + 1):
	d.append((dict1[i] - dict2[i]) % n)
f = [0] * n
for i in d:
	f[i] += 1
print(max(f))


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
indexa = [0] * (n + 1)
indexb = [0] * (n + 1)
for j in range(n):
	indexa[a[j]] = j + 1
	indexb[b[j]] = j + 1
dicti = []
for j in range(1, n + 1):
	one = indexa[j]
	two = indexb[j]
	x = abs(one - two)
	if one == two:
		dicti.append(0)
	elif one < two:
		dicti.append(str(x) + 'l')
		dicti.append(str(n - x) + 'r')
	else:
		dicti.append(str(x) + 'r')
		dicti.append(str(n - x) + 'l')
final = Counter(dicti)
print(max(list(final.values())))


from collections import Counter as co
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[b[i]] = i
v = []
for i in range(len(a)):
	e = d[a[i]] - i
	if e < 0:
		e += n
	v.append(e)
print(max(co(v).values()))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def main():
	n = int(input())
	A = tuple(map(int, input().split()))
	B = tuple(map(int, input().split()))
	D = dict()
	for (i, a) in enumerate(A):
		D[a] = i
	C = [0] * n
	for (i, b) in enumerate(B):
		C[i] = D[b]
	for (i, c) in enumerate(C):
		if c == 0:
			break
	C = C[i:] + C[:i]
	Cnt = [0] * n
	for (i, c) in enumerate(C):
		dist = (c - i) % n
		Cnt[dist] += 1
	ans = max(Cnt)
	sys.stdout.write(str(ans) + '\n')
main()


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
lb = {}
for i in range(n):
	lb[b[i]] = i
d = defaultdict(int)
m = 0
for i in range(n):
	l = (i - lb[a[i]] + n) % n
	d[l] += 1
	m = max(m, d[l])
print(m)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0] + a
b = [0] + b
pos = [0 for i in range(n + 1)]
ans = 0
d = {}
for i in range(1, n + 1):
	pos[a[i]] = i
for i in range(1, n + 1):
	curr = pos[b[i]] - i
	if curr < 0:
		curr += n
	if curr not in d:
		d[curr] = 1
	else:
		d[curr] += 1
	ans = max(ans, d[curr])
print(ans)


from sys import stdin

def mostFrequent(arr, n):
	hsh = dict()
	for i in range(n):
		if arr[i] in hsh.keys():
			hsh[arr[i]] += 1
		else:
			hsh[arr[i]] = 1
	maxi = 0
	for i in hsh:
		if maxi < hsh[i]:
			maxi = hsh[i]
	return maxi
n = int(stdin.readline())
A = list(map(int, stdin.readline().split()))
B = list(map(int, stdin.readline().split()))
ans = 0
s = set()
p = A.index(B[-1])
B = B[p + 1:] + B[0:p + 1]
ar1 = n * [0]
ar2 = n * [0]
for i in range(n):
	ar1[A[i] - 1] = i
	ar2[B[i] - 1] = i
ans = []
for i in range(n):
	ans.append((ar1[i] - ar2[i]) % n)
print(mostFrequent(ans, n))


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	n = int(input())
	a = {}
	b = {}
	for (x, i, j) in zip(range(n), li(), li()):
		a[i] = b[j] = x
	c = arr([0] * n)
	for i in range(1, n + 1):
		c[b[i] - a[i]] += 1
	print(max(c))
solve()


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
pos = dict()
for i in range(n):
	pos[arr[i]] = i
rotations = [0] * n
for i in range(n):
	rotations[i] = (pos[brr[i]] - i + n) % n
print(Counter(rotations).most_common()[0][1])


n = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
d = {}
for i in range(n):
	d[b[i]] = i
jump_needed = []
for i in range(n):
	map_idx = d[a[i]]
	if i <= map_idx:
		jump_needed.append(map_idx - i)
	else:
		x = n - 1 - i + map_idx + 1
		jump_needed.append(x)
di = {}
for i in jump_needed:
	try:
		di[i] = di[i] + 1
	except KeyError:
		di[i] = 1
print(max(di.values()))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
from collections import defaultdict
left = defaultdict(int)
right = defaultdict(int)
ind = defaultdict(lambda : [0, 0])
for i in range(n):
	ind[a[i]][0] = i
	ind[b[i]][1] = i
for j in range(1, n + 1):
	if ind[j][0] >= ind[j][1]:
		right[ind[j][0] - ind[j][1]] += 1
		left[n - ind[j][0] + ind[j][1]] += 1
	else:
		left[ind[j][1] - ind[j][0]] += 1
		right[n - ind[j][1] + ind[j][0]] += 1
ans = 0
a = max([left[i] for i in left])
b = max([right[i] for i in right])
ans = max(a, b, ans)
print(ans)


n = int(input())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
visited = {k: 0 for k in range(n)}
scores = [0 for k in range(n)]
maxscore = 0
position = 0
for i in range(n):
	visited[alist[i]] = i
for i in range(n):
	if i <= visited[blist[i]]:
		position = visited[blist[i]] - i
	else:
		position = n - (i - visited[blist[i]])
	scores[position] += 1
	if scores[position] > maxscore:
		maxscore = scores[position]
print(maxscore)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def main():
	try:
		n = I()
		a = list(In())
		b = list(In())
		d = {}
		ans = []
		d1 = {}
		for x in range(n):
			d[b[x]] = x
		for x in range(n):
			temp = d[a[x]]
			if temp > x:
				jump = n - (temp - x)
			else:
				jump = x - temp
			if d1.get(jump, -1) != -1:
				d1[jump] += 1
			else:
				d1[jump] = 1
		t = max(d1.values())
		print(t)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


import sys
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
n = I()
a = li()
b = li()
ans = 0
ma = {}
mb = {}
for i in range(n):
	ma[b[i]] = i
	mb[a[i]] = i
dm = {}
for i in range(0, n + 1):
	dm[i] = 0
for i in range(1, n + 1):
	dm[(ma[i] - mb[i]) % n] += 1
print(max(dm.values()))


from collections import defaultdict
n = int(input())
l = [[-1, -1] for i in range(n)]
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
for i in range(n):
	l[l1[i] - 1][0] = i + 1
	l[l2[i] - 1][1] = i + 1
for i in range(n):
	(a, b) = (l[i][0], l[i][1])
	if l[i][0] < l[i][1]:
		l[i][0] = -1 * (n - b + a)
		l[i][1] = b - a
	elif l[i][0] == l[i][1]:
		l[i] = [0]
	else:
		l[i][0] = b - a
		l[i][1] = n - a + b
maxi = 0
d = defaultdict(int)
for i in range(n):
	for j in l[i]:
		d[j] += 1
		if d[j] > maxi:
			maxi = d[j]
print(maxi)


N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
da = {}
db = {}
for i in range(N):
	da[a[i]] = i
	db[b[i]] = i
counts = {}
for i in range(1, N + 1):
	if db[i] > da[i]:
		count = da[i] + N - db[i]
	else:
		count = da[i] - db[i]
	if count in counts.keys():
		counts[count] += 1
	else:
		counts[count] = 1
maxi = -1
for count in counts.keys():
	if counts[count] > maxi:
		maxi = counts[count]
print(maxi)


from sys import stdin
input = stdin.buffer.readline
n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
cnt = [0] * n
idx = [0] * n
for i in range(n):
	idx[a[i] - 1] = i
for i in range(n):
	cnt[idx[b[i] - 1] - i] += 1
print(max(cnt))


n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
inds = {}
for x in range(n):
	inds[b[x]] = x
res = [0] * n
for x in range(n):
	if inds[a[x]] >= x:
		required = inds[a[x]] - x
	else:
		required = n - (x - inds[a[x]])
	res[required] += 1
print(max(res))


import sys
input = sys.stdin.readline

def intInput():
	return int(input())

def intListInput():
	return list(map(int, input().split()))

def strInput():
	return input()

def brute(n, a, b):
	result = 0
	for k in range(n):
		curr = 0
		for i in range(n):
			if a[i] == b[(i + k) % n]:
				curr += 1
		result = max(result, curr)
	return result

def soln(n, a, b):
	table = {}
	for (i, num) in enumerate(a):
		table[num] = i
	buckets = [0 for _ in range(n)]
	for (j, num) in enumerate(b):
		i = table[num]
		if j <= i:
			m = i - j
		else:
			m = n + i - j
		buckets[m] += 1
	return max(buckets)

def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	result = soln(n, a, b)
	print(result)
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(d1, d2) = ({}, {})
for i in range(n):
	d1[a[i]] = i
	d2[b[i]] = i
d = {}
for i in range(1, n + 1):
	val = (d1[i] - d2[i]) % n
	if val in d:
		d[val] += 1
	else:
		d[val] = 1
print(max(d.values()))


def solve():
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a_ = [None for i in range(n + 1)]
	b_ = [None for i in range(n + 1)]
	for i in range(n):
		a_[a[i]] = i + 1
		b_[b[i]] = i + 1
	diff_ar = [0 for i in range(n + 1)]
	max_diff = 0
	for i in range(1, n + 1):
		curr_diff = (a_[i] - b_[i]) % n
		diff_ar[curr_diff] += 1
		max_diff = max(max_diff, diff_ar[curr_diff])
	print(max_diff)
solve()


n = int(input())
l = list(map(int, input().split()))
m = list(map(int, input().split()))
loc = [0] * (n + 1)
ans_l = [0] * (n + 1)
for i in range(n):
	loc[l[i]] = i
for i in range(n):
	temp = loc[m[i]] - i
	if temp < 0:
		temp += n
	ans_l[temp] += 1
print(max(ans_l))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ass = [0] * n
for i in range(n):
	ass[a[i] - 1] = i
m = [0] * n
mx = 0
for i in range(n):
	x = i - ass[b[i] - 1]
	x %= n
	m[x] += 1
	mx = max(mx, m[x])
print(mx)


from collections import Counter

def solve(n, a, b):
	for i in range(n):
		a[i] -= 1
		b[i] -= 1
	c = [0 for i in range(n)]
	d = [0 for i in range(n)]
	for i in range(n):
		c[a[i]] = i
	m = 0
	for i in range(n):
		d[i] = (c[b[i]] - i + n) % n
	g = Counter(d)
	m = 0
	for i in g.items():
		if m < i[1]:
			m = i[1]
	return m
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(solve(n, a, b))


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
mo = 1000000007
n = inn()
a = arr()
b = arr()
da = defaultdict(int)
for i in range(n):
	da[a[i]] = i + 1
db = defaultdict(int)
for i in range(n):
	db[b[i]] = i + 1
d = defaultdict(int)
for i in range(1, n + 1):
	res = (da[i] - db[i]) % n
	d[res] += 1
print(max(d.values()))


import math
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = [0] * (n + 1)
b1 = [0] * (n + 1)
for i in range(n):
	a1[a[i]] = i
	b1[b[i]] = i
t = [0] * (n + 1)
for i in range(1, n + 1):
	q = a1[i] - b1[i]
	if q < 0:
		q += n
	t[q] += 1
print(max(t))


def solve():
	n = int(input())
	_A = list(input().split(' '))
	_B = list(input().split(' '))
	A = sorted([(_A[i], i) for i in range(n)])
	B = sorted([(_B[i], i) for i in range(n)])
	ans = [0] * n
	for i in range(n):
		ans[(n + A[i][1] - B[i][1]) % n] += 1
	return max(ans)
print(solve())


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * n
e = [0] * n
for i in range(n):
	c[a[i] - 1] = d[b[i] - 1] = i
for i in range(n):
	e[i] = c[i] - d[i]
	if e[i] < 0:
		e[i] += n
m = j = 1
e.sort()
for i in range(1, n):
	if e[i] == e[i - 1]:
		j += 1
		if j > m:
			m = j
	else:
		j = 1
print(m)


import sys
input = sys.stdin.buffer.readline
n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
a += a
ia = [[] for _ in range(n)]
ib = [[] for _ in range(n)]
for (i, x) in enumerate(a):
	ia[x - 1].append(i)
for (i, x) in enumerate(b):
	ib[x - 1].append(i)
cnt = [0] * n
for i in range(n):
	(ii, jj) = ia[i]
	kk = ib[i][0]
	if ii >= kk:
		cnt[ii - kk] += 1
	if jj - kk < n:
		cnt[jj - kk] += 1
print(max(cnt))


from collections import Counter
from sys import stdin
input = stdin.readline

def find_left(a, b, n):
	f_l = []
	s_l = []
	for i in range(1, n + 1):
		if a[i] >= b[i]:
			f_l.append(a[i] - b[i])
			s_l.append(b[i] + n - a[i])
		else:
			f_l.append(a[i] + n - b[i])
			s_l.append(b[i] - a[i])
	return (f_l, s_l)

def find_right(a, b, n):
	f_r = []
	s_r = []
	for i in range(1, n + 1):
		if a[i] >= b[i]:
			f_r.append(n - a[i] + b[i])
			s_r.append(a[i] - b[i])
		else:
			f_r.append(b[i] - a[i])
			s_r.append(n - b[i] + a[i])
	return (f_r, s_r)

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	first_p = {}
	second_p = {}
	f_l = []
	s_l = []
	f_r = []
	s_r = []
	for i in range(n):
		first_p[a[i]] = i + 1
		second_p[b[i]] = i + 1
	(f_l, s_l) = find_left(first_p, second_p, n)
	(f_r, s_r) = find_left(first_p, second_p, n)
	a = Counter(f_l).most_common(1)[0][1]
	b = Counter(s_l).most_common(1)[0][1]
	c = Counter(s_r).most_common(1)[0][1]
	d = Counter(f_r).most_common(1)[0][1]
	print(max(max(a, b), max(c, d)))
main()


N = int(input())
arrayA = [int(x) for x in input().split()]
arrayB = [int(x) for x in input().split()]
pairs = [[] for i in range(N)]
for i in range(N):
	pairs[arrayA[i] - 1].append(i)
for i in range(N):
	pairs[arrayB[i] - 1].append(i)
checker = []
for i in pairs:
	if i[0] < i[1]:
		i[0] += N
	checker.append(i[0] - i[1])

def mostfrequent(x):
	dictionary = {}
	for i in x:
		if i in dictionary:
			dictionary[i] += 1
		else:
			dictionary[i] = 1
	counter = []
	for i in dictionary:
		counter.append(dictionary[i])
	return max(counter)
print(mostfrequent(checker))


from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0 for x in range(n + 1)]
mmax = 0
offset = [0 for x in range(n + 1)]
for i in range(n):
	pos[a[i]] = i
for i in range(n):
	cur = pos[b[i]] - i
	if cur < 0:
		cur += n
	offset[cur] += 1
ans = 0
for i in offset:
	ans = max(ans, i)
print(ans)


for t in range(1):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	ct = 0
	matrix = [0] * n
	diff = [0] * n
	diffn = [0] * n
	for i in range(n):
		matrix[brr[i] - 1] = i
	for i in range(n):
		pos = (i - matrix[arr[i] - 1]) % n
		diff[pos] += 1
	print(max(diff))


N = int(input())
a = map(int, input().strip().split())
a_positions = {elem: i for (i, elem) in enumerate(a)}
b = map(int, input().strip().split())
b_positions = {elem: i for (i, elem) in enumerate(b)}
rotation_differences = {i: 0 for i in range(N)}
max_occurance = 0
for i in range(1, N + 1):
	key = (b_positions[i] - a_positions[i]) % N
	rotation_differences[key] += 1
	if rotation_differences[key] > max_occurance:
		max_occurance = rotation_differences[key]
print(max_occurance)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
for _ in range(1):
	n = int(z())
	l1 = list(map(int, z().split()))
	l2 = list(map(int, z().split()))
	pos = [0] * n
	for i in range(n):
		pos[l1[i] - 1] += i
		pos[l2[i] - 1] -= i
	out = [0] * n
	for i in pos:
		out[i] += 1
	print(max(out))


from sys import stdin
n = int(stdin.readline().strip())
alist = list(map(int, stdin.readline().split()))
blist = list(map(int, stdin.readline().split()))
pos = {}
for i in range(len(blist)):
	pos[blist[i]] = i
(counts, ans) = ({}, 0)
for i in range(len(alist)):
	d = (pos[alist[i]] - i) % n
	counts[d] = counts.get(d, 0) + 1
	ans = max(ans, counts[d])
print(ans)


from sys import stdin, stdout
import sys
from math import *

def lcs(i, j, count, X, Y):
	if i == 0 or j == 0:
		return count
	if X[i - 1] == Y[j - 1]:
		count = lcs(i - 1, j - 1, count + 1, X, Y)
	count = max(count, max(lcs(i, j - 1, 0, X, Y), lcs(i - 1, j, 0, X, Y)))
	return count
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[b[i]] = i
ans = [0] * n
for i in range(n):
	if d[a[i]] >= i:
		ans[d[a[i]] - i] += 1
	else:
		ans[n - (i - d[a[i]])] += 1
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ia = [0] * (n + 1)
ib = [0] * (n + 1)
i = 0
while i < len(b):
	x = b[i]
	ib[x] = i
	i = i + 1
i = 0
da = {}
while i < n:
	x = a[i]
	y = ib[x]
	if i == y:
		r = n
		h = -1 * n
	elif i < y:
		r = y - i
		h = -1 * (n - y + i)
	else:
		r = n - i + y
		h = y - i
	if r in da:
		da[r] = da[r] + 1
	else:
		da[r] = 1
	if h in da:
		da[h] = da[h] + 1
	else:
		da[h] = 1
	i = i + 1
m = -1
for i in da:
	if da[i] > m:
		m = da[i]
print(m)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	a = li()
	b = li()
	d = defaultdict(int)
	c = defaultdict(int)
	for i in range(n):
		c[a[i]] = i
		d[b[i]] = i
	ans = []
	for i in range(n):
		ans.append((c[a[i]] - d[a[i]] + n) % n)
	f = Counter(ans)
	temp = 0
	for i in f:
		temp = max(temp, f[i])
	print(temp)
for _ in range(1):
	solve()


n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
pos = list((0 for i in range(n)))
for i in range(n):
	pos[arr1[i] - 1] = i
left = list((int(0) for i in range(n + 1)))
right = list((int(0) for i in range(n + 1)))
for i in range(n):
	if i < pos[arr2[i] - 1]:
		lol = i + 1 + n - pos[arr2[i] - 1] - 1
		kek = pos[arr2[i] - 1] - i
	else:
		lol = i - pos[arr2[i] - 1]
		kek = n - i + pos[arr2[i] - 1]
	left[lol] += 1
	right[kek] += 1
print(max(max(*left), max(*right)))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
la = [0] * (n + 1)
lb = [0] * (n + 1)
for i in range(n):
	la[a[i]] = i
	lb[b[i]] = i
dic = {}
for i in range(1, n + 1):
	diff = lb[i] - la[i]
	if diff < 0:
		diff = n + diff
	dic[diff] = dic.get(diff, 0) + 1
mx = 0
for key in dic:
	if dic[key] > mx:
		mx = dic[key]
print(mx)


from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
PosA = [0] * (N + 1)
PosB = [0] * (N + 1)
for i in range(N):
	PosA[A[i]] = i + 1
	PosB[B[i]] = i + 1
Change = [0] * (N + 1)
for i in range(1, N + 1):
	Change[i] = PosA[i] - PosB[i]
Neg = [0] * (N + 1)
for i in range(1, N + 1):
	if Change[i] > 0:
		Neg[i] = Change[i] - N
	else:
		Neg[i] = Change[i]
Pos = [0] * (N + 1)
for i in range(1, N + 1):
	if Change[i] < 0:
		Pos[i] = N + Change[i]
	else:
		Pos[i] = Change[i]
Neg[0] = 100111
Pos[0] = 100111
NegC = Counter(Neg)
PosC = Counter(Pos)
print(min(NegC.most_common(1)[0][1], PosC.most_common(1)[0][1]))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
location = [0] * (n + 1)
for i in range(n):
	location[l2[i]] = i + 1
dis = [0] * (n + 1)
for i in range(n):
	d = location[l1[i]] - (i + 1)
	if d < 0:
		d += n
	dis[d] += 1
print(max(dis))


n = int(input())
o = [-1 for i in range(n + 1)]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = {}
for i in range(n):
	o[a[i]] = i
for i in range(n):
	x = o[b[i]]
	if x - i >= 0:
		if x - i in d:
			d[x - i] += 1
		else:
			d[x - i] = 1
	elif n + x - i in d:
		d[n + x - i] += 1
	else:
		d[n + x - i] = 1
print(max(d.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
da = {}
db = {}
for i in range(n):
	da[a[i]] = i
	db[b[i]] = i
d = [0] * (n + 1)
for i in range(n):
	delta = db[a[i]] - i
	delta = (delta + n) % n
	d[delta] += 1
print(max(d))


from collections import Counter
for _ in range(1):
	n = int(input())
	a = [int(i) - 1 for i in input().split()]
	b = [int(i) - 1 for i in input().split()]
	ai = [0] * n
	bi = [0] * n
	o = [0] * n
	for i in range(n):
		ai[a[i]] = i
		bi[b[i]] = i
	for i in range(n):
		o[(ai[i] - bi[i] + n) % n] += 1
	print(max(o))


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
tests = lambda : range(1, int_in() + 1)
case_out = lambda i, o: out('Case #{}: {}'.format(i, o))

def solve(n, a, b):
	b_dict = {}
	for (i, item) in enumerate(b):
		if item not in b_dict:
			b_dict[item] = []
		b_dict[item].append(i)
	buckets = [0] * n
	for (i, item) in enumerate(a):
		if item in b_dict:
			indices = b_dict[item]
			for index in indices:
				if i <= index:
					buckets[index - i] += 1
				else:
					buckets[index + n - i] += 1
	return max(buckets)
n = int_in()
a = arr_in()
b = arr_in()
out(solve(n, a, b))


def solve(array1, array2):
	posArr = []
	offArr = []
	for i in range(len(array1)):
		posArr.append(0)
		offArr.append(0)
	for (i, elem) in enumerate(array1):
		posArr[elem - 1] = i
	maxOff = 0
	for (i, elem) in enumerate(array2):
		offArr[elem - 1] = posArr[elem - 1] - i
		if offArr[elem - 1] < 0:
			offArr[elem - 1] += len(offArr)
		if maxOff < offArr[elem - 1]:
			maxOff = offArr[elem - 1]
	offCount = []
	for i in range(maxOff + 1):
		offCount.append(0)
	for elem in offArr:
		offCount[elem] += 1
	return max(offCount)
input()
while True:
	try:
		v1 = input().split(' ')
		v2 = input().split(' ')
		for i in range(len(v1)):
			v1[i] = int(v1[i])
			v2[i] = int(v2[i])
		print(solve(v1, v2))
	except EOFError:
		break


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
n = int(input())
a = int_arr()
b = int_arr()
ind = {a[i]: i for i in range(n)}
shaft = [0 for i in range(200002)]
for i in range(n):
	val = b[i]
	d = ind[val]
	if i == d:
		shaft[0] += 1
		continue
	elif d > i:
		shaft[d - i] += 1
	else:
		shaft[n - i + d] += 1
print(max(shaft))


from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aidx = [-1] * n
bidx = [-1] * n
for (i, (ai, bi)) in enumerate(zip(a, b)):
	aidx[ai - 1] = i
	bidx[bi - 1] = i
diffs = [(aidx[i] - bidx[i]) % n for i in range(n)]
print(max(Counter(diffs).values()))


import math
from collections import defaultdict

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
n = r()
a = rl()
b = rl()
d = {}
e = [0] * n
for i in range(n):
	d[a[i]] = i
for i in range(n):
	ind = d[b[i]] - i
	if ind < 0:
		ind = n + ind
	e[ind] += 1
print(max(e))


from collections import defaultdict

def buildIndexArray(arr):
	indexArray = [0] * len(arr)
	for i in range(n):
		indexArray[arr[i] - 1] = i
	return indexArray
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
indexA = buildIndexArray(a)
indexB = buildIndexArray(b)
shiftCount = defaultdict(int)
for i in range(n):
	shiftCount[(indexB[i] - indexA[i] + n) % n] += 1
print(max(shiftCount.values()))


from collections import defaultdict
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
(d, d2) = (defaultdict(int), {})
for i in range(n):
	d2[l2[i]] = i
for i in range(n):
	cur = i - d2[l1[i]]
	if cur < 0:
		cur += n
	d[cur] += 1
print(max(d.values()))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [0] * n
for i in range(n):
	l[a[i] - 1] += i
	l[b[i] - 1] -= i
d = dict()
ans = 0
for i in range(n):
	if l[i] < 0:
		l[i] += n
	if l[i] not in d:
		d[l[i]] = 0
	d[l[i]] += 1
	ans = max(ans, d[l[i]])
print(ans)


def cast(cre, typ):
	return type(typ)(map(cre, typ))

def solution():
	n = int(input())
	(a, b) = (cast(int, input().split()), cast(int, input().split()))
	(a_idx, b_idx) = ([0 for i in range(n + 1)], [0 for i in range(n + 1)])
	for i in range(n):
		a_idx[a[i]] = i
		b_idx[b[i]] = i
	amt = [0 for i in range(n)]
	for i in range(1, n + 1):
		amt[(n + (a_idx[i] - b_idx[i])) % n] += 1
	print(max(amt))
solution()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dic1 = {}
dic2 = {}
dic3 = {}
for i in range(n):
	dic1[a[i]] = i
	dic2[b[i]] = i
for i in range(1, n + 1):
	if dic1[i] - dic2[i] >= 0:
		try:
			dic3[dic1[i] - dic2[i]].append(1)
		except:
			dic3[dic1[i] - dic2[i]] = [1]
	else:
		try:
			dic3[n - (dic2[i] - dic1[i])].append(1)
		except:
			dic3[n - dic2[i] + dic1[i]] = [1]
m = 0
for i in dic3:
	m = max(len(dic3[i]), m)
print(m)


from operator import eq
n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[arr2[i]] = i
for i in range(n):
	dic[arr1[i]] -= i
	if dic[arr1[i]] < 0:
		dic[arr1[i]] += n
ans = [0] * n
for i in dic:
	ans[dic[i]] += 1
print(max(ans))


n = int(input())
orig = list(map(int, input().split()))
rot = list(map(int, input().split()))
pos = [0] * (n + 1)
rs = [0] * (n + 1)
rsMax = [0] * (n + 1)
ls = [0] * (n + 1)
lsMax = [0] * (n + 1)
for i in range(n):
	pos[orig[i]] = i + 1
for i in range(n):
	k = rot[i]
	rs[k] = (pos[k] - i + 1 + n) % n
	ls[k] = (i + 1 - pos[k] + n) % n
	rsMax[rs[k]] += 1
	lsMax[ls[k]] += 1
print(max(max(rsMax), max(lsMax)))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p1 = [0] * n
p2 = [0] * n
ans = [0] * n
for i in range(n):
	p1[a[i] - 1] = i
	p2[b[i] - 1] = i
for i in range(n):
	ans[(p1[i] - p2[i] + n) % n] += 1
print(max(ans))


n = int(input())
arrA = list(map(int, input().split()))
arrB = list(map(int, input().split()))
positionAdict = dict()
positionBdict = dict()
for i in range(n):
	positionAdict[arrA[i]] = i
	positionBdict[arrB[i]] = i
moveCount = [0] * n
for i in range(n):
	if i < positionBdict[arrA[i]]:
		moveCount[n - positionBdict[arrA[i]] + i] += 1
	else:
		moveCount[abs(i - positionBdict[arrA[i]])] += 1
result = 1
for i in range(n):
	if moveCount[i] > result:
		result = moveCount[i]
print(result)


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
m = []
for i in range(n):
	m.append(0)
pos = []
for i in range(n + 1):
	pos.append(0)
for i in range(n):
	pos[a[i]] = i
for i in range(n):
	cur = pos[b[i]] - i
	if cur < 0:
		cur += n
	m[cur] += 1
max = 0
for i in range(n):
	if m[i] > max:
		max = m[i]
print(max)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
solution = [0] * n
distances = [-1] * n
sol = 0
for i in range(n):
	ele = b[i] - 1
	distances[ele] = i
for i in range(n):
	ele = a[i] - 1
	aux = i - distances[ele]
	if aux < 0:
		aux = n + aux
	solution[aux] += 1
	if solution[aux] > sol:
		sol = solution[aux]
print(sol)


def getMatches(n, a, b):
	count = 0
	for i in range(n):
		if a[i] == b[i]:
			count += 1
	return count

def rotate(arr, n):
	x = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = x

def invrotate(arr, n):
	x = arr[0]
	for i in range(n - 1):
		arr[i] = arr[i + 1]
	arr[n - 1] = x
n = int(input())
x = input()
x = x.split()
x = [int(y) for y in x]
a = x
x = input()
x = x.split()
x = [int(y) for y in x]
b = x
d = {}
for i in range(n):
	d[i + 1] = 0
for i in range(n):
	if i == 0:
		d[a[i]] -= n
		d[b[i]] += i
	else:
		d[a[i]] -= i
		d[b[i]] += i
vals = []
for i in d:
	vals.append(d[i])
x = {}
for i in vals:
	x[i] = 0
for i in vals:
	x[i] += 1
maxC = 0
for i in vals:
	if x[i] > maxC:
		maxC = x[i]
d = {}
for i in range(n):
	d[i + 1] = 0
for i in range(n):
	d[a[i]] -= i
	d[b[i]] += i
vals = []
for i in d:
	vals.append(d[i] % n)
x = {}
for i in vals:
	x[i] = 0
for i in vals:
	x[i] += 1
for i in vals:
	if x[i] > maxC:
		maxC = x[i]
print(maxC)


import collections

def eval(N, D1, D2):
	d1 = dict()
	d2 = dict()
	for i in range(N):
		d1[D1[i]] = i
		d2[D2[i]] = i
	Da = collections.defaultdict(int)
	Db = collections.defaultdict(int)
	for i in D1:
		dd = d1[i] - d2[i]
		if dd == 0:
			l1 = 0
		elif dd < 0:
			l1 = dd + N
		else:
			l1 = dd
		dd2 = d2[i] - d1[i]
		if dd2 == 0:
			l2 = 0
		elif dd2 < 0:
			l2 = dd2
		else:
			l2 = dd2 - N
		Da[l1] += 1
		Db[l2] += 1
	print(max(max(Da.values()), max(Db.values())))
N = int(input())
D1 = list(map(int, input().split()))
D2 = list(map(int, input().split()))
eval(N, D1, D2)