You get the first N terms, each later term equals the count of distinct values before it, and you must output the Mth term.
Seunghyun built a sequence BBB with the following rule.
Here SSS is a sequence of length NNN that Seunghyun thought up on his own.
Seunghyun wants to know the MMMth term of BBB. Write a program that computes that value for him.
The first line contains NNN, the length of the sequence SSS.
The second line contains S1,S2,…,SNS_1, S_2, \dots, S_NS1,S2,…,SN in order, separated by spaces.
The third line contains MMM.
Print the MMMth term of the sequence BBB.
If N=4N = 4N=4 and S=(2,13,−7,2)S = (2, 13, -7, 2)S=(2,13,−7,2), the first nine terms of BBB are 2,13,−7,2,3,4,5,6,72, 13, -7, 2, 3, 4, 5, 6, 72,13,−7,2,3,4,5,6,7.