import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Shuifeng01 { static int res=0; public static void main(String[] args) throws IOException { BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); int n= Integer.parseInt(br.readLine()); String[] s = br.readLine().split(" "); int[] nums= new int[n]; for (int i = 0; i < n; i++) { nums[i]=Integer.parseInt(s[i]); } dfs(nums,0,0,0); System.out.println(res); } // index 当前所在的城市,kaixin 当前的开心值,buyNums 当前购买的礼品数 private static void dfs(int[] nums,int index,int kaixin,int buyNums){ if(index==nums.length){ if(kaixin>=0){ res=Math.max(res,buyNums); } return ; } // 买 dfs(nums,index+1,kaixin+nums[index],buyNums+1); // 不买 dfs(nums,index+1,kaixin,buyNums); } }