<p>There are <code>n</code> soldiers standing in a line. Each soldier is assigned a <strong>unique</strong><code>rating</code> value.</p>
<p>You have to form a team of 3 soldiers amongst them under the following rules:</p>
<ul>
<li>Choose 3 soldiers with index (<code>i</code>, <code>j</code>, <code>k</code>) with rating (<code>rating[i]</code>, <code>rating[j]</code>, <code>rating[k]</code>).</li>
<li>A team is valid if: (<code>rating[i] < rating[j] < rating[k]</code>) or (<code>rating[i] > rating[j] > rating[k]</code>) where (<code>0 <= i < j < k < n</code>).</li>
</ul>
<p>Return the number of teams you can form given the conditions. (soldiers can be part of multiple teams).</p>