func main() var n: int :: cui@inputInt() var map: dict :: #dict var ans: int :: 0 var idx: int :: 0 for i(1, n) var a: int :: cui@inputInt() do idx :: [idx, map.get(a, &)].max() do ans :: [ans, i - idx].max() do map.add(a, i) end for do cui@print("\{ans}\n") end func