import java.util.Scanner;
public class Main {
public static void main
(String[] args
) { Scanner scanner
= new Scanner
(System.
in); int n = scanner.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = scanner.nextInt();
}
int maxElement
= 0, maxCount
= 0, minElement
= 0, minCount
= Integer.
MAX_VALUE;
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = 0; j < n; j++) {
if (arr[i] == arr[j]) {
cnt++;
}
}
if (maxCount < cnt) {
maxCount = cnt;
maxElement = arr[i];
}
if (minCount > cnt) {
minCount = cnt;
minElement = arr[i];
}
}
System.
out.
println("Max Element: " + maxElement
+ ", Max Count: " + maxCount
); System.
out.
println("Min Element: " + minElement
+ ", Min Count: " + minCount
); }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKcHVibGljIGNsYXNzIE1haW4gewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIFNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgaW50IG4gPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICBpbnRbXSBhcnIgPSBuZXcgaW50W25dOwogICAgICAgIAogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgIGFycltpXSA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBpbnQgbWF4RWxlbWVudCA9IDAsIG1heENvdW50ID0gMCwgbWluRWxlbWVudCA9IDAsIG1pbkNvdW50ID0gSW50ZWdlci5NQVhfVkFMVUU7CiAgICAgICAgCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgaW50IGNudCA9IDA7CiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgbjsgaisrKSB7CiAgICAgICAgICAgICAgICBpZiAoYXJyW2ldID09IGFycltqXSkgewogICAgICAgICAgICAgICAgICAgIGNudCsrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIAogICAgICAgICAgICBpZiAobWF4Q291bnQgPCBjbnQpIHsKICAgICAgICAgICAgICAgIG1heENvdW50ID0gY250OwogICAgICAgICAgICAgICAgbWF4RWxlbWVudCA9IGFycltpXTsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICAgICAgaWYgKG1pbkNvdW50ID4gY250KSB7CiAgICAgICAgICAgICAgICBtaW5Db3VudCA9IGNudDsKICAgICAgICAgICAgICAgIG1pbkVsZW1lbnQgPSBhcnJbaV07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgCiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJNYXggRWxlbWVudDogIiArIG1heEVsZW1lbnQgKyAiLCBNYXggQ291bnQ6ICIgKyBtYXhDb3VudCk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJNaW4gRWxlbWVudDogIiArIG1pbkVsZW1lbnQgKyAiLCBNaW4gQ291bnQ6ICIgKyBtaW5Db3VudCk7CiAgICB9Cn0=