#include <iostream>
using namespace std;
#include<bits/stdc++.h>

int main() {
	// your code goes here
	int arr[] = {-2,1,-3,4,-1,2,1,-5,4};
	int n = sizeof(arr)/sizeof(int);
	//there are i+1 subarrays ending at i we have to find the maximum subarray sum ending at i 
	vector<int>p1;
	for(int i = 0 ; i <n ; i++){
		int sum = 0; int t=INT_MIN;
		for(int j = i ;j>=0;j--){
			sum+=arr[j];
			t=max(t,sum);
		}
		p1.push_back(t);
	}
	for(int i = 0 ; i<n;i++) cout<<p1[i]<<" ";
	
	return 0;
}