import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int[] V = new int[N + 1]; for (int i = 1; i <= N; i++) { V[i] = scanner.nextInt(); } int[] dp = new int[N + 1]; dp[1] = V[1]; for (int i = 2; i <= N; i++) { int max = dp[i - 1]; for (int j = 0; j < i - 1; j++) { max = Math.max(max, dp[j] + V[i]); } dp[i] = max; } System.out.println(dp[N]); } }