n = int(input())
p = input()
index = 0
s = []
res = []
for i in range(n):
  if s and p[i] > s[-1][0]:
    s.append((p[i], i))

  elif s and p[i] < s[-1][0]:
    res.extend([s[-1][1], i])
    break

  else:
    if s:
      s.append((p[i], s[-1][1]))
    else:
      s.append((p[i], i))
  # print(s)
if not res:
  print('NO')
else:
  # print(res)
  temp = p[res[0]:res[1]+1]
  q = p[:res[0]] + temp[::-1] + p[res[1]+1:] 
  # q  = q + q[res[1]:] 
  # print(p[res[0]: res[1]])
  print(q)




