When the server was in serious trouble, Erfan was a great help. Since Erfan is a fan of palindromes, Amin wanted to gift him a palindrome array. However, Erfan felt discouraged by the complexity of that idea and instead requested just a sorted array as a gift.
Initially, you have an array of length that consists of integers. In each step, you pick the first elements of the array and move them to the end of the array in the same order.
For example, if the initial array is [3, 2, 5, 4, 1, 1]
, after one step,
it transforms into [1, 1, 3, 2, 5, 4]
.
Now, Amin wants to know if, after some number of steps, he can sort the array and make Erfan happy, or if Erfan will remain frustrated and never help with another server trouble again.
the first line consist that 2n is the length of the array. the next line consist of integers. the array elements.
your output should consist one string. "happy erfan" if Amin can sort the array after finite number of steps. "sad erfan" if Amin can't sort the array with any number of steps.