cho.sh
Notes
Loading...

Longest Repeated Substring

Time limit

2s

Memory limit

128 MB

Problem

You are given a string S of length L consisting only of lowercase English letters. A substring of S is called a repeated substring if it appears at least twice in the whole string.

Given S, find the length of the longest repeated substring.

Input

The first line contains the length L of the string. (1 ≤ L ≤ 200,000)

The second line contains the length-L string S, consisting only of lowercase English letters and written without spaces.

Output

Print the length of the longest repeated substring on the first line. If no repeated substring exists, print 0.