import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Set; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); HashMap map = new HashMap<>(); int[] arr = new int[n]; for(int i=0;i> allEntries = map.entrySet(); int ans = 0; for(Map.Entry entry : allEntries){ int num = entry.getKey(); int max = 0; if(map.get(num-1)!=null && map.get(num-1)>0){ max = map.get(num-1); } max += entry.getValue(); if(max > ans){ ans = max; } } System.out.println(ans); } }