Pashmak decided to give Parmida a pair of flowers from the garden. There are nflowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference is maximal possible!

Your task is to write a program which calculates two things:

  1. The maximum beauty difference of flowers that Pashmak can give to Parmida.
  2. The number of ways that Pashmak can pick the flowers. Two ways are considered different if and only if there is at least one flower that is chosen in the first way and not chosen in the second way.

Input

The first line of the input contains n (2 ≤ n ≤ 2·105). In the next line there are n space-separated integers b1b2, ..., bn (1 ≤ bi ≤ 109).

Output

The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively.

Example

Input

Output
 
Input

Output
 
Input

Output
 

Note

In the third sample the maximum beauty difference is 2 and there are 4 ways to do this:

  1. choosing the first and the second flowers;
  2. choosing the first and the fifth flowers;
  3. choosing the fourth and the second flowers;
  4. choosing the fourth and the fifth flowers.

my code is folowing.

#include <iostream>
using namespace std;
int main()
{
    long long n;
    while( cin >> n )
    {
        int i;
        long long *b=new long long[n];
        for(i=0;i<n;i++)
            cin>>b[i];

        long long maxn=b[0],minn=b[0],m=0,k=0;
        for(i=0;i<n;i++)
        {
            if(b[i]>maxn)
                maxn=b[i];
        }
        for(i=0;i<n;i++)
        {
            if(b[i]<minn)
                minn=b[i];
        }
        for(i=0;i<n;i++)
        {
            if(b[i]==maxn)
                m=m+1;
            if(b[i]==minn)
                k=k+1;
        }
       cout<<(maxn-minn)<<" "<<(maxn==minn)?(n*(n-1)/2):(m*k);
    }

    return 0;
}

  

Pashmak and Flowers的更多相关文章

  1. CF459B Pashmak and Flowers (水

    Pashmak and Flowers Codeforces Round #261 (Div. 2) B. Pashmak and Flowers time limit per test 1 seco ...

  2. cf459B Pashmak and Flowers

    B. Pashmak and Flowers time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. Codeforces Round #261 (Div. 2) B. Pashmak and Flowers 水题

    题目链接:http://codeforces.com/problemset/problem/459/B 题意: 给出n支花,每支花都有一个漂亮值.挑选最大和最小漂亮值得两支花,问他们的差值为多少,并且 ...

  4. codeforces 459 B.Pashmak and Flowers 解题报告

    题目链接:http://codeforces.com/problemset/problem/459/B 题目意思:有 n 朵 flowers,每朵flower有相应的 beauty,求出最大的beau ...

  5. New Training Table

          2014_8_15 CodeForces 261 DIV2 A. Pashmak and Garden 简单题   B. Pashmak and Flowers    简单题   C. P ...

  6. Codeforces Round #261 (Div. 2) B

    链接:http://codeforces.com/contest/459/problem/B B. Pashmak and Flowers time limit per test 1 second m ...

  7. CF 459A && 459B && 459C && 459D && 459E

    http://codeforces.com/contest/459 A题 Pashmak and Garden 化简化简水题,都告诉平行坐标轴了,数据还出了对角线,后面两个点坐标给的范围也不错 #in ...

  8. Codeforces Round #261 (Div. 2)[ABCDE]

    Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden ...

  9. [codeforces] 暑期训练之打卡题(二)

    每个标题都做了题目原网址的超链接 Day11<Given Length and Sum of Digits...> 题意: 给定一个数 m 和 一个长度 s,计算最大和最小在 s 长度下, ...

随机推荐

  1. Activity切换动画---点击哪里从哪放大

    emmmm,这次来梳理一下 Activity 切换动画的研究.首先,老规矩,看一下效果图: 效果图 这次要实现的动画效果就是类似于上图那样,点击某个 view,就从那个 view 展开下个 Activ ...

  2. GacUtil

    编辑本段工具简介 全局程序集缓存工具 (Gacutil.exe) 管理程序集缓存的 .NET 实用工具库还提供一种命令行接口工具,名为全局程序集缓存实用工具 (Gacutil.exe). 编辑本段命令 ...

  3. Windows系统重装

    http://www.ishuo.cn/show/76437.htmlhttp://jingyan.baidu.com/article/d8072ac45d4f60ec95cefdaa.html

  4. xampp 出现403 无法访问问题(已解决)

    最近重新安装xampp,配置虚拟主机做本地测试,但是总是出现服务器无法访问,权限不够的提示. 查找error文件后排查错误,发现是权限的问题.具体错误如下: 重新查看配置文件httpd.conf,才发 ...

  5. form表单数据封装成json格式并提交给服务器

    1.jsp代码,form表单: <form action="#" id="costForm"> <input type="hidde ...

  6. 5、C#基础 - C#的值类型

    1.C#的值类型 有几个特点: 存储在栈里 基于值类型的变量直接包含值(值类型存储实际值). 将一个值类型变量赋给另一个值类型变量时,将复制包含的值. 这与引用类型变量的赋值不同,引用类型变量的赋值只 ...

  7. Vuex 源码学习(一)

    (一)Vuex 是什么? Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态, 并以相应的规则保证状态以一种可预测的方式发生变化. —— 来自 V ...

  8. Java调用PDFBox打印自定义纸张PDF

    打印对象 一份设置为A3纸张, 页面边距为(10, 10, 10, 10)mm的PDF文件. PageFormat 默认PDFPrintable无法设置页面大小. PDFPrintable print ...

  9. 使用hiredis实现pipeline方式访问

    1.介绍 hiredis: 一个c/c++的访问redis的api库 地址:https://github.com/redis/hiredis pipeline方式: redis中的pipeline方式 ...

  10. Java-----关于eclipse导入项目发生的问题及解决办法

    今天通过eclipse导入了几个项目,项目名出现红叉,对于我这样的强迫症来说是无法容忍的,故现做总结,遇到同学可按照以下方法来操作. 改动的地方主要是两个方面: 1.Tomcat版本问题. 此问题是由 ...