My submission link:https://mirror.codeforces.com/contest/1617/submission/139558699
What i did was pushed all numbers greater than n in a vector and all number lesser than or equal to n with frequency greater than 1 in the same vector. After that i pushed all numbers of input vector in a set and checked for numbers from 1 to n which were not there in permutation and pushed it in another vector b and then i converted vector a to ma modulo for number at each index also sorted vector a and checked if a[i]<b[i] for some index if found that index answer would be -1 as vector b is already sorted so i cannot further make it more lesser otherwise i printed vector b size.
But it is showing WA on test case 9 pretest 304. Please Help if you find out a flaw also a counter test case would be welcomed too. thank you in advance.