import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) { //long t = System.currentTimeMillis(); new Main().run(); //System.err.println(System.currentTimeMillis() - t); } int get(int[] D,int s) { int ret=100; for(int i=0;i>i)%2==0)continue; if(D[i]<0)ret+=100; } return ret; } void run() { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int[] D=new int[N]; for(int i=0;i>next)%2==1)continue; int ns=s|1<0) { dp[ns]=Math.max(dp[ns], Math.min(HP,dp[s]+D[next])); }else { if(dp[s]+D[next]<=0)continue; dp[ns]=Math.max(dp[ns], dp[s]+D[next]); } } } System.out.println(dp[(1<