Suki's Mirror Walk
Suki walks through the park following a path marked by numbered landmarks. The landmarks are arranged in a specific sequence, and Suki has a superstition: she believes her path will bring her good luck only if the sequence of landmarks reads the same forward and backward (a palindrome).
After walking the current path, Suki realizes it may not be a palindrome. Since she can only add new landmarks at the end of her path (she can't go backward), she wants to know the minimum number of additional landmarks she needs to append to make her entire path perfectly symmetric.
Given the sequence of landmarks on Suki's current path, determine if it is already a palindrome, or find the minimum number of landmarks to append to the end to make it one.
Input
The first line contains n (1 ≤ n ≤ 10^5) — the number of landmarks in Suki's current path.
The second line contains n space-separated integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the landmark IDs in order.
Output
Print a single integer: the minimum number of landmarks to append to the end of the sequence to make it a palindrome. If the sequence is already a palindrome, print 0.
Notes
- Print only how many landmarks to append, not which ones.