SP4681 TWICE - Twice

Description

Given a string S, find the longest substring that appears at least twice in S (occurrences may overlap).

Input Format

The first line contains an integer L (1 The second line contains the string S, consisting of exactly L lowercase letters ('a'-'z').

Output Format

Output the length of the longest substring that appears at least twice in S. If there is no such substring, output 0.