N = int(eval(input()))

S = eval(input())



dp = [[0 for _ in range(N)] for _ in range(N)]



ans = 0

for i in range(N):

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

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

            tmp = 1

            if i > 0:

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

            if j - i < tmp:

                continue

            dp[i][j] = tmp

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

print(ans)
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())
dp = [[0 for _ in range(N)] for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if S[i] == S[j]:
            tmp = 1
            if i > 0:
                tmp += dp[i - 1][j - 1]
            if j - i < tmp:
                continue
            dp[i][j] = tmp
        ans = max(ans, dp[i][j])
print(ans)

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)

-dp = [[0 for _ in range(N)] for _ in range(N)] -ans = 0 -for i in range(N): -    for j in range(i + 1, N): -        if S[i] == S[j]: -            tmp = 1 -            if i > 0: -                tmp += dp[i - 1][j - 1] -            if j - i < tmp: -                continue -            dp[i][j] = tmp -        ans = max(ans, dp[i][j]) -print(ans) +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)