#pragma GCC target("avx,avx2,fma") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); //想定TLE3 (O(N^2)) long long N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector S(N + 1, 0); for (int i = 0; i < N; i++){ S[i + 1] = S[i] + A[i]; } long long ans = 0; for (int i = 0; i < N; i++){ for (int j = i; j < N; j++){ ans += S[j + 1] - S[i]; } } cout << ans << endl; }