为什么WA 0? 不应该30pts吗....
#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
inline int read() {int x=0,f=1; char ch=getchar();while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar();}while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
int n,a[100005],pre[100005][2];
//0 表示没用最后一位 1 表示用了最后一位
signed main(){
n=read();
for(int i=1;i<=n;i++) a[i]=read();
pre[1][0]=0;
pre[1][1]=a[1];
for(int i=2;i<=n;i++){
pre[i][0]=max(pre[i][0],max(pre[i-1][1],pre[i-1][0]));
pre[i][1]=max(pre[i][1],max(pre[i][0],pre[i-1][0]+a[i]));
}
int res=0;
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
if(i==j){
res+=max(pre[j][0]-pre[i-1][1],pre[j][1]-pre[i-1][0]);
}
else res+=pre[j][1]-pre[i-1][1];
res%=MOD;
}
}
cout<<res<<endl;
return 0;
}