All Tracks Data Structures Hash Tables Basics of Hash Tables Problem

The Electric Type
/

Data Structures, Easy-Medium, Hash table, Hash table, Map, Set

Problem
Editorial
Analytics

Everyone knows that some special Pikachus hate evolving into Raichus. (The legend says because Raichu is ugly, and Pikachu looks good!)

The question is how do we find these special Pikachus who hate evolution? The crazy Poke'mon trainer Ash Catch'Em has derived a random algorithm, which is completely wrong, but since he's your friend, you've to humor him and his crazy algorithms.

He thinks if you are given N Pikachus in an array, A1,A2 ... AN, where each Pikachu is denoted by an integer. The total number of unique pairs (Ai,Aj) where i < j is the number of Pikachus who hate evolution.

Input format:
The first line will consist of a single integer N. The second line consists of N integers A1,A2 ... AN.

Output format:
Output the total number of unique pairs (Ai,Aj) that can be formed, which will also be the number of special Pikachus.

Constraints:
1 ≤ N ≤ 2 * 105
1 ≤ Ai ≤ 109

Reference:
enter image description here

SAMPLE INPUT
5
1 2 2 1 3
SAMPLE OUTPUT
6
Explanation

All the possible pairs are (1,1),(1,2) , (1,3) , (2,1), (2,2), (2,3).

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?