import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, int[] as) {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] nextArray(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDoubleArray(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public int[][] nextIntMatrix(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLongMatrix(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDoubleMatrix(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
}

class ModCalculator {
  private final long mod;
  private final ModCombinationCache modCombinationCache;
  
  ModCalculator(long mod) {
    this.mod = mod;
    this.modCombinationCache = new ModCombinationCache();
  }
  
  public long add(long a, long b) {
    return (a + b) % mod;
  }
  
  public long sub(long a, long b) {
    return (a - b + mod) % mod;
  }
  
  public long mul(long a, long b) {
    return (a * b) % mod;
  }
  
  public long pow(long a, long b) {
    if (b == 0) {
      return 1;
    }
    long v = pow(mul(a, a), b / 2);
    if (b % 2 == 1) {
      return mul(v, a);
    } else {
      return v;
    }
  }
  
  public long inverse(long a) {
    return pow(a, mod - 2);
  }
  
  public long div(long a, long b) {
    return mul(a, inverse(b));
  }
  
  public long getF(int n) {
    return modCombinationCache.getF(n);
  }
  
  public long getP(int n, int r) {
    return modCombinationCache.getP(n, r);
  }
  
  public long getC(int n, int k) {
    return modCombinationCache.getC(n, k);
  }
  
  class ModCombinationCache {
    private final List<Long> factorialCache;
    private final List<Long> factorialInverseCache;
    
    public ModCombinationCache() {
      factorialCache = new ArrayList<>();
      factorialCache.add(1L);
      factorialInverseCache = new ArrayList<>();
      factorialInverseCache.add(1L);
    }
    
    private void resize(int n) {
      for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      }
    }
    
    long getF(int n) {
      resize(n);
      return factorialCache.get(n);
    }
    
    long getP(int n, int r) {
      resize(n);
      return mul(factorialCache.get(n), factorialInverseCache.get(n - r));
    }
    
    long getC(int n, int k) {
      resize(n);
      return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)));
    }
  }
}
 
class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
  
  public static void shuffle(int[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  }
  
  public static void shuffle(long[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  }
  
  public static void sort(int[] array) {
    shuffle(array);
    Arrays.sort(array);
  }
  
  public static void sort(long[] array) {
    shuffle(array);
    Arrays.sort(array);
  }
}

class UnionFind {
  int[] parents;
  int[] ranks;

  UnionFind(int n) {
    parents = new int[n];
    ranks = new int[n];

    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  }

  public int getRoot(int index) {
    if (parents[index] == index) {
      return index;
    } else {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    }
  }

  public boolean sameGroup(int a, int b) {
    return getRoot(a) == getRoot(b);
  }

  public void merge(int a, int b) {
    int rootA = getRoot(a);
    int rootB = getRoot(b);
    if (rootA == rootB) {
      return;
    }
    if (ranks[rootA] < ranks[rootB]) {
      parents[rootA] = rootB;
    } else if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
  private static String solve(int n, int[] as) {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
} Main private static String solve(int n, int[] as) {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  } solve {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  } boolean[] existGroups = new boolean[8]; existGroups new boolean[8] 8 int countTop = 0; countTop 0 for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    } int a as {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    } {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    } if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      } a < 3200 a 3200 {
        existGroups[a / 400] = true;
      } existGroups[a / 400] = true existGroups[a / 400] existGroups a / 400 a 400 true {
        countTop++;
      } countTop++ countTop int countGroup = 0; countGroup 0 for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    } boolean b existGroups {
      if (b) {
        countGroup++;
      }
    } {
      if (b) {
        countGroup++;
      }
    } if (b) {
        countGroup++;
      } b {
        countGroup++;
      } countGroup++ countGroup int min; min int max; max if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    } countGroup > 0 countGroup 0 {
      min = countGroup;
      max = countGroup + countTop;
    } min = countGroup min countGroup max = countGroup + countTop max countGroup + countTop countGroup countTop {
      min = 1;
      max = countTop;
    } min = 1 min 1 max = countTop max countTop return String.format("%d %d", min, max); String.format("%d %d", min, max) String.format String "%d %d" min max int n n int[] as as private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  } execute {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  } int n = reader.nextInt(); n reader.nextInt() reader.nextInt reader int[] as = reader.nextIntArray(n); as reader.nextIntArray(n) reader.nextIntArray reader n out.println(solve(n, as)) out.println out solve(n, as) solve n as ContestReader reader reader PrintWriter out out public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  } main {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  } ContestReader reader = new ContestReader(System.in); reader new ContestReader(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) execute(reader, out) execute reader out out.flush() out.flush out String[] args args class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] nextArray(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDoubleArray(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public int[][] nextIntMatrix(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLongMatrix(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDoubleMatrix(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
} ContestReader private BufferedReader reader; reader private StringTokenizer tokenizer; tokenizer ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  } ContestReader {
    reader = new BufferedReader(new InputStreamReader(in));
  } reader = new BufferedReader(new InputStreamReader(in)) reader new BufferedReader(new InputStreamReader(in)) InputStream in in public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  } next {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    } try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      } catch (Exception e) {
        throw new RuntimeException(e);
      } Exception e {
        throw new RuntimeException(e);
      } throw new RuntimeException(e); new RuntimeException(e) {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } tokenizer = new java.util.StringTokenizer(reader.readLine()) tokenizer new java.util.StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public int nextInt() {
    return Integer.parseInt(next());
  } nextInt {
    return Integer.parseInt(next());
  } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() {
    return Long.parseLong(next());
  } nextLong {
    return Long.parseLong(next());
  } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() {
    return Double.parseDouble(next());
  } nextDouble {
    return Double.parseDouble(next());
  } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String[] nextArray(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  } nextArray {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  } String[] array = new String[n]; array new String[n] n for (int i = 0; i < n; i++) {
      array[i] = next();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      array[i] = next();
    } {
      array[i] = next();
    } array[i] = next() array[i] array i next() next return array; array int n n public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  } nextIntArray {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  } int[] array = new int[n]; array new int[n] n for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      array[i] = nextInt();
    } {
      array[i] = nextInt();
    } array[i] = nextInt() array[i] array i nextInt() nextInt return array; array int n n public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  } nextLongArray {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  } long[] array = new long[n]; array new long[n] n for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      array[i] = nextLong();
    } {
      array[i] = nextLong();
    } array[i] = nextLong() array[i] array i nextLong() nextLong return array; array int n n public double[] nextDoubleArray(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  } nextDoubleArray {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  } double[] array = new double[n]; array new double[n] n for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      array[i] = nextDouble();
    } {
      array[i] = nextDouble();
    } array[i] = nextDouble() array[i] array i nextDouble() nextDouble return array; array int n n public int[][] nextIntMatrix(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  } nextIntMatrix {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  } int[][] matrix = new int[n][m]; matrix new int[n][m] n m for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    } {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    } for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      } int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
        matrix[i][j] = nextInt();
      } {
        matrix[i][j] = nextInt();
      } matrix[i][j] = nextInt() matrix[i][j] matrix[i] matrix i j nextInt() nextInt return matrix; matrix int n n int m m public long[][] nextLongMatrix(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  } nextLongMatrix {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  } long[][] matrix = new long[n][m]; matrix new long[n][m] n m for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    } {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    } for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      } int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
        matrix[i][j] = nextLong();
      } {
        matrix[i][j] = nextLong();
      } matrix[i][j] = nextLong() matrix[i][j] matrix[i] matrix i j nextLong() nextLong return matrix; matrix int n n int m m public double[][] nextDoubleMatrix(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  } nextDoubleMatrix {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  } double[][] matrix = new double[n][m]; matrix new double[n][m] n m for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    } {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    } for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      } int j = 0; int j = 0; j 0 j < m j m j++ j++ j {
        matrix[i][j] = nextDouble();
      } {
        matrix[i][j] = nextDouble();
      } matrix[i][j] = nextDouble() matrix[i][j] matrix[i] matrix i j nextDouble() nextDouble return matrix; matrix int n n int m m class ModCalculator {
  private final long mod;
  private final ModCombinationCache modCombinationCache;
  
  ModCalculator(long mod) {
    this.mod = mod;
    this.modCombinationCache = new ModCombinationCache();
  }
  
  public long add(long a, long b) {
    return (a + b) % mod;
  }
  
  public long sub(long a, long b) {
    return (a - b + mod) % mod;
  }
  
  public long mul(long a, long b) {
    return (a * b) % mod;
  }
  
  public long pow(long a, long b) {
    if (b == 0) {
      return 1;
    }
    long v = pow(mul(a, a), b / 2);
    if (b % 2 == 1) {
      return mul(v, a);
    } else {
      return v;
    }
  }
  
  public long inverse(long a) {
    return pow(a, mod - 2);
  }
  
  public long div(long a, long b) {
    return mul(a, inverse(b));
  }
  
  public long getF(int n) {
    return modCombinationCache.getF(n);
  }
  
  public long getP(int n, int r) {
    return modCombinationCache.getP(n, r);
  }
  
  public long getC(int n, int k) {
    return modCombinationCache.getC(n, k);
  }
  
  class ModCombinationCache {
    private final List<Long> factorialCache;
    private final List<Long> factorialInverseCache;
    
    public ModCombinationCache() {
      factorialCache = new ArrayList<>();
      factorialCache.add(1L);
      factorialInverseCache = new ArrayList<>();
      factorialInverseCache.add(1L);
    }
    
    private void resize(int n) {
      for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      }
    }
    
    long getF(int n) {
      resize(n);
      return factorialCache.get(n);
    }
    
    long getP(int n, int r) {
      resize(n);
      return mul(factorialCache.get(n), factorialInverseCache.get(n - r));
    }
    
    long getC(int n, int k) {
      resize(n);
      return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)));
    }
  }
} ModCalculator private final long mod; mod private final ModCombinationCache modCombinationCache; modCombinationCache ModCalculator(long mod) {
    this.mod = mod;
    this.modCombinationCache = new ModCombinationCache();
  } ModCalculator {
    this.mod = mod;
    this.modCombinationCache = new ModCombinationCache();
  } this.mod = mod this.mod this this.mod mod this.modCombinationCache = new ModCombinationCache() this.modCombinationCache this this.modCombinationCache new ModCombinationCache() long mod mod public long add(long a, long b) {
    return (a + b) % mod;
  } add {
    return (a + b) % mod;
  } return (a + b) % mod; (a + b) % mod (a + b) a b mod long a a long b b public long sub(long a, long b) {
    return (a - b + mod) % mod;
  } sub {
    return (a - b + mod) % mod;
  } return (a - b + mod) % mod; (a - b + mod) % mod (a - b + mod) a - b a b mod mod long a a long b b public long mul(long a, long b) {
    return (a * b) % mod;
  } mul {
    return (a * b) % mod;
  } return (a * b) % mod; (a * b) % mod (a * b) a b mod long a a long b b public long pow(long a, long b) {
    if (b == 0) {
      return 1;
    }
    long v = pow(mul(a, a), b / 2);
    if (b % 2 == 1) {
      return mul(v, a);
    } else {
      return v;
    }
  } pow {
    if (b == 0) {
      return 1;
    }
    long v = pow(mul(a, a), b / 2);
    if (b % 2 == 1) {
      return mul(v, a);
    } else {
      return v;
    }
  } if (b == 0) {
      return 1;
    } b == 0 b 0 {
      return 1;
    } return 1; 1 long v = pow(mul(a, a), b / 2); v pow(mul(a, a), b / 2) pow mul(a, a) mul a a b / 2 b 2 if (b % 2 == 1) {
      return mul(v, a);
    } else {
      return v;
    } b % 2 == 1 b % 2 b 2 1 {
      return mul(v, a);
    } return mul(v, a); mul(v, a) mul v a {
      return v;
    } return v; v long a a long b b public long inverse(long a) {
    return pow(a, mod - 2);
  } inverse {
    return pow(a, mod - 2);
  } return pow(a, mod - 2); pow(a, mod - 2) pow a mod - 2 mod 2 long a a public long div(long a, long b) {
    return mul(a, inverse(b));
  } div {
    return mul(a, inverse(b));
  } return mul(a, inverse(b)); mul(a, inverse(b)) mul a inverse(b) inverse b long a a long b b public long getF(int n) {
    return modCombinationCache.getF(n);
  } getF {
    return modCombinationCache.getF(n);
  } return modCombinationCache.getF(n); modCombinationCache.getF(n) modCombinationCache.getF modCombinationCache n int n n public long getP(int n, int r) {
    return modCombinationCache.getP(n, r);
  } getP {
    return modCombinationCache.getP(n, r);
  } return modCombinationCache.getP(n, r); modCombinationCache.getP(n, r) modCombinationCache.getP modCombinationCache n r int n n int r r public long getC(int n, int k) {
    return modCombinationCache.getC(n, k);
  } getC {
    return modCombinationCache.getC(n, k);
  } return modCombinationCache.getC(n, k); modCombinationCache.getC(n, k) modCombinationCache.getC modCombinationCache n k int n n int k k class ModCombinationCache {
    private final List<Long> factorialCache;
    private final List<Long> factorialInverseCache;
    
    public ModCombinationCache() {
      factorialCache = new ArrayList<>();
      factorialCache.add(1L);
      factorialInverseCache = new ArrayList<>();
      factorialInverseCache.add(1L);
    }
    
    private void resize(int n) {
      for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      }
    }
    
    long getF(int n) {
      resize(n);
      return factorialCache.get(n);
    }
    
    long getP(int n, int r) {
      resize(n);
      return mul(factorialCache.get(n), factorialInverseCache.get(n - r));
    }
    
    long getC(int n, int k) {
      resize(n);
      return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)));
    }
  } ModCombinationCache private final List<Long> factorialCache; factorialCache private final List<Long> factorialInverseCache; factorialInverseCache public ModCombinationCache() {
      factorialCache = new ArrayList<>();
      factorialCache.add(1L);
      factorialInverseCache = new ArrayList<>();
      factorialInverseCache.add(1L);
    } ModCombinationCache {
      factorialCache = new ArrayList<>();
      factorialCache.add(1L);
      factorialInverseCache = new ArrayList<>();
      factorialInverseCache.add(1L);
    } factorialCache = new ArrayList<>() factorialCache new ArrayList<>() factorialCache.add(1L) factorialCache.add factorialCache 1L factorialInverseCache = new ArrayList<>() factorialInverseCache new ArrayList<>() factorialInverseCache.add(1L) factorialInverseCache.add factorialInverseCache 1L private void resize(int n) {
      for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      }
    } resize {
      for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      }
    } for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      } int i = factorialCache.size() - 1; int i = factorialCache.size() - 1; i factorialCache.size() - 1 factorialCache.size() factorialCache.size factorialCache 1 i < n i n i++ i++ i {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      } {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      } long v = mul(factorialCache.get(i), i + 1); v mul(factorialCache.get(i), i + 1) mul factorialCache.get(i) factorialCache.get factorialCache i i + 1 i 1 factorialCache.add(v) factorialCache.add factorialCache v factorialInverseCache.add(inverse(v)) factorialInverseCache.add factorialInverseCache inverse(v) inverse v int n n long getF(int n) {
      resize(n);
      return factorialCache.get(n);
    } getF {
      resize(n);
      return factorialCache.get(n);
    } resize(n) resize n return factorialCache.get(n); factorialCache.get(n) factorialCache.get factorialCache n int n n long getP(int n, int r) {
      resize(n);
      return mul(factorialCache.get(n), factorialInverseCache.get(n - r));
    } getP {
      resize(n);
      return mul(factorialCache.get(n), factorialInverseCache.get(n - r));
    } resize(n) resize n return mul(factorialCache.get(n), factorialInverseCache.get(n - r)); mul(factorialCache.get(n), factorialInverseCache.get(n - r)) mul factorialCache.get(n) factorialCache.get factorialCache n factorialInverseCache.get(n - r) factorialInverseCache.get factorialInverseCache n - r n r int n n int r r long getC(int n, int k) {
      resize(n);
      return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)));
    } getC {
      resize(n);
      return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)));
    } resize(n) resize n return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k))); mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k))) mul factorialCache.get(n) factorialCache.get factorialCache n mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)) mul factorialInverseCache.get(k) factorialInverseCache.get factorialInverseCache k factorialInverseCache.get(n-k) factorialInverseCache.get factorialInverseCache n-k n k int n n int k k class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
  
  public static void shuffle(int[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  }
  
  public static void shuffle(long[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  }
  
  public static void sort(int[] array) {
    shuffle(array);
    Arrays.sort(array);
  }
  
  public static void sort(long[] array) {
    shuffle(array);
    Arrays.sort(array);
  }
} Algorithm private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  } swap {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  } Object tmp = list[a]; tmp list[a] list a list[a] = list[b] list[a] list a list[b] list b list[b] = tmp list[b] list b tmp Object[] list list int a a int b b public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  } nextPermutation {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  } int rightMostAscendingOrderIndex = ts.length - 2; rightMostAscendingOrderIndex ts.length - 2 ts.length ts ts.length 2 while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    } rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0 rightMostAscendingOrderIndex >= 0 rightMostAscendingOrderIndex 0 ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0 ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) ts[rightMostAscendingOrderIndex].compareTo ts[rightMostAscendingOrderIndex] ts rightMostAscendingOrderIndex ts[rightMostAscendingOrderIndex + 1] ts rightMostAscendingOrderIndex + 1 rightMostAscendingOrderIndex 1 0 {
      rightMostAscendingOrderIndex--;
    } rightMostAscendingOrderIndex-- rightMostAscendingOrderIndex if (rightMostAscendingOrderIndex < 0) {
      return false;
    } rightMostAscendingOrderIndex < 0 rightMostAscendingOrderIndex 0 {
      return false;
    } return false; false int rightMostGreatorIndex = ts.length - 1; rightMostGreatorIndex ts.length - 1 ts.length ts ts.length 1 while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    } ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0 ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) ts[rightMostAscendingOrderIndex].compareTo ts[rightMostAscendingOrderIndex] ts rightMostAscendingOrderIndex ts[rightMostGreatorIndex] ts rightMostGreatorIndex 0 {
      rightMostGreatorIndex--;
    } rightMostGreatorIndex-- rightMostGreatorIndex swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex) swap ts rightMostAscendingOrderIndex rightMostGreatorIndex for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    } int i = 0; int i = 0; i 0 i < (ts.length - rightMostAscendingOrderIndex - 1) / 2 i (ts.length - rightMostAscendingOrderIndex - 1) / 2 (ts.length - rightMostAscendingOrderIndex - 1) ts.length - rightMostAscendingOrderIndex - 1 ts.length ts ts.length rightMostAscendingOrderIndex 1 2 i++ i++ i {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    } {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    } swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i) swap ts rightMostAscendingOrderIndex + 1 + i rightMostAscendingOrderIndex + 1 + i rightMostAscendingOrderIndex 1 i ts.length - 1 - i ts.length - 1 - i ts.length ts ts.length 1 i return true; true T[] ts ts public static void shuffle(int[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  } shuffle {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  } Random random = new Random(); random new Random() int n = array.length; n array.length array array.length for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    } {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    } int randomIndex = i + random.nextInt(n - i); randomIndex i + random.nextInt(n - i) i random.nextInt(n - i) random.nextInt random n - i n i int temp = array[i]; temp array[i] array i array[i] = array[randomIndex] array[i] array i array[randomIndex] array randomIndex array[randomIndex] = temp array[randomIndex] array randomIndex temp int[] array array public static void shuffle(long[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  } shuffle {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  } Random random = new Random(); random new Random() int n = array.length; n array.length array array.length for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    } {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    } int randomIndex = i + random.nextInt(n - i); randomIndex i + random.nextInt(n - i) i random.nextInt(n - i) random.nextInt random n - i n i long temp = array[i]; temp array[i] array i array[i] = array[randomIndex] array[i] array i array[randomIndex] array randomIndex array[randomIndex] = temp array[randomIndex] array randomIndex temp long[] array array public static void sort(int[] array) {
    shuffle(array);
    Arrays.sort(array);
  } sort {
    shuffle(array);
    Arrays.sort(array);
  } shuffle(array) shuffle array Arrays.sort(array) Arrays.sort Arrays array int[] array array public static void sort(long[] array) {
    shuffle(array);
    Arrays.sort(array);
  } sort {
    shuffle(array);
    Arrays.sort(array);
  } shuffle(array) shuffle array Arrays.sort(array) Arrays.sort Arrays array long[] array array class UnionFind {
  int[] parents;
  int[] ranks;

  UnionFind(int n) {
    parents = new int[n];
    ranks = new int[n];

    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  }

  public int getRoot(int index) {
    if (parents[index] == index) {
      return index;
    } else {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    }
  }

  public boolean sameGroup(int a, int b) {
    return getRoot(a) == getRoot(b);
  }

  public void merge(int a, int b) {
    int rootA = getRoot(a);
    int rootB = getRoot(b);
    if (rootA == rootB) {
      return;
    }
    if (ranks[rootA] < ranks[rootB]) {
      parents[rootA] = rootB;
    } else if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    }
  }
} UnionFind int[] parents; parents int[] ranks; ranks UnionFind(int n) {
    parents = new int[n];
    ranks = new int[n];

    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  } UnionFind {
    parents = new int[n];
    ranks = new int[n];

    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  } parents = new int[n] parents new int[n] n ranks = new int[n] ranks new int[n] n for (int i = 0; i < n; i++) {
      parents[i] = i;
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      parents[i] = i;
    } {
      parents[i] = i;
    } parents[i] = i parents[i] parents i i int n n public int getRoot(int index) {
    if (parents[index] == index) {
      return index;
    } else {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    }
  } getRoot {
    if (parents[index] == index) {
      return index;
    } else {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    }
  } if (parents[index] == index) {
      return index;
    } else {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    } parents[index] == index parents[index] parents index index {
      return index;
    } return index; index {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    } parents[index] = getRoot(parents[index]) parents[index] parents index getRoot(parents[index]) getRoot parents[index] parents index return parents[index]; parents[index] parents index int index index public boolean sameGroup(int a, int b) {
    return getRoot(a) == getRoot(b);
  } sameGroup {
    return getRoot(a) == getRoot(b);
  } return getRoot(a) == getRoot(b); getRoot(a) == getRoot(b) getRoot(a) getRoot a getRoot(b) getRoot b int a a int b b public void merge(int a, int b) {
    int rootA = getRoot(a);
    int rootB = getRoot(b);
    if (rootA == rootB) {
      return;
    }
    if (ranks[rootA] < ranks[rootB]) {
      parents[rootA] = rootB;
    } else if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    }
  } merge {
    int rootA = getRoot(a);
    int rootB = getRoot(b);
    if (rootA == rootB) {
      return;
    }
    if (ranks[rootA] < ranks[rootB]) {
      parents[rootA] = rootB;
    } else if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    }
  } int rootA = getRoot(a); rootA getRoot(a) getRoot a int rootB = getRoot(b); rootB getRoot(b) getRoot b if (rootA == rootB) {
      return;
    } rootA == rootB rootA rootB {
      return;
    } return; if (ranks[rootA] < ranks[rootB]) {
      parents[rootA] = rootB;
    } else if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    } ranks[rootA] < ranks[rootB] ranks[rootA] ranks rootA ranks[rootB] ranks rootB {
      parents[rootA] = rootB;
    } parents[rootA] = rootB parents[rootA] parents rootA rootB if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    } ranks[rootB] < ranks[rootA] ranks[rootB] ranks rootB ranks[rootA] ranks rootA {
      parents[rootB] = rootA;
    } parents[rootB] = rootA parents[rootB] parents rootB rootA {
      parents[rootA] = rootB;
      ranks[rootB]++;
    } parents[rootA] = rootB parents[rootA] parents rootA rootB ranks[rootB]++ ranks[rootB] ranks rootB int a a int b b public class Main {
  private static String solve(int n, int[] as) {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
} public class Main {
  private static String solve(int n, int[] as) {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
} Main
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, int[] as) {
    boolean[] existGroups = new boolean[8];
    int countTop = 0;
    for (int a : as) {
      if (a < 3200) {
        existGroups[a / 400] = true;
      } else {
        countTop++;
      }
    }
    int countGroup = 0;
    for (boolean b : existGroups) {
      if (b) {
        countGroup++;
      }
    }
    int min;
    int max;
    if (countGroup > 0) {
      min = countGroup;
      max = countGroup + countTop;
    } else {
      min = 1;
      max = countTop;
    }
    return String.format("%d %d", min, max);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextIntArray(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] nextArray(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDoubleArray(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public int[][] nextIntMatrix(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLongMatrix(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDoubleMatrix(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
}

class ModCalculator {
  private final long mod;
  private final ModCombinationCache modCombinationCache;
  
  ModCalculator(long mod) {
    this.mod = mod;
    this.modCombinationCache = new ModCombinationCache();
  }
  
  public long add(long a, long b) {
    return (a + b) % mod;
  }
  
  public long sub(long a, long b) {
    return (a - b + mod) % mod;
  }
  
  public long mul(long a, long b) {
    return (a * b) % mod;
  }
  
  public long pow(long a, long b) {
    if (b == 0) {
      return 1;
    }
    long v = pow(mul(a, a), b / 2);
    if (b % 2 == 1) {
      return mul(v, a);
    } else {
      return v;
    }
  }
  
  public long inverse(long a) {
    return pow(a, mod - 2);
  }
  
  public long div(long a, long b) {
    return mul(a, inverse(b));
  }
  
  public long getF(int n) {
    return modCombinationCache.getF(n);
  }
  
  public long getP(int n, int r) {
    return modCombinationCache.getP(n, r);
  }
  
  public long getC(int n, int k) {
    return modCombinationCache.getC(n, k);
  }
  
  class ModCombinationCache {
    private final List<Long> factorialCache;
    private final List<Long> factorialInverseCache;
    
    public ModCombinationCache() {
      factorialCache = new ArrayList<>();
      factorialCache.add(1L);
      factorialInverseCache = new ArrayList<>();
      factorialInverseCache.add(1L);
    }
    
    private void resize(int n) {
      for (int i = factorialCache.size() - 1; i < n; i++) {
        long v = mul(factorialCache.get(i), i + 1);
        factorialCache.add(v);
        factorialInverseCache.add(inverse(v));
      }
    }
    
    long getF(int n) {
      resize(n);
      return factorialCache.get(n);
    }
    
    long getP(int n, int r) {
      resize(n);
      return mul(factorialCache.get(n), factorialInverseCache.get(n - r));
    }
    
    long getC(int n, int k) {
      resize(n);
      return mul(factorialCache.get(n), mul(factorialInverseCache.get(k), factorialInverseCache.get(n-k)));
    }
  }
}
 
class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
  
  public static void shuffle(int[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      int temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  }
  
  public static void shuffle(long[] array) {
    Random random = new Random();
    int n = array.length;
    for (int i = 0; i < n; i++) {
      int randomIndex = i + random.nextInt(n - i);
      
      long temp = array[i];
      array[i] = array[randomIndex];
      array[randomIndex] = temp;
    }
  }
  
  public static void sort(int[] array) {
    shuffle(array);
    Arrays.sort(array);
  }
  
  public static void sort(long[] array) {
    shuffle(array);
    Arrays.sort(array);
  }
}

class UnionFind {
  int[] parents;
  int[] ranks;

  UnionFind(int n) {
    parents = new int[n];
    ranks = new int[n];

    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  }

  public int getRoot(int index) {
    if (parents[index] == index) {
      return index;
    } else {
      parents[index] = getRoot(parents[index]);
      return parents[index];
    }
  }

  public boolean sameGroup(int a, int b) {
    return getRoot(a) == getRoot(b);
  }

  public void merge(int a, int b) {
    int rootA = getRoot(a);
    int rootB = getRoot(b);
    if (rootA == rootB) {
      return;
    }
    if (ranks[rootA] < ranks[rootB]) {
      parents[rootA] = rootB;
    } else if (ranks[rootB] < ranks[rootA]) {
      parents[rootB] = rootA;
    } else {
      parents[rootA] = rootB;
      ranks[rootB]++;
    }
  }
}
