okay so i've got n and an array of n numbers, i have to go through all the three's of numbers like a, a[j], a[k] so that i < j < k and take the maximum of each such numbers (max of a, a[j], a[k]). my first guess is three loops but that seems to be to slow:
for( int i = 0; i < n-2; ++i )
for( int j = i+1; j < n-1; ++j )
for( int k = j+1; k < n; ++k )
s += max( a[i], max( a[j], a[k] ) );