<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. For each index <code>i</code> (<code>1 <= i <= nums.length - 2</code>) the <strong>beauty</strong> of <code>nums[i]</code> equals:</p>
<ul>
<li><code>2</code>, if <code>nums[j] < nums[i] < nums[k]</code>, for <strong>all</strong><code>0 <= j < i</code> and for <strong>all</strong><code>i < k <= nums.length - 1</code>.</li>
<li><code>1</code>, if <code>nums[i - 1] < nums[i] < nums[i + 1]</code>, and the previous condition is not satisfied.</li>
<li><code>0</code>, if none of the previous conditions holds.</li>
</ul>
<p>Return<em> the <strong>sum of beauty</strong> of all </em><code>nums[i]</code><em> where </em><code>1 <= i <= nums.length - 2</code>.</p>