import java.util.*;
class Main {
public static void main(String[] args) {
List<Integer> a = new ArrayList<>(Arrays.asList(1,2,3,4,3,2,1));
int length = a.size();
HashMap<Integer, Integer> lonely = new HashMap<>();
for (int i = 0; i < length; i++) {
int count = 0;
for (int j = 0; j < length; j++) {
if(a.get(i) == a.get(j)){
count++;
lonely.put(a.get(i), count);
}
}
}
System.out.println(lonely);
}
}