/* -*- coding: utf-8 -*- * * 1096.cc: No.1096 Range Sums - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ typedef long long ll; /* global variables */ ll ass[MAX_N + 1]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int ai; scanf("%d", &ai); ass[i + 1] = ass[i] + ai; } ll sum = 0, asum = 0; for (int l = n; l > 0; l--) { asum += ass[l] - ass[n - l]; sum += asum; } printf("%lld\n", sum); return 0; }