Company: Morgan stanley_12may
Difficulty: medium
Security Key for Data Packets Problem Description While transmitting data, N packets are given a unique ID from 0 to N-1. A security key is calculated based on the size of the data packets using a protocol. In each step, the protocol chooses K consecutive data packets with the same data size and finds the square of K. Then the protocol removes those packets from the calculation for the next step. This process continues until there is no packet left for calculation. The security key is the sum of the squares for all steps which should be the maximum possible value. Write an algorithm to find the security key for the given N data packets. Input The first line of the input consists of an integer - num , representing the number of data packets (N). The second line consists of N space-separated integers - dataSize 0 , dataSize 1 , ..., dataSize N-1 , representing the size of the data packets. Output Print an integer representing the security key for the given N data packets. Constraints 1 &