N = int(eval(input()))

S = eval(input())



dp = [[None for j in range(N)] for i in range(N)]

vlen = 0

for i in range(N-1):

    for j in range(i + 1, N):

        if S[i] != S[j]:

            dp[i][j] = 0

        elif i - 1 >= 0 and j - 1 >= 0:

            dp[i][j] = dp[i - 1][j - 1] + 1

        else:

            dp[i][j] = 1

        if i + dp[i][j] <= j:

            vlen = max(vlen, dp[i][j])

print(vlen)

N = int(eval(input()))

S = eval(input())





def check(vlen):

    part = set()

    for l1 in range(N - vlen * 2 + 1):

        part.add(S[l1:l1 + vlen])

        l2 = l1 + vlen

        if S[l2:l2 + vlen] in part:

            return True

    return False





oklen = 0

nglen = N // 2 + 1



while nglen - oklen > 1:

    midlen = (oklen + nglen) // 2

    if check(midlen):

        oklen = midlen

    else:

        nglen = midlen

print(oklen)

N = int(eval(input()))
S = eval(input())
dp = [[None for j in range(N)] for i in range(N)]
vlen = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if S[i] != S[j]:
            dp[i][j] = 0
        elif i - 1 >= 0 and j - 1 >= 0:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = 1
        if i + dp[i][j] <= j:
            vlen = max(vlen, dp[i][j])
print(vlen)

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


def check(vlen):
    part = set()
    for l1 in range(N - vlen * 2 + 1):
        part.add(S[l1 : l1 + vlen])
        l2 = l1 + vlen
        if S[l2 : l2 + vlen] in part:
            return True
    return False


oklen = 0
nglen = N // 2 + 1
while nglen - oklen > 1:
    midlen = (oklen + nglen) // 2
    if check(midlen):
        oklen = midlen
    else:
        nglen = midlen
print(oklen)

-dp = [[None for j in range(N)] for i in range(N)] -vlen = 0 -for i in range(N - 1): -    for j in range(i + 1, N): -        if S[i] != S[j]: -            dp[i][j] = 0 -        elif i - 1 >= 0 and j - 1 >= 0: -            dp[i][j] = dp[i - 1][j - 1] + 1 -        else: -            dp[i][j] = 1 -        if i + dp[i][j] <= j: -            vlen = max(vlen, dp[i][j]) -print(vlen) + + +def check(vlen): +    part = set() +    for l1 in range(N - vlen * 2 + 1): +        part.add(S[l1 : l1 + vlen]) +        l2 = l1 + vlen +        if S[l2 : l2 + vlen] in part: +            return True +    return False + + +oklen = 0 +nglen = N // 2 + 1 +while nglen - oklen > 1: +    midlen = (oklen + nglen) // 2 +    if check(midlen): +        oklen = midlen +    else: +        nglen = midlen +print(oklen)