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. webpack之前端性能优化(史上最全,不断更新中。。。)

    最近在用webpack优化首屏加载性能,通过几种插件之后我们上线前后的速度快了一倍,在此就简单的分享下吧,先上个优化前后首屏渲染的对比图. 可以看到总下载时间从3800ms缩短到1600ms. 我们在 ...

  2. [flask实践] 解决qq邮箱/mysql的相关配置问题

    笔者经过flask web(Miguel著,封面是一条狗)一书的学习,打算实现一个旅游类网站,在此过程中发现,相对于书中的flasky博客程序,需要作出一些改变: 1. 注册邮箱:国内要使用126,q ...

  3. Python入门 - 函数方法

    本节主讲python函数的基本用法,主要包括传递参数.匿名函数和变量作用域. 一.传递参数 python除了传递必需参数外,还可以传递默认参数,不定长参数和关键字参数. 1. 传递必需参数 def m ...

  4. Android开发之漫漫长途 番外篇——自定义View的各种姿势2

    该文章是一个系列文章,是本人在Android开发的漫漫长途上的一点感想和记录,我会尽量按照先易后难的顺序进行编写该系列.该系列引用了<Android开发艺术探索>以及<深入理解And ...

  5. 微信JS-SDK选择相册或拍照并上传PHP实现

    理解:微信上传接口是拍照,或者选择本地照片,上传到微信的服务器,获取到一个id,通过token与这个id获取到图片,保存到服务器即可. 效果 通过微信js接口,调用底层程序. 需要引入js文件,并进行 ...

  6. 数据库索引------Btree索引的使用限制

    1.如果不是按照索引最左列开始查找,则无法使用索引. 比如说id+name   那么是name+id 的话  ,这个索引则无法使用. 2.使用索引时不能跳过索引中的列.   如果是id+name+ag ...

  7. Jsoup(一)Jsoup详解(官方)

    一.Jsoup概述 1.1.简介     jsoup 是一款Java 的HTML解析器,可直接解析某个URL地址.HTML文本内容.它提供了一套非常省力的API, 可通过DOM,CSS以及类似于jQu ...

  8. 深入浅出了解OCR识别票据原理

    欢迎大家前往云加社区,获取更多腾讯海量技术实践干货哦~ 译者:Mr.Geek 本文翻译自dzone 中Ivan Ozhiganov所发文章Deep Dive Into OCR for Receipt ...

  9. Property list types and their various representations

    iOS下Property list能够存储的数据类型  Property list types and their various representations  Abstract type XML ...

  10. 改动hosts权限

    在屏蔽网页.訪问一些特定局域网的时候,都可能须要改动Hosts文件. 只是在改动Hosts文件后.会遇到无法保存的情况,提示"您没有权限在此位置中保存文件,请与管理员联系以获取对应权限&qu ...