代码重发一遍:
```cpp
#include <iostream>
using namespace std;
int a[10010];
int main()
{
int n,max=0;
long long int sum=0;
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>a[i];
if (a[i]>max)
max=a[i];
}
for (int i=1;i<=max;i++)
{
int l,r;
for (int j=1;j<n-1;j++)
{
if(a[j]>=i)
{
l=j;
break;
}
}
for (int j=n-2;j>=1;j--)
{
if(a[j]>=i)
{
r=j;
break;
}
}
for (int j=1;j<=r;j++)
{
if (a[j]<i)
sum++;
}
}
cout<<sum<<endl;
return 0;
}
```
by LJY_ljy @ 2018-11-23 20:16:20