function countValues(elements, value)
{
var cnt = 0;
for (var i = 0; i < elements.length; i++) {
if(elements[i] == value) {
cnt++;
}
}
return cnt;
}
function removeUniqueValues(elements)
{
var newElements = [], cnt = 0;
for(var i = 0; i < elements.length; i++) {
cnt = countValues(elements, elements[i]);
if(cnt > 1) {
newElements.push(elements[i]);
}
}
return newElements;
}
var elements = [2,2,3,1,1];
var newElements = removeUniqueValues(elements);
console.log(newElements);