Given an array a[] of size N which contains elements from 0 to N-1, you need to find all the elements occurring more than once in the given array. Return the answer in ascending order.
Note: The extra space is only for the array to be returned.
Try and perform all operations within the provided array. 
Example 1:
Input:
N = 4
a[] = {0,3,1,2}
Output: -1
Explanation: N=4 and all elements from 0
to (N-1 = 3) are present in the given
array. Therefore output is -1.
Example 2:
Input:
N = 5
a[] = {2,3,1,2,3}
Output: 2 3 
Explanation: 2 and 3 occur more than once
in the given array.
Your Task:
Complete the function duplicates() which takes array a[] and n as input as parameters and returns a list of elements that occur more than once in the given array in a sorted manner. If no such element is found, return list containing [-1]. 
Expected Time Complexity: O(n).
Expected Auxiliary Space: O(n).
Constraints:
1 <= N <= 10^{5}
0 <= A[i] <= N-1, for each valid i

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: class Solution:

    def duplicates(self, arr, n): 

    	# code here

    	    

Solutions:
class Solution:

	def duplicates(self, arr, n):
		unique_set = set()
		duplicates = set()
		for i in arr:
			if i in unique_set:
				duplicates.add(i)
			else:
				unique_set.add(i)
		if duplicates:
			return sorted(duplicates)
		else:
			return [-1]


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		if len(arr) == len(set(arr)):
			return [-1]
		duplicates = []
		d = Counter(arr)
		for i in d:
			if d[i] > 1:
				duplicates.append(i)
		duplicates.sort()
		if duplicates:
			return duplicates
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		count = [0] * n
		for x in arr:
			count[x] += 1
			result = []
		for i in range(n):
			if count[i] > 1:
				result.append(i)
		if not result:
			return [-1]
		return sorted(result)


class Solution:

	def duplicates(self, arr, n):
		arr.sort()
		b = []
		c = []
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				b.append(arr[i])
		b = list(set(b))
		b.sort()
		if b == []:
			b.append(-1)
		return b


class Solution:

	def duplicates(self, arr, n):
		d = {}
		max_val = -1
		for element in arr:
			if element in d:
				d[element] += 1
			else:
				d[element] = 1
		max_val = [element for (element, count) in d.items() if count > 1]
		if len(max_val) == 0:
			return [-1]
		else:
			return sorted(max_val)


class Solution:

	def duplicates(self, arr, n):
		for i in range(0, n):
			index = arr[i] % n
			arr[index] += n
		flag = False
		res = []
		for i in range(0, n):
			if arr[i] // n > 1:
				res.append(i)
				flag = True
		if flag == False:
			res.append(-1)
		return res


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		if len(arr) == len(set(arr)):
			return [-1]
		dup = []
		dict = Counter(arr)
		for i in dict:
			if dict[i] > 1:
				dup.append(i)
		dup.sort()
		return dup


class Solution:

	def duplicates(self, arr, n):
		m = {}
		ans = []
		for el in arr:
			if el in m:
				if m[el] == 1:
					m[el] += 1
					ans.append(el)
			else:
				m[el] = 1
		ans.sort()
		if ans:
			return ans
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		res = []
		hash = {}
		for ele in arr:
			if ele not in hash:
				hash[ele] = 1
			else:
				hash[ele] += 1
		for (k, v) in hash.items():
			if v > 1:
				res.append(k)
		if res:
			res.sort()
			return res
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		res = []
		hashmap = {}
		setarr = []
		for i in arr:
			if i not in hashmap:
				hashmap[i] = 1
				setarr.append(i)
			else:
				hashmap[i] += 1
		setarr.sort()
		for i in setarr:
			if hashmap[i] > 1:
				res.append(i)
		if res:
			return res
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		a = {}
		b = []
		for i in arr:
			if i in a:
				if a[i] == 1:
					a[i] += 1
					b.append(i)
			else:
				a[i] = 1
		b.sort()
		if b:
			return b
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		arr.sort()
		curr_ele = arr[0]
		duplicates = []
		for i in range(1, n):
			if curr_ele == arr[i]:
				if duplicates == [] or duplicates[-1] != arr[i]:
					duplicates.append(arr[i])
			else:
				curr_ele = arr[i]
		if duplicates == []:
			return [-1]
		return duplicates


class Solution:

	def duplicates(self, arr, n):
		f = {}
		for i in arr:
			if i in f:
				f[i] += 1
			else:
				f[i] = 1
		res = []
		for j in f:
			if f[j] != 1:
				res.append(j)
		if len(res) == 0:
			return [-1]
		else:
			res.sort()
			return res


class Solution:

	def duplicates(self, arr, n):
		dic = {}
		for i in arr:
			dic[i] = 1 + dic.get(i, 0)
		out = []
		for (k, v) in dic.items():
			if v > 1:
				out.append(k)
		return sorted(out) if out else [-1]


class Solution:

	def duplicates(self, arr, n):
		duplicates = set()
		seen = set()
		for num in arr:
			if num in seen:
				duplicates.add(num)
			else:
				seen.add(num)
		if duplicates:
			return sorted(duplicates)
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		arr.sort()
		count = {}
		duplicates = []
		for a in arr:
			if a in count:
				count[a] = count[a] + 1
			else:
				count[a] = 1
		for (k, v) in count.items():
			if v > 1:
				duplicates.append(k)
		duplicates.sort()
		if len(duplicates) == 0:
			return [-1]
		else:
			return duplicates


class Solution:

	def duplicates(self, arr, n):
		y = {}
		ans = []
		for i in arr:
			if i in y:
				if y[i] == 1:
					ans.append(i)
					y[i] += 1
			else:
				y[i] = 1
		if len(ans) == 0:
			return [-1]
		ans.sort()
		return ans


class Solution:

	def duplicates(self, arr, n):
		l1 = []
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				if d[i] == 1:
					l1.append(i)
				d[i] += 1
		if len(l1) == 0:
			l1.append(-1)
			return l1
		else:
			l1.sort()
			return l1


class Solution:

	def duplicates(self, arr, n):
		(temp, res) = (set(), set())
		for i in arr:
			if i not in temp:
				temp.add(i)
			else:
				res.add(i)
		if res:
			return sorted(list(res))
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		l = {}
		ans = []
		for i in arr:
			if i in l:
				if l[i] == 1:
					l[i] += 1
					ans.append(i)
			else:
				l[i] = 1
		ans.sort()
		if ans:
			return ans
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		if len(arr) == len(set(arr)):
			return [-1]
		dop = {}
		for i in arr:
			dop[i] = dop.get(i, 0) + 1
		lp = []
		for i in dop:
			if dop[i] > 1:
				lp.append(i)
		if len(lp):
			lp.sort()
			return lp
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		l = set()
		arr.sort()
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				l.add(arr[i])
		if len(l) == 0:
			return [-1]
		x = list(l)
		x.sort()
		return x


class Solution:

	def duplicates(self, arr, n):
		count = {}
		for i in range(n):
			if arr[i] in count.keys():
				count[arr[i]] += 1
			else:
				count[arr[i]] = 1
		out = []
		for counts in count:
			if count[counts] > 1:
				out.append(counts)
		out.sort()
		if len(out) < 1:
			return [-1]
		else:
			return out


class Solution:

	def duplicates(self, arr, n):
		n = len(arr)
		for i in range(n):
			index = arr[i] % n
			arr[index] += n
		duplicates = []
		for i in range(n):
			if arr[i] // n > 1:
				duplicates.append(i)
		if len(duplicates) == 0:
			return [-1]
		else:
			return duplicates


class Solution:

	def duplicates(self, arr, n):
		seen = set()
		dup = set()
		for i in range(n):
			if arr[i] in seen and arr[i] not in dup:
				dup.add(arr[i])
			else:
				seen.add(arr[i])
		dup1 = sorted(dup)
		if len(dup) == 0:
			return [-1]
		else:
			return dup1


class Solution:

	def duplicates(self, arr, n):
		d = {}
		for _ in arr:
			if _ not in d:
				d[_] = 1
			else:
				d[_] += 1
		d1 = dict(((k, v) for (k, v) in d.items() if v != 1))
		if d1:
			return sorted(d1.keys())
		else:
			return [-1]


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		hash = {}
		lst = []
		for i in arr:
			if i in hash:
				lst.append(i)
			else:
				hash[i] = i
		if len(lst) == 0:
			return [-1]
		return sorted(set(lst))


class Solution:

	def duplicates(self, arr, n):
		for i in range(n):
			arr[i] = arr[i] + 1
		res = []
		count = 0
		for i in range(n):
			if abs(arr[i]) > n:
				index = abs(arr[i]) // (n + 1)
			else:
				index = abs(arr[i])
			if index == n:
				count += 1
				continue
			val = arr[index]
			if val < 0:
				res.append(index - 1)
				arr[index] = abs(arr[index]) * (n + 1)
			elif val > n:
				continue
			else:
				arr[index] = -arr[index]
		if count > 1:
			res.append(n - 1)
		if len(res) == 0:
			res.append(-1)
		else:
			res.sort()
		return res


class Solution:

	def duplicates(self, arr, n):
		freq_map = {}
		for elem in arr:
			if elem not in freq_map:
				freq_map[elem] = 1
			else:
				freq_map[elem] += 1
		ans = []
		for val in freq_map:
			if freq_map[val] > 1:
				ans.append(val)
		ans.sort()
		if not ans:
			return [-1]
		else:
			return ans


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		a = Counter(arr)
		b = list(a.keys())
		c = list(a.values())
		z = []
		for i in range(len(b)):
			if c[i] > 1:
				z.append(b[i])
		if len(z) == 0:
			return [-1]
		else:
			z.sort()
			return z


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		dup = []
		counterA = Counter(arr)
		for (i, j) in counterA.items():
			if j > 1:
				dup.append(i)
		if len(dup) == 0:
			dup.append(-1)
			return dup
		else:
			dup.sort()
			return dup


class Solution:

	def duplicates(self, arr, n):
		for indexNum in arr:
			arr[indexNum % n] += n
		res = []
		for i in range(n):
			if arr[i] // n >= 2:
				res.append(i)
		return res if res else [-1]
		s = set()
		res = []
		for num in arr:
			if num in s:
				res.append(num)
			s.add(num)
		return sorted(list(set(res))) if res else [-1]


class Solution:

	def duplicates(self, arr, n):
		for indexNum in arr:
			arr[indexNum % n] += n
		res = []
		for i in range(n):
			if arr[i] // n >= 2:
				res.append(i)
		return res if res else [-1]


class Solution:

	def duplicates(self, arr, n):
		sor = []
		dict = {}
		for i in range(n):
			if arr[i] in dict:
				dict[arr[i]] += 1
			else:
				dict[arr[i]] = 1
		for key in dict:
			if dict[key] > 1:
				sor.append(key)
		sor.sort()
		if len(sor) > 0:
			return sor
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		s = set()
		res = []
		for num in arr:
			if num in s:
				res.append(num)
			s.add(num)
		return sorted(list(set(res))) if res else [-1]


class Solution:

	def duplicates(self, arr, n):
		cnt = 0
		res = []
		hmap = {}
		for i in range(n):
			hmap[arr[i]] = hmap.get(arr[i], 0) + 1
		for (key, val) in hmap.items():
			if val > 1:
				res.append(key)
		res.sort()
		if res:
			return res
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		nums = set(arr)
		if len(nums) == len(arr) or n == 1:
			return [-1]
		ans = []
		nums = arr
		nums.sort()
		for i in range(1, n):
			if nums[i] == nums[i - 1]:
				ans.append(nums[i])
		ans = list(set(ans))
		ans.sort()
		return ans


class Solution:

	def duplicates(self, arr, n):
		a = [0] * (n + 1)
		b = []
		for i in arr:
			a[i] += 1
			if a[i] == 2:
				b.append(i)
		return [-1] if len(b) == 0 else sorted(b)


class Solution:

	def duplicates(self, arr, n):
		ans = []
		for i in range(n):
			ind = arr[i] % n
			arr[ind] += n
		for i in range(n):
			if arr[i] // n > 1:
				ans.append(i)
		if len(ans) < 1:
			ans.append(-1)
		return ans


class Solution:

	def duplicates(self, arr, n):
		freq = [0] * (max(arr) + 1)
		Dups = []
		for i in arr:
			freq[i] += 1
			if freq[i] == 2:
				Dups.append(i)
		return [-1] if len(Dups) == 0 else sorted(Dups)


class Solution:

	def duplicates(self, arr, n):
		arr_set = set()
		duplicates = set()
		for i in arr:
			if i in arr_set:
				duplicates.add(i)
			arr_set.add(i)
		if len(duplicates) == 0:
			return [-1]
		return sorted(duplicates)


class Solution:

	def duplicates(self, arr, n):
		seen = set()
		duplicate_item = {x for x in arr if x in seen or (seen.add(x) or False)}
		return [-1] if len(duplicate_item) == 0 else sorted(list(duplicate_item))


class Solution:

	def duplicates(self, arr, n):
		count = {}
		result = []
		found = False
		for i in arr:
			count[i] = 1 + count.get(i, 0)
		for (i, c) in count.items():
			if c > 1:
				result.append(i)
				found = True
		if found:
			return sorted(result)
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		count = [0] * n
		res = set()
		for i in range(n):
			if count[arr[i]] == 1:
				res.add(arr[i])
			else:
				count[arr[i]] = 1
		return sorted(res) if res else [-1]


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		dic = Counter(arr)
		a = []
		found = False
		for (k, v) in dic.items():
			if dic[k] > 1:
				a.append(k)
				found = True
		if found:
			return sorted(a)
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		r = []
		arr.sort()
		i = 1
		while i < n:
			if arr[i] == arr[i - 1]:
				r.append(arr[i])
				while i + 1 < n and arr[i + 1] == arr[i]:
					i = i + 1
			i = i + 1
		if len(r) == 0:
			r.append(-1)
		return r


class Solution:

	def duplicates(self, arr, n):
		result = []
		for i in range(n):
			index = arr[i] % n
			arr[index] += n
		for i in range(n):
			if arr[i] >= 2 * n:
				result.append(i)
		if result:
			return result
		else:
			return [-1]


class Solution:

	def duplicates(self, array, n):
		for i in range(n):
			x = array[i] % n
			array[x] += n
		result = list()
		for i in range(n):
			if array[i] >= n * 2:
				result.append(i)
		if not result:
			return [-1]
		return result


class Solution:

	def duplicates(self, arr, n):
		d = {}
		a = []
		for i in arr:
			try:
				d[i] += 1
				if d[i] == 2:
					a.append(i)
			except:
				d.__setitem__(i, 1)
		if len(a) > 0:
			return sorted(a)
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		count_map = {}
		result = []
		for num in arr:
			count_map[num] = count_map.get(num, 0) + 1
		found_duplicates = False
		for (num, count) in count_map.items():
			if count > 1:
				result.append(num)
				found_duplicates = True
		if found_duplicates:
			return sorted(result)
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		arr.sort()
		r = []
		tmp = arr[0]
		inarr = -1
		for i in range(1, n):
			if tmp == arr[i] and inarr == -1:
				r.append(arr[i])
				inarr = arr[i]
			if tmp != arr[i]:
				tmp = arr[i]
				inarr = -1
		if len(r) < 1:
			return [-1]
		return r


class Solution:

	def duplicates(self, arr, n):
		dic = {}
		ans = []
		for i in arr:
			if i in dic:
				dic[i] = dic[i] + 1
			else:
				dic[i] = 1
		flag = 0
		for (key, value) in dic.items():
			if value > 1:
				ans.append(key)
				flag = 1
		if not flag:
			return [-1]
		ans.sort()
		return ans


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		d = {}
		ans = []
		for x in arr:
			if x in d:
				if d[x] == 1:
					d[x] += 1
					ans.append(x)
			else:
				d[x] = 1
		ans.sort()
		if ans:
			return ans
		return [-1]


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		m = {}
		ans = []
		for el in arr:
			if el in m:
				if m[el] == 1:
					m[el] += 1
					ans.append(el)
			else:
				m[el] = 1
		ans.sort()
		if ans:
			return ans
		return [-1]


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		if len(arr) == len(set(arr)):
			return [-1]
		dup = []
		Dict = Counter(arr)
		for x in Dict:
			if Dict[x] > 1:
				dup.append(x)
		if len(dup):
			dup.sort()
			return dup
		else:
			return [-1]


class Solution:

	def duplicates(self, arr, n):
		st = {}
		lst = []
		for el in arr:
			if el in st:
				if st[el] == 1:
					st[el] += 1
					lst.append(el)
			else:
				st[el] = 1
		lst.sort()
		if lst:
			return lst
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		freq = [0] * n
		for num in arr:
			freq[num] += 1
		res = []
		for i in range(n):
			if freq[i] > 1:
				res.append(i)
		return res if len(res) > 0 else [-1]


class Solution:

	def duplicates(self, arr, n):
		for num in arr:
			idx = num % n
			arr[idx] += n
		ans = []
		for i in range(0, n):
			if arr[i] // n > 1:
				ans.append(i)
		if len(ans) > 0:
			return ans
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		m = {}
		list1 = []
		for i in arr:
			if i in m:
				if m[i] == 1:
					m[i] += 1
					list1.append(i)
			else:
				m[i] = 1
		list1.sort()
		if list1:
			return list1
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		hash_map = {}
		result = []
		for i in arr:
			hash_map[i] = 1 + hash_map.get(i, 0)
		for i in hash_map:
			if hash_map[i] != 1:
				result.append(i)
		if not result:
			return [-1]
		return sorted(result)


class Solution:

	def duplicates(self, arr, n):
		maps = {}
		ret = []
		for x in arr:
			w = maps.get(x, 0) + 1
			maps[x] = w
			if w == 2:
				ret.append(x)
		if len(ret) == 0:
			return [-1]
		else:
			ret.sort()
			return ret


class Solution:

	def duplicates(self, arr, n):
		arr.sort()
		s = []
		p = 0
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				if len(s) == 0:
					s.append(arr[i])
				elif s[p] != arr[i]:
					s.append(arr[i])
					p += 1
		if len(s) == 0:
			return [-1]
		return s


import collections

class Solution:

	def duplicates(self, arr, n):
		c = collections.Counter(arr)
		k = c.most_common()
		result = []
		for (i, j) in k:
			if j > 1:
				result.append(i)
			else:
				break
		result.sort()
		return result if result and len(result) > 0 else [-1]


class Solution:

	def duplicates(self, arr, n):
		freq = {}
		ans = set()
		for i in arr:
			try:
				freq[i] += 1
			except:
				freq[i] = 1
		for i in range(n):
			if freq[arr[i]] > 1:
				ans.add(arr[i])
		if len(ans) == 0:
			return [-1]
		ans = list(ans)
		ans.sort()
		return ans


class Solution:

	def duplicates(self, a, n):
		freq = {}
		for i in a:
			if i in freq:
				freq[i] += 1
			else:
				freq[i] = 1
		return sorted([i for i in freq if freq[i] > 1]) or [-1]


class Solution:

	def duplicates(self, arr, n):
		arr = sorted(arr)
		(l, f) = (set(), 0)
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				l.add(arr[i])
				f = 1
		l = sorted(l)
		if f == 0:
			return [-1]
		else:
			return l


class Solution:

	def duplicates(self, arr, n):
		seen = set()
		dup = set()
		for i in arr:
			if i in seen:
				dup.add(i)
			else:
				seen.add(i)
		if len(dup) == 0:
			dup.add(-1)
			seen.add(-1)
		return sorted(dup)


class Solution:

	def duplicates(self, arr, n):
		m = {}
		s = []
		for i in arr:
			if i not in m:
				m[i] = 1
			else:
				m[i] += 1
		for i in m:
			if m[i] >= 2:
				s.append(i)
		if len(s) == 0:
			return [-1]
		return sorted(s)


class Solution:

	def duplicates(self, arr, n):
		dict = {}
		for i in range(n):
			if arr[i] not in dict:
				dict[arr[i]] = 1
			else:
				dict[arr[i]] += 1
		counter = 0
		for (key, val) in dict.items():
			if val != 1:
				arr[counter] = key
				counter += 1
		if counter == 0:
			return [-1]
		new = arr[:counter]
		new.sort()
		return new


from collections import Counter

class Solution:

	def duplicates(self, arr, n):
		hMap = {x: 0 for x in arr}
		for x in arr:
			hMap[x] += 1
		temp = []
		for (k, v) in hMap.items():
			if v > 1:
				temp.append(k)
		if len(temp) == 0:
			return [-1]
		res = sorted(temp)
		return res


class Solution:

	def duplicates(self, arr, n):
		a = []
		dict1 = {}
		for i in arr:
			if i not in dict1:
				dict1[i] = 1
			else:
				dict1[i] += 1
		for i in dict1:
			if dict1[i] != 1:
				a.append(i)
		a.sort()
		if len(a) == 0:
			return [-1]
		return a


class Solution:

	def duplicates(self, arr, n):
		(temp, res, max1) = (set(), set(), float('-inf'))
		for i in arr:
			if i not in temp:
				temp.add(i)
			else:
				res.add(i)
				max1 = max(max1, i) + 1
		if max1 == float('-inf'):
			return [-1]
		temp1 = [0 for i in range(max1)]
		for i in res:
			temp1[i] = 1
		res = []
		for i in range(max1):
			if temp1[i]:
				res.append(i)
		return res


class Solution:

	def duplicates(self, arr, n):
		freq = {}
		duplicates = []
		for num in arr:
			if num in freq:
				freq[num] += 1
			else:
				freq[num] = 1
		for (num, count) in freq.items():
			if count > 1:
				duplicates.append(num)
		duplicates.sort()
		return duplicates if duplicates else [-1]


class Solution:

	def duplicates(self, arr, n):
		d = {}
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		d1 = dict(sorted(d.items(), key=lambda x: x[0]))
		a = []
		for i in d1:
			if d1[i] > 1:
				a.append(i)
		a.sort()
		if len(a) == 0:
			return [-1]
		else:
			return a


class Solution:

	def duplicates(self, arr, n):
		d = {}
		t = []
		for i in arr:
			if i in d:
				t.append(i)
			else:
				d[i] = 1
		if len(t) != 0:
			t = list(set(t))
			t.sort()
			return t
		return [-1]


class Solution:

	def duplicates(self, arr, n):
		a = {}
		for i in arr:
			if i not in a:
				a[i] = 1
			else:
				a[i] += 1
		b = [i for i in a if a[i] > 1]
		if b == []:
			return [-1]
		else:
			k = sorted(b)
			return k


class Solution:

	def duplicates(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		arr[:] = [i for i in d.keys() if d[i] > 1]
		arr.sort()
		if arr != []:
			return arr
		else:
			return [-1]