#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
vector<int> in;
vector<int> vec;
int N;
scanf("%d", &N);
int size;
size = N * (N + 1) / 2;
for(int i = 0; i<size; i++){
int temp;
scanf("%d", &temp);
in.push_back(temp);
}
vec.resize(size, 0);
int i = 0;
vec[0] = in[0];
for(int j = 1; j<N; j++){ //줄 변경
for(int m = 0; m<j; m++){ //m번째 줄 전부 탐색
for(int k = 0; k < 2; k++){ //아왼, 아오
if(vec[i + k + j] < vec[i] + in[i + k + j])
vec[i + k + j] = vec[i] + in[i + k + j];
}
i++;
}
}
int max = 0;
for(int j = size-N; j <size; j++){
if(max < vec[j]){
max = vec[j];
}
}
printf("%d\n", max);
}