import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[][] exists = new boolean[n + 1][10]; exists[0][0] = true; int max = 0; for (int i = 1; i <= n; i++) { int x = sc.nextInt() % 10; for (int j = i - 1; j >= 0 && j + 1 + (n - i + 1) > max; j--) { for (int k = 0; k < 10; k++) { if (exists[j][k]) { exists[j + 1][(k + x) % 10] = true; } } if (exists[j + 1][0]) { max = Math.max(max, j + 1); } } } System.out.println(max); } }