public void solve() throws IOException {
    int n = nextInt();
    long min = Integer.MAX_VALUE;
    long mincount = 0;
    long max = Integer.MIN_VALUE;
    long maxcount = 0;
    for (int x = 0; x < n; x++) {
      int num = nextInt();

      if (num == min) {
        mincount++;
      } else if (num < min) {
        min = num;
        mincount = 1;
      }

      if (num == max) {
        maxcount++;
      } else if (num > max) {
        max = num;
        maxcount = 1;
      }
    }

    if (min == max) {
      System.out.println("0 " + (mincount * (maxcount - 1) / 2));
    } else {
      System.out.println((max - min) + " " + (mincount * maxcount));
    }

  }