Interviewstreet Triplet
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/13928575/interviewstreet-triplet-challenge">interviewstreet Triplet challenge</a>  </p>
</blockquote>



<p>There is an integer array <code>d</code> which does not contain more than two elements of the same value. How many distinct ascending triples <code>(d[i] &lt; d[j] &lt; d[k], i &lt; j &lt; k)</code> are present? </p>

<p><strong>Input format:</strong></p>

<p>The first line contains an integer <code>N</code> denoting the number of elements in the array. This is followed by a single line containing <code>N</code> integers separated by a single space with no leading/trailing spaces</p>

<p><strong>Output format:</strong></p>

<p>A single integer that denotes the number of distinct ascending triples present in the array</p>

<p><strong>Constraints:</strong></p>

<pre><code>N &lt;= 10^5
</code></pre>

<p>Every element of the array is present at most twice</p>

<p>Every element of the array is a 32-bit positive integer</p>

<p><strong>Sample input:</strong></p>

<pre><code>6

1 1 2 2 3 4
</code></pre>

<p><strong>Sample output:</strong></p>

<pre><code>4
</code></pre>

<p><strong>Explanation:</strong></p>

<p>The distinct triplets are</p>

<pre><code>(1,2,3)
(1,2,4)
(1,3,4)
(2,3,4)
</code></pre>
