using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; static class Program{ const int mod=(int)1e9+7; const long inf=long.MaxValue-1; static List>[] li; static bool[] b; static long[] h,d; static long ans=0; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; int n=s[0],m=n-1; li=new List>[n+1]; b=new bool[n+1]; h=new long[n+1]; d=new long[n+1]; for(int i=1;i<=n;i++){li[i]=new List>();} for(int i=0;i=d[i];j--) {dp[j]=Max(dp[j],dp[j-d[i]]+h[i]);} } Console.WriteLine(ans+dp.Max()); } static long Fu(int a,int g,int z){ b[a]=true; long p=0; for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i