﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MaximalSum {
  class Program {
    static void Main() {
      int n = int.Parse(Console.ReadLine());
      int[] numbers = new int[n];
      int suma = 0;
      int sumaMax = 0;

      for(int i = 0;i<n;i++) {
        numbers[i] = int.Parse(Console.ReadLine());
      }

      for(int i = 0;i<numbers.Length;i++) {
        for(int j = i ;j<numbers.Length;j++) {
          suma = suma + numbers[j];
          sumaMax = Math.Max(sumaMax, suma);
        }
        suma = 0;
      }
      
      Console.WriteLine(sumaMax);
    }
  }
}
