To solve this question,we need to find the law of times of every number appears in all segments.
Note: sum += num*(N - i)(i + 1);
//if change it to sum+= (N - i)(i + 1)num,it can’t ac,because (N - i)(i + 1) would be a too big number to cause data overrun.
#include <iostream>
#include <stdio.h>
#include<stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
int main() {
int N;
cin >> N;
double sum = 0;
double num;
for (int i = 0; i < N; i++)
{
cin >> num;
sum += num*(N - i)*(i + 1);
}
printf("%.2f", sum);
return 0;
}