N = int(eval(input()))

S = eval(input())

ok, ng = 0, N + 1

while abs(ok - ng) > 1:

    x = (ok + ng) // 2

    check = set()

    for i in range(N - x + 1):

        check.add(S[i: i + x])

        if S[i + x: i + 2 * x] in check:

            ok = x

            break

    else:

        ng = x



print(ok)
n = int(eval(input()))

s = eval(input())

left = 0

right = n // 2 + 1

while right - left > 1:

    mid = (right + left) // 2

    length = mid

    check = set()

    for i in range(n - length + 1):

        s1 = s[i:i+length]

        check.add(s1)

        if s[i+length: i + 2*length] in check:

            left = mid

            break

    else:

        right = mid

print(left)
N = int(eval(input()))
S = eval(input())
ok, ng = 0, N + 1
while abs(ok - ng) > 1:
    x = (ok + ng) // 2
    check = set()
    for i in range(N - x + 1):
        check.add(S[i : i + x])
        if S[i + x : i + 2 * x] in check:
            ok = x
            break
    else:
        ng = x
print(ok)

n = int(eval(input()))
s = eval(input())
left = 0
right = n // 2 + 1
while right - left > 1:
    mid = (right + left) // 2
    length = mid
    check = set()
    for i in range(n - length + 1):
        s1 = s[i : i + length]
        check.add(s1)
        if s[i + length : i + 2 * length] in check:
            left = mid
            break
    else:
        right = mid
print(left)

-N = int(eval(input())) -S = eval(input()) -ok, ng = 0, N + 1 -while abs(ok - ng) > 1: -    x = (ok + ng) // 2 +n = int(eval(input())) +s = eval(input()) +left = 0 +right = n // 2 + 1 +while right - left > 1: +    mid = (right + left) // 2 +    length = mid -    for i in range(N - x + 1): -        check.add(S[i : i + x]) -        if S[i + x : i + 2 * x] in check: -            ok = x +    for i in range(n - length + 1): +        s1 = s[i : i + length] +        check.add(s1) +        if s[i + length : i + 2 * length] in check: +            left = mid -        ng = x -print(ok) +        right = mid +print(left)