#! ruby # Try yukicoder # author: Leornadone @ NEETSDKASU N = gets.to_i S = gets.chomp # S[i,j] # S[j+1,j+(j+1-i)] = S[j+1,j+1+(j-i)] m = Hash.new N.pred.downto(0) do |i| N.pred.downto(i) do |j| k =S[i..j] if m.include? k b = (j + 1) + (j - i) if m[k].include? b puts "YES" exit end m[k][i] = true else m[k] = {i => true} end end end puts "NO"