#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
#ifdef LOCAL
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
#endif // LOCAL
int n;
scanf("%d",&n);
double ans=0;
for(int i=0;i<n;i++){
double a;
scanf("%lf",&a);
ans+=a*(i+1)*(n-i);
}
printf("%.2f\n",ans);
return 0;
}
注意:
ans+=a*(i+1)*(n-i);
这里如果写成ans+=(i+1)*(n-i)*a;会出错