import numpy as np
import numba
@numba.jit
def solve(n,s):
    dp=np.zeros((n+1,n+1),dtype=np.int16)
    for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
    print(np.amax(dp))
n=int(input())
s=np.array([ord(i) for i in input()])
solve(n,s) import numpy as np numpy import numba numba def solve(n,s):
    dp=np.zeros((n+1,n+1),dtype=np.int16)
    for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
    print(np.amax(dp)) solve dp=np.zeros((n+1,n+1),dtype=np.int16) dp np.zeros((n+1,n+1),dtype=np.int16) np.zeros np zeros (n+1,n+1) n+1 n 1 n+1 n 1 dtype=np.int16 dtype np.int16 np int16 for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
     i range(n) range n for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
     j range(i+1,n) range i+1 i 1 n if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
     s[i]==s[j] s[i] s i s[j] s j if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
     dp[i][j]<j-i dp[i][j] [i] dp i j j-i j i dp[i+1][j+1]=dp[i][j]+1 dp[i+1][j+1] [i+1] dp i+1 i 1 j+1 j 1 dp[i][j]+1 dp[i][j] [i] dp i j 1 print(np.amax(dp)) print np.amax(dp) np.amax np amax dp n n s s @numba.jit solve numba.jit solve n=int(input()) n int(input()) int input() input ord(i) for i in input() for i in input() i input() input for i in input() ord(i) ord i s=np.array([ord(i) for i in input()]) s np.array([ord(i) for i in input()]) np.array np array [ord(i) for i in input()] solve(n,s) solve n s n=int(input()) int(input()) n s=np.array([ord(i) for i in input()]) np.array([ord(i) for i in input()]) s def solve(n,s):
    dp=np.zeros((n+1,n+1),dtype=np.int16)
    for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
    print(np.amax(dp)) def solve(n,s):
    dp=np.zeros((n+1,n+1),dtype=np.int16)
    for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
    print(np.amax(dp)) solve
import numpy as np
import numba
@numba.jit
def solve(n,s):
    dp=np.zeros((n+1,n+1),dtype=np.int16)
    for i in range(n):
        for j in range(i+1,n):
            if s[i]==s[j]:
                if dp[i][j]<j-i:
                    dp[i+1][j+1]=dp[i][j]+1
    print(np.amax(dp))
n=int(input())
s=np.array([ord(i) for i in input()])
solve(n,s)