N = int(eval(input()))

S = eval(input())



F = [1] * (N//2 + 2)

for i in range(1, len(F)):

    F[i] = F[i] * 26



def check(l):

    D = set()

    for i in range(N - 2 * l + 1):

        D.add(S[i:i+l])

        if S[i+l:i+2*l] in D:

            return True



OK = 0

NG = N // 2 + 1



while abs(OK - NG) > 1:

    mid = (OK + NG) // 2

    if check(mid):

        OK = mid

    else:

        NG = mid



print(OK)
N = int(eval(input()))

S = eval(input())



def check(l):

    D = set()

    for i in range(N - 2 * l + 1):

        D.add(S[i:i+l])

        if S[i+l:i+2*l] in D:

            return True



OK = 0

NG = N // 2 + 1



while abs(OK - NG) > 1:

    mid = (OK + NG) // 2

    if check(mid):

        OK = mid

    else:

        NG = mid



print(OK)
N = int(eval(input()))
S = eval(input())
F = [1] * (N // 2 + 2)
for i in range(1, len(F)):
    F[i] = F[i] * 26


def check(l):
    D = set()
    for i in range(N - 2 * l + 1):
        D.add(S[i : i + l])
        if S[i + l : i + 2 * l] in D:
            return True


OK = 0
NG = N // 2 + 1
while abs(OK - NG) > 1:
    mid = (OK + NG) // 2
    if check(mid):
        OK = mid
    else:
        NG = mid
print(OK)

N = int(eval(input()))
S = eval(input())


def check(l):
    D = set()
    for i in range(N - 2 * l + 1):
        D.add(S[i : i + l])
        if S[i + l : i + 2 * l] in D:
            return True


OK = 0
NG = N // 2 + 1
while abs(OK - NG) > 1:
    mid = (OK + NG) // 2
    if check(mid):
        OK = mid
    else:
        NG = mid
print(OK)

-F = [1] * (N // 2 + 2) -for i in range(1, len(F)): -    F[i] = F[i] * 26