import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner stdIn = new Scanner(System.in); int numOfCandles = 0, i = 0, largest = 0; boolean outOfRange = false; int[] candles = null; if (stdIn.hasNextInt()) { numOfCandles = stdIn.nextInt(); if (numOfCandles >= 1 && numOfCandles <= Math.pow(10.0, 5.0)) candles = new int[numOfCandles]; else { outOfRange = true; } } while (stdIn.hasNextInt()) { int next = stdIn.nextInt(); if (next >= 1 && next <= Math.pow(10.0, 7.0)) { candles[i++] = next; if (largest <= next) largest = next; } else { outOfRange = true; } } if (!outOfRange) System.out.println(findBlowOutCandles(candles, largest)); else System.out.println("Too many candles and/or too much heights."); } private static int findBlowOutCandles(final int[] theCandles, final int theLargest) { int count = 0; for (int i = 0; i < theCandles.length; i++) { if (theCandles[i] == theLargest) { count++; } } return count; } }