import java.util.Scanner;
public class B {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int oldX, oldY, newX = 0, newY = 0;
        int n = in.nextInt();
        int k = in.nextInt();
        double distance = 0;
        for (int i = 0; i < n; i++) {
            oldX = newX;
            oldY = newY;
            newX = in.nextInt();
            newY = in.nextInt();
            if (i == 0) {
                continue;
            }
            distance += Math.sqrt(Math.abs((newX - oldX) * (newX - oldX) + (newY - oldY) * (newY - oldY)));
        }

        System.out.println(distance * k / 50);
    }
}


import java.text.DecimalFormat;
import java.util.Scanner;

public class CodeForce127AWastedTime {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s = new Scanner(System.in);
        int points,times;
        points=s.nextInt();
        times=s.nextInt();
        int[][] p = new int[points][2];
        for (int i = 0; i <points; i++) {
            p[i][0]=s.nextInt();
            p[i][1]=s.nextInt();

        }
        double dis = 0;

        for (int j = 1; j < points; j++) {

            dis = dis+Math.sqrt(Math.pow(p[j][0]-p[j-1][0],2)+Math.pow(p[j][1]-p[j-1][1],2));
        }
        dis = dis*times/50.0;
        DecimalFormat df = new DecimalFormat("0.000000000");
        System.out.println(df.format(dis));
    }
}


import java.io.IOException;
import java.util.Scanner;

public class Main {
    static int a[] = new int[128];
    public static void main(String[] args) throws IOException{
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        for (int i = 0;i < 128;i++)
                a[i] = 0;
        for (int i = 0;i < n;i++)
            ++a[cin.nextInt()];
        int Res = 0;
        for (int i = 0;i < 128;i++)
            Res += a[i] / 2;
        System.out.println(Res / 2);
    }
}


#include<stdio.h>
sai(const void*a,const void*b)
{
	return (*(int*)a-*(int*)b);
}
int main( )
{
	long long int n;
	scanf("%lld",&n);
	long long int a[200001],i,d=0,m=1,z=0,c=1;
	for(i=0;i<n;i++)
	{
		a[i]=0;
	}
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	qsort(a,n,sizeof (long long int),sai);
	d=(a[n-1]-a[0]);
	for(i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			c+=1;
		}
		else
		{
			break;
		}
	}
	for(i=n-1;i>0;i--)
	{
		if(a[i]==a[i-1])
		{
			m+=1;
		}
		else
		{
			break;
		}
	}
	z=(c*m);
	printf("%lld %lld\n",d,z);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int sai(const void* a,const void* b)
{
	return *(long long int*)a-*(long long int*)b;
}
int main( )
{
	long long int n,i,j=0,k=0,a=0,b=0,c[200001]={0},l=1,y=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&c[i]);
	}
	qsort(c,n,sizeof(long long int),sai);
	/*	for(i=0;i<n;i++)
		{
		printf("%lld ",c[i]);
		}
		printf("\n");*/
	j=c[n-1];
	k=c[0];
	for(i=0;i<n-1;i++)
	{
		if(c[i]==c[i+1])
		{
			a+=1;
		}
		else
		{
			break;
		}
	}
	if(a!=n-1)
	{
		for(i=n-1;i>0;i++)
		{
			if(c[i]==c[i-1])
			{
				b+=1;
			}
			else
			{
				break;
			}
		}
	}
	if(c[0]!=c[n-1])
	{
		printf("%lld %lld\n",j-k,((a+1)*(b+1)));
	}
	else
	{
		printf("%lld %lld\n",y,l);
	}
	return 0;
}


#include <stdio.h>
int main() {
	int n, i, a[200010], min = 1000000005, max = -1, diff = 0;
	long long int maxcount = 0, mincount = 0;
	scanf("%d",&n);
	for( i = 0; i < n; i++ ) {
		scanf("%d",&a[i]);
		if( min > a[i] ) {
			min = a[i];
		}
		if( max < a[i] ) {
			max = a[i];
		}
		if(diff < (max - min) ) {
			diff = max - min;
		}
	}
	for( i = 0; i < n; i++ ) {
		if( max == min && max == a[i]) {
			++mincount;
			++maxcount;
		} else {
			if( max == a[i] ) {
				maxcount++;
			} else if (min == a[i]){
				mincount++;
			}
		}
	}
	//printf("%lld %lld",maxcount,mincount);
	if( max == min ) {
		printf("%d %I64d\n",diff,maxcount * (maxcount - 1)/2);
	} else {
		printf("%d %I64d\n",diff,maxcount * mincount);
	}
	return 0;
}


#include <stdio.h>
int main()
{
    long int n,a[200000],i,max=0,min=1000000000,b=0,c=0;
    scanf("%ld",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==max)
            b++;
        if(a[i]==min)
            c++;
    }
    printf("%ld ",max-min);
    printf("%ld",b*c);
    return 0;
}


#include <stdio.h>
int main()
{
    long int n,a[200000],i,max=0,min=1000000000,b=0,c=0;
    scanf("%ld",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==max)
            b++;
        if(a[i]==min)
            c++;
    }
    printf("%ld ",max-min);
    printf("%lld",b*c);
    return 0;
}


#include <stdio.h>
int main()
{
    long int n,a[200005],i,max=0,min=1000000000,b=0,c=0;
    long long int d;
    scanf("%ld",&n);
    for(i=0;i<n;i++)
        scanf("%ld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==max)
            b++;
        if(a[i]==min)
            c++;
    }
    d=b*c;
    printf("%ld ",max-min);
    printf("%lld",d);
    return 0;
}


#include <stdio.h>
int main()
{
    long long int n,a[200005],i,max=0,min=1000000001,b=0,c=0,d;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==max)
            b++;
        if(a[i]==min)
            c++;
    }
    d=b*c;
    if(max==min)
        printf("%lld 0",max-min);
    else
        printf("%lld %lld",max-min,d);
    return 0;
}


#include <stdio.h>
int main()
{
    long long int n,a[200005],i,max=0,min=1000000001,b=0,c=0,d;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==max)
            b++;
        if(a[i]==min)
            c++;
    }
    d=b*c;
    if(max==min)
        printf("%lld 0",(b*(b-1)/2));
    else
        printf("%lld %lld",max-min,d);
    return 0;
}


#include <stdio.h>
int main()
{
    long long int n,a[200005],i,max=0,min=1000000001,b=0,c=0,d;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]==max)
            b++;
        if(a[i]==min)
            c++;
    }
    d=b*c;
    if(max==min)
        printf("0 %lld",(n*(n-1)/2));
    else
        printf("%lld %lld",max-min,d);
    return 0;
}


//
//  main.c
//  codeforces_problemset
//
//  Created by Ashish on 10/10/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    int n;
    int i;
    int array[200000]={0};
    scanf("%d\n");
    for(i=0;i<n;i++){
        scanf("%d",&array[i]);
    }
    int j;
    int max=0;
    int min=array[0];
    for(j=0;j<n;j++){

        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }

    }
    int count1=0;
    int count2=0;
    for(j=0;j<n;j++){
        if(array[j]==max){
            count1++;
        }
        if(array[j]==min){
            count2++;
        }
    }
    printf("%d %d",max-min,count1+count2);
        return 0;
}


//
//  main.c
//  codeforces2
//
//  Created by Ashish on 10/1/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>

int main()
{
    int count=0;
    int min;
    int max;
    int a;
    int array[200000]={0};
    int i;
    scanf("%d\n",&a);
    for(i=0;i<a;i++){
        scanf("%d",&array[i]);
    }
    int j;
    array[0]=max;
    array[0]=min;
    for(j=0;j<a-1;j++){
        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }
        if(array[j]==max){
            count++;
        }
    }
    int diff;
    diff=max-min;
    printf("%d %d ",diff,count);

    return 0;
}


#include<stdio.h>
long long int n,i,j,s,a[300001],max,min;
int main()
{
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",a+i);
		if(a[i]>max)
			max=a[i];
		if(!i || a[i]<min)
			min=a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==max)
			s++;
		if(a[i]==min)
			j++;
	}
	long long int t=s*j;
	if(max==min)
		t=s*(s-1)/2;

	printf("%lld %lld",max-min,t);
	return 0;
}


//
//  main.c
//  codeforces2
//
//  Created by Ashish on 10/1/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>

int main()
{
    int count=0;
    int min;
    int max;
    int a;
    int array[200000]={0};
    int i;
    scanf("%d\n",&a);
    for(i=0;i<a;i++){
        scanf("%d",&array[i]);
    }
    int j;
    array[0]=max;
    array[0]=min;
    for(j=0;j<a;j++){
        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }
        if(array[j]==max){
            count++;
        }
    }
    int diff;
    diff=max-min;
    printf("%d %d ",diff,count);

    return 0;
}


//
//  main.c
//  codeforces_problemset
//
//  Created by Ashish on 10/10/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    int n;
    int i;
    int array[200000]={0};
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&array[i]);
    }
    int j;
    int max=0;
    int min=array[0];
    for(j=0;j<n;j++){

        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }

    }
    int count1=0;
    int count2=0;
    for(j=0;j<n;j++){
        if(array[j]==max){
            count1++;
        }
        if(array[j]==min){
            count2++;
        }
    }
    int min1=count1;
    if(count1>count2){
        min1=count2;
    }
    printf("%d %d",max-min,min1);
        return 0;
}


//
//  main.c
//  codeforces_problemset
//
//  Created by Ashish on 10/10/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    int n;
    int i;
    int array[200000]={0};
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&array[i]);
    }
    int j;
    int max=0;
    int min=array[0];
    for(j=0;j<n;j++){

        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }

    }
    int count1=0;
    int count2=0;
    for(j=0;j<n;j++){
        if(array[j]==max){
            count1++;
        }
        if(array[j]==min){
            count2++;
        }
    }
    printf("%d %d",max-min,count1*count2);
        return 0;
}


//
//  main.c
//  codeforces2
//
//  Created by Ashish on 10/1/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>

int main()
{
    int max=0;
    int diff;
    int count=0;
    int a;
    int array[200000]={0};
    int i;
    scanf("%d\n",&a);
    for(i=0;i<a;i++){
        scanf("%d",&array[i]);
    }
    int j;
    for(j=0;j<a;j++){
        if(array[j-1]>array[j]&&j!=-1){
            int hold;
            hold=array[j-1];
            array[j]=array[j-1];
            array[j-1]=hold;
            j--;
        }
    }
    // sorted the array

    int y;
    for(y=0;y<a;y++){
        while(y!=a-1){
            diff=array[y]-array[y-1];
            if(diff>max){
                diff=max;
            }
            if(diff==max){
                count++;
            }
        }
    }
    printf("%d %d",diff,count);
    return 0;
}


//
//  main.c
//  codeforces_problemset
//
//  Created by Ashish on 10/10/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    int n;
    int i;
    int array[200000]={0};
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&array[i]);
    }
    int j;
    int max=0;
    int min=array[0];
    for(j=0;j<n;j++){

        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }

    }
    int count1=0;
    int count2=0;
    for(j=0;j<n;j++){
        if(array[j]==max){
            count1++;
        }
        if(array[j]==min){
            count2++;
        }
    }
    printf("%d %d",max-min,count1+count2);
        return 0;
}


//
//  main.c
//  codeforces_problemset
//
//  Created by Ashish on 10/10/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    int n;
    int i;
    int array[200000]={0};
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&array[i]);
    }
    int j;
    int max=0;
    int min=array[0];
    for(j=0;j<n;j++){

        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }

    }
    int count1=0;
    int count2=0;
    for(j=0;j<n;j++){
        if(array[j]==max){
            count1++;
        }
        if(array[j]==min){
            count2++;
        }
    }
    int min1=count1;
    if(count1>count2){
        min1=count2;
    }
    printf("%d %d",max-min,min1*min1);
        return 0;
}


//
//  main.c
//  codeforces_problemset
//
//  Created by Ashish on 10/10/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    unsigned long long int n;
    unsigned long long int i;
    int array[200000]={0};
    scanf("%llu\n",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&array[i]);
    }
    int j;
    unsigned long long int max=0;
    unsigned long long int min=array[0];
    for(j=0;j<n;j++){

        if(array[j]>max){
            max=array[j];
        }
        if(array[j]<min){
            min=array[j];
        }

    }
    unsigned long long int count1=0;
   unsigned long long  int count2=0;
    for(j=0;j<n;j++){
        if(array[j]==max){
            count1++;
        }
        if(array[j]==min){
            count2++;
        }
    }
    printf("%llu %llu",max-min,count1*count2);
        return 0;
}


#include <stdio.h>
#include <stdlib.h>

void mySort(int n,int A[n]);

void merge(int arr[],int low,int mid,int high,int n);
void mergeSort(int arr[], int low, int high);

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);

    }
    mergeSort(A,0,n);
    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

void mySort(int n,int A[n])
{
    int i,value,pos;
    for(i=1;i<n;i++)
    {
        pos = i;
        value = A[i];
        while(value < A[pos-1] && pos> 0)
        {
            A[pos] = A[pos-1];
            pos--;
        }
        A[pos] = value;

    }
}

void mergeSort(int arr[], int low, int high)
{
    int mid;
    if(low<high)
    {
        mid = (low+high)/2;
        mergeSort(arr, low, mid);
        mergeSort(arr, mid+1, high);
        merge(arr, low, mid, high,high);
    }
}

void merge(int arr[],int low,int mid,int high,int n)
{
    int i, l , r, k, temp[n];
    l=low;
    r=mid+1;
    i=low;
    while((l<=mid)&&(r<=high))
    {
        if(arr[l]<=arr[r])
        {
            temp[i]=arr[l];
            l++;
        }
        else
        {
            temp[i]=arr[r];
            r++;
        }
        i++;
    }
    if(l>mid)
    {
        for(k=r; k<=high; k++)
        {
            temp[i]=arr[k];
            i++;
        }
    }
    else
    {
        for(k=l; k<=mid; k++)
        {
            temp[i]=arr[k];
            i++;
        }
    }
    for(k=low; k<=high; k++)
    {
        arr[k]=temp[k];
    }
}


#include <stdio.h>
#include <stdlib.h>

void mySort(int n,int A[n]);

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    mySort(n,A);
    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

void mySort(int n,int A[n])
{
    int i,value,pos;
    for(i=1;i<n;i++)
    {
        pos = i;
        value = A[i];
        while(value < A[pos-1] && pos> 0)
        {
            A[pos] = A[pos-1];
            pos--;
        }
        A[pos] = value;

    }
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i] == max)
        {
            counter1++;
        }
        if(A[i] == min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        double t = n*(n-1)/2;
        printf("%g",t);
    }
    else
    {
       double t = counter1 * counter2 ;
        printf("%g",t);
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int getMax(int arr[], int n);
void countSort(int arr[], int n, int exp);
void radixsort(int arr[], int n);

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);

    }

    int x = sizeof(A)/sizeof(A[0]);
    radixsort(A, x);

    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

int getMax(int arr[], int n)
{
    int i;
    int mx = arr[0];
    for ( i = 1; i < n; i++)
        if (arr[i] > mx)
            mx = arr[i];
    return mx;
}

void countSort(int arr[], int n, int exp)
{
    int output[n]; // output array
    int i, count[10] = {0};

    // Store count of occurrences in count[]
    for (i = 0; i < n; i++)
        count[ (arr[i]/exp)%10 ]++;

    // Change count[i] so that count[i] now contains actual
    //  position of this digit in output[]
    for (i = 1; i < 10; i++)
        count[i] += count[i - 1];

    // Build the output array
    for (i = n - 1; i >= 0; i--)
    {
        output[count[ (arr[i]/exp)%10 ] - 1] = arr[i];
        count[ (arr[i]/exp)%10 ]--;
    }

    // Copy the output array to arr[], so that arr[] now
    // contains sorted numbers according to current digit
    for (i = 0; i < n; i++)
        arr[i] = output[i];
}

void radixsort(int arr[], int n)
{
    // Find the maximum number to know number of digits
    int m = getMax(arr, n);

    // Do counting sort for every digit. Note that instead
    // of passing digit number, exp is passed. exp is 10^i
    // where i is current digit number
        int exp;
    for (exp = 1; m/exp > 0; exp *= 10)
        countSort(arr, n, exp);
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,max = INT_MIN , min = INT_MAX,x;
    double counter1=0,counter2=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%d",n*(n-1)/2);
    }
    else
    {
        printf("%g",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x,t;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(counter1 == counter2)
    {
        t =  pow(counter1,2);
        printf("%d",t);
    }
    else
    {
        t = counter1 * counter2 ;
        printf("%d",t);
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x,t;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        t = n*(n-1)/2;
        printf("%d",t);
    }
    else
    {
        t = counter1 * counter2 ;
        printf("%d",t);
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);

    }

    int x = sizeof(A)/sizeof(A[0]);
    radixsort(A, x);

    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

int getMax(int arr[], int n)
{
    int i;
    int mx = arr[0];
    for ( i = 1; i < n; i++)
        if (arr[i] > mx)
            mx = arr[i];
    return mx;
}

void countSort(int arr[], int n, int exp)
{
    int output[n]; // output array
    int i, count[10] = {0};

    // Store count of occurrences in count[]
    for (i = 0; i < n; i++)
        count[ (arr[i]/exp)%10 ]++;

    // Change count[i] so that count[i] now contains actual
    //  position of this digit in output[]
    for (i = 1; i < 10; i++)
        count[i] += count[i - 1];

    // Build the output array
    for (i = n - 1; i >= 0; i--)
    {
        output[count[ (arr[i]/exp)%10 ] - 1] = arr[i];
        count[ (arr[i]/exp)%10 ]--;
    }

    // Copy the output array to arr[], so that arr[] now
    // contains sorted numbers according to current digit
    for (i = 0; i < n; i++)
        arr[i] = output[i];
}

void radixsort(int arr[], int n)
{
    // Find the maximum number to know number of digits
    int m = getMax(arr, n);

    // Do counting sort for every digit. Note that instead
    // of passing digit number, exp is passed. exp is 10^i
    // where i is current digit number
        int exp;
    for (exp = 1; m/exp > 0; exp *= 10)
        countSort(arr, n, exp);
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x,t;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    printf("%d",(counter1*counter2));

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,max = INT_MIN , min = INT_MAX,x;
    int counter1=0,counter2=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i] == max)
        {
            counter1++;
        }

    }
    for(i=0;i<n;i++)
    {
         if(A[i] == min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%d",n*(n-1)/2);
    }
    else
    {
        printf("%d",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

void mySort(int n,int A[n]);

void merge(int arr[],int low,int mid,int high,int n);
void mergeSort(int arr[], int low, int high);
void quickSort (int arr[], int left, int right);

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);

    }
    quickSort(A,0,n-1);
    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

void mySort(int n,int A[n])
{
    int i,value,pos;
    for(i=1;i<n;i++)
    {
        pos = i;
        value = A[i];
        while(value < A[pos-1] && pos> 0)
        {
            A[pos] = A[pos-1];
            pos--;
        }
        A[pos] = value;

    }
}

void mergeSort(int arr[], int low, int high)
{
    int mid;
    if(low<high)
    {
        mid = (low+high)/2;
        mergeSort(arr, low, mid);
        mergeSort(arr, mid+1, high);
        merge(arr, low, mid, high,high);
    }
}

void merge(int arr[],int low,int mid,int high,int n)
{
    int i, l , r, k, temp[n];
    l=low;
    r=mid+1;
    i=low;
    while((l<=mid)&&(r<=high))
    {
        if(arr[l]<=arr[r])
        {
            temp[i]=arr[l];
            l++;
        }
        else
        {
            temp[i]=arr[r];
            r++;
        }
        i++;
    }
    if(l>mid)
    {
        for(k=r; k<=high; k++)
        {
            temp[i]=arr[k];
            i++;
        }
    }
    else
    {
        for(k=l; k<=mid; k++)
        {
            temp[i]=arr[k];
            i++;
        }
    }
    for(k=low; k<=high; k++)
    {
        arr[k]=temp[k];
    }
}

void quickSort (int arr[], int left, int right)
{
    int pivot, j, temp, i;
    if(left<right)
    {
        pivot=left;
        i=left;
        j=right;
        while(i<j)
        {
            while(arr[i]<arr[pivot]&&i<right)
                i++;
            while(arr[j]>=arr[pivot] && j>left)
                j--;
            if(i<j)
            {
                temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
        temp=arr[pivot];
        arr[pivot]=arr[j];
        arr[j]=temp;
        quickSort(arr,left,j-1);
        quickSort(arr,j+1,right);
    }
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,max = INT_MIN , min = INT_MAX,x;
    long long counter1=0,counter2=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%d",n*(n-1)/2);
    }
    else
    {
        printf("%d",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x,t;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(counter1 == counter2)
    {
        t =  pow(counter1,2);
        printf("%d",t);
    }
    else
    {
        t = counter1 * counter2 ;
        printf("%d",t);
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x,t;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(counter1==counter2)
    {
        t = n*(n-1)/2;
        printf("%d",t);
    }
    else
    {
        t = counter1 * counter2 ;
        printf("%d",t);
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    long int n,i,max = INT_MIN , min = INT_MAX,x;
    long int counter1=0,counter2=0;
    scanf("%ld",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%ld ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i] == max)
        {
            counter1++;
        }

    }
    for(i=0;i<n;i++)
    {
         if(A[i] == min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%ld",n*(n-1)/2);
    }
    else
    {
        printf("%ld",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#define RANGE 255
int getMax(int arr[], int n);
void countSort(int arr[], int n, int exp);
void radixsort(int arr[], int n);

void countSort2(char *str)
{
    // The output character array that will have sorted str
    char output[strlen(str)];

    // Create a count array to store count of inidividul characters and
    // initialize count array as 0
    int count[RANGE + 1], i;
    memset(count, 0, sizeof(count));

    // Store count of each character
    for(i = 0; str[i]; ++i)
        ++count[str[i]];

    // Change count[i] so that count[i] now contains actual position of
    // this character in output array
    for (i = 1; i <= RANGE; ++i)
        count[i] += count[i-1];

    // Build the output character array
    for (i = 0; str[i]; ++i)
    {
        output[count[str[i]]-1] = str[i];
        --count[str[i]];
    }

    // Copy the output array to str, so that str now
    // contains sorted characters
    for (i = 0; str[i]; ++i)
        str[i] = output[i];
}

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);

    }

    countSort2(A);

    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

int getMax(int arr[], int n)
{
    int i;
    int mx = arr[0];
    for ( i = 1; i < n; i++)
        if (arr[i] > mx)
            mx = arr[i];
    return mx;
}

void countSort(int arr[], int n, int exp)
{
    int output[n]; // output array
    int i, count[10] = {0};

    // Store count of occurrences in count[]
    for (i = 0; i < n; i++)
        count[ (arr[i]/exp)%10 ]++;

    // Change count[i] so that count[i] now contains actual
    //  position of this digit in output[]
    for (i = 1; i < 10; i++)
        count[i] += count[i - 1];

    // Build the output array
    for (i = n - 1; i >= 0; i--)
    {
        output[count[ (arr[i]/exp)%10 ] - 1] = arr[i];
        count[ (arr[i]/exp)%10 ]--;
    }

    // Copy the output array to arr[], so that arr[] now
    // contains sorted numbers according to current digit
    for (i = 0; i < n; i++)
        arr[i] = output[i];
}

void radixsort(int arr[], int n)
{
    // Find the maximum number to know number of digits
    int m = getMax(arr, n);

    // Do counting sort for every digit. Note that instead
    // of passing digit number, exp is passed. exp is 10^i
    // where i is current digit number
        int exp;
    for (exp = 1; m/exp > 0; exp *= 10)
        countSort(arr, n, exp);
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,max = INT_MIN , min = INT_MAX,x;
    double counter1=0,counter2=0,t=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i] == max)
        {
            counter1++;
        }
        if(A[i] == min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        t = n*(n-1)/2;
        printf("%d",t);
    }
    else
    {
        t = counter1 * counter2 ;
        printf("%d",t);
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,max = INT_MIN , min = INT_MAX,x;
    int counter1=0,counter2=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i] == max)
        {
            counter1++;
        }

    }
    for(i=0;i<n;i++)
    {
         if(A[i] == min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%I64d",n*(n-1)/2);
    }
    else
    {
        printf("%I64d",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    long long int n,i,max = INT_MIN , min = INT_MAX,x;
    long long int counter1=0,counter2=0;
    scanf("%I64d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%I64d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i] == max)
        {
            counter1++;
        }

    }
    for(i=0;i<n;i++)
    {
         if(A[i] == min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%I64d",n*(n-1)/2);
    }
    else
    {
        printf("%I64d",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
//////asdfsadf
void mySort(int n,int A[n]);

void merge(int arr[],int low,int mid,int high,int n);
void mergeSort(int arr[], int low, int high);
void quickSort (int arr[], int left, int right);

int main()
{
    int n,i,counter=0,j,max;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);

    }
    quickSort(A,0,n-1);
    i=0;
    j = n-1;
    max = A[j] - A[i];
    printf("%d ",max);
    for(i=0; A[i] == A[0] ;i++)
    {
        for(j=n-1; A[j] == A[n-1];j--)
        {
            counter++;
        }
    }
    printf("%d",counter);

    return 0;
}

void mySort(int n,int A[n])
{
    int i,value,pos;
    for(i=1;i<n;i++)
    {
        pos = i;
        value = A[i];
        while(value < A[pos-1] && pos> 0)
        {
            A[pos] = A[pos-1];
            pos--;
        }
        A[pos] = value;

    }
}

void mergeSort(int arr[], int low, int high)
{
    int mid;
    if(low<high)
    {
        mid = (low+high)/2;
        mergeSort(arr, low, mid);
        mergeSort(arr, mid+1, high);
        merge(arr, low, mid, high,high);
    }
}

void merge(int arr[],int low,int mid,int high,int n)
{
    int i, l , r, k, temp[n];
    l=low;
    r=mid+1;
    i=low;
    while((l<=mid)&&(r<=high))
    {
        if(arr[l]<=arr[r])
        {
            temp[i]=arr[l];
            l++;
        }
        else
        {
            temp[i]=arr[r];
            r++;
        }
        i++;
    }
    if(l>mid)
    {
        for(k=r; k<=high; k++)
        {
            temp[i]=arr[k];
            i++;
        }
    }
    else
    {
        for(k=l; k<=mid; k++)
        {
            temp[i]=arr[k];
            i++;
        }
    }
    for(k=low; k<=high; k++)
    {
        arr[k]=temp[k];
    }
}

void quickSort (int arr[], int left, int right)
{
    int pivot, j, temp, i;
    if(left<right)
    {
        pivot=left;
        i=left;
        j=right;
        while(i<j)
        {
            while(arr[i]<arr[pivot]&&i<right)
                i++;
            while(arr[j]>=arr[pivot] && j>left)
                j--;
            if(i<j)
            {
                temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
        temp=arr[pivot];
        arr[pivot]=arr[j];
        arr[j]=temp;
        quickSort(arr,left,j-1);
        quickSort(arr,j+1,right);
    }
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

///sdafsfsa

int main()
{
    int n,i,max = INT_MIN , min = INT_MAX,x;
    long long counter1=0,counter2=0;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%d",n*(n-1)/2);
    }
    else
    {
        printf("%d",counter1 * counter2 );
    }

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main()
{
    int n,i,counter1=0,counter2=0,max = INT_MIN , min = INT_MAX,x;
    scanf("%d",&n);
    int A[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }

    ///get min & max

    for(i=0;i<n;i++)
    {
        if(A[i] > max)
        {
            max = A[i];
        }
        if(A[i] < min)
        {
            min = A[i];
        }
    }
    x = max - min;

    printf("%d ",x);

    ///counting
    for(i=0;i<n;i++)
    {
        if(A[i]==max)
        {
            counter1++;
        }
        if(A[i]==min)
        {
            counter2++;
        }
    }

    if(min == max)
    {
        printf("%d",n*(n-1)/2);
    }
    else
    {
        printf("%d",counter1 * counter2 );
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,min=1000000000,max=0,b,minc,maxc;
    long long l;
    scanf("%i", &n);
    for(int i=0; i<n; i++){
        scanf("%i", &b);
        if(b>max){
            max=b;
            maxc=1;
        }
        else{
            if(b==max){
                maxc++;
            }
        }
        if(b<min){
            min=b;
            minc=1;
        }
        else{
            if(b==min){
                minc++;
            }
        }
    }
    l=maxc*minc;
    printf("%i %lli", max-min, l);
    return 0;
};


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,min=1000000000,max=0,b,minc,maxc;
    scanf("%i", &n);
    for(int i=0; i<n; i++){
        scanf("%i", &b);
        if(b>max){
            max=b;
            maxc=1;
        }
        else{
            if(b==max){
                maxc++;
            }
        }
        if(b<min){
            min=b;
            minc=1;
        }
        else{
            if(b==min){
                minc++;
            }
        }
    }
    printf("%i %i", max-min, minc*maxc);
    return 0;
};


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,min=1000000000,max=0,b;
    long long minc,maxc;
    scanf("%i", &n);
    for(int i=0; i<n; i++){
        scanf("%i", &b);
        if(b>max){
            max=b;
            maxc=1;
        }
        else{
            if(b==max){
                maxc++;
            }
        }
        if(b<min){
            min=b;
            minc=1;
        }
        else{
            if(b==min){
                minc++;
            }
        }
    }
    if(min==max){
        int i=1,f=0;
        while(i!=(minc+maxc)/2){
            f+=i;
            i++;
        }
        printf("%i %i", max-min, f);
    }
    else{
        printf("%i %lli", max-min, maxc*minc);
    }
    return 0;
};


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,min=1000000000,max=0,b;
    long long minc,maxc;
    scanf("%i", &n);
    for(int i=0; i<n; i++){
        scanf("%i", &b);
        if(b>max){
            max=b;
            maxc=1;
        }
        else{
            if(b==max){
                maxc++;
            }
        }
        if(b<min){
            min=b;
            minc=1;
        }
        else{
            if(b==min){
                minc++;
            }
        }
    }
    printf("%i %lli", max-min, maxc*minc);
    return 0;
};


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,min=1000000000,max=0,b;
    long long minc,maxc;
    scanf("%i", &n);
    for(int i=0; i<n; i++){
        scanf("%i", &b);
        if(b>max){
            max=b;
            maxc=0;
        }
        if(b<min){
            min=b;
            minc=0;
        }
        if(b==max){
            maxc++;
        }
        if(b==min){
            minc++;
        }
    }
    if(max==min){
        long long g;
        g=(maxc*(maxc-1))/2;
        printf("0 %lli", g);
    }
    else{
        printf("%i %lli", max-min, minc*maxc);
    }
    return 0;
};


#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,min=1000000000,max=0,b;
    long long minc,maxc;
    scanf("%i", &n);
    for(int i=0; i<n; i++){
        scanf("%i", &b);
        if(b>max){
            max=b;
            maxc=0;
        }
        if(b<min){
            min=b;
            minc=0;
        }
        if(b==max){
            maxc++;
        }
        if(b==min){
            minc++;
        }
    }
    if(max==min){
        long long g;
        g=(maxc+minc)/2;
        g=g*(g-1)/2;
        printf("0 %lli", g);
    }
    else{
        printf("%i %lli", max-min, minc*maxc);
    }
    return 0;
};


#include <stdio.h>

int main()
{
	int n;
	int a[200000];
	scanf("%d", &n);
	scanf("%d", &a[0]);
	int min = a[0], max = a[0];
	for (int i=1; i<n; i++)
	{
		scanf("%d", &a[i]);
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	printf("%d ", max - min);
	int d1 = 0, d2 = 0;
	for (int i=0; i<n; i++)
	{
		if (min == a[i]) d1++;
		if (max == a[i]) d2++;
	}
	long long t = d1 * d2;
	printf("%I64d", t);
	return 0;
}


#include <stdio.h>
#include <inttypes.h>

int main()
{
	int n;
	int a[200000];
	scanf("%d", &n);
	scanf("%d", &a[0]);
	int min = a[0], max = a[0];
	for (int i=1; i<n; i++)
	{
		scanf("%d", &a[i]);
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	printf("%d ", max - min);
	int d1 = 0, d2 = 0;
	for (int i=0; i<n; i++)
	{
		if (min == a[i]) d1++;
		if (max == a[i]) d2++;
	}
	if (min != max) printf("%I64d", (long long) d1 * (long long) d2);
	else printf("%I64d", ((long long) d1 * (long long) (d1-1)) / 2);

	return 0;
}


#include <stdio.h>

int main()
{
	int n;
	int a[20000];
	scanf("%d", &n);
	scanf("%d", &a[0]);
	int min = a[0], max = a[0];
	for (int i=1; i<n; i++)
	{
		scanf("%d", &a[i]);
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	printf("%d ", max - min);
	int d1 = 0, d2 = 0;
	for (int i=0; i<n; i++)
	{
		if (min == a[i]) d1++;
		if (max == a[i]) d2++;
	}
	printf("%d", d1 * d2);
	return 0;
}


#include <stdio.h>

int main()
{
	int n;
	int a[200000];
	scanf("%d", &n);
	scanf("%d", &a[0]);
	int min = a[0], max = a[0];
	for (int i=1; i<n; i++)
	{
		scanf("%d", &a[i]);
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	printf("%d ", max - min);
	int d1 = 0, d2 = 0;
	for (int i=0; i<n; i++)
	{
		if (min == a[i]) d1++;
		if (max == a[i]) d2++;
	}
	printf("%d", d1 * d2);
	return 0;
}


#include <stdio.h>

int main()
{
	int n;
	int a[200000];
	scanf("%d", &n);
	scanf("%d", &a[0]);
	int min = a[0], max = a[0];
	for (int i=1; i<n; i++)
	{
		scanf("%d", &a[i]);
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	printf("%d ", max - min);
	int d1 = 0, d2 = 0;
	for (int i=0; i<n; i++)
	{
		if (min == a[i]) d1++;
		if (max == a[i]) d2++;
	}
	printf("%I64d", d1 * d2);
	return 0;
}


#include <stdio.h>
#include <inttypes.h>

int main()
{
	int n;
	int a[200000];
	scanf("%d", &n);
	scanf("%d", &a[0]);
	int min = a[0], max = a[0];
	for (int i=1; i<n; i++)
	{
		scanf("%d", &a[i]);
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}
	printf("%d ", max - min);
	int d1 = 0, d2 = 0;
	for (int i=0; i<n; i++)
	{
		if (min == a[i]) d1++;
		if (max == a[i]) d2++;
	}

	printf("%I64d", (long long) d1 * (long long) d2);

	return 0;
}


#include<stdio.h>
int main()
{
    int n;
unsigned    long long int max=0,a[200005],min=1000000007,cnt1=0,cnt2=0;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
            if(max<a[i])
            max=a[i];
            if(min>a[i])
            min=a[i];

    }
    printf("%llu ",max-min);
        for(i=0;i<n;i++)
        {
            if(max==a[i])
            cnt1++;
            if(min==a[i])
            cnt2++;
        }
        if(cnt1==0 || cnt2==0)
        printf("1\n");
        else if(cnt1==n)
        printf("%llu\n",n*(n-1)/2);
        else printf("%llu\n",cnt1*cnt2);

        return 0;
}


#include<stdio.h>
#include<limits.h>
int a[1000000];
int main()
{
    int c1=0,c2=0,n,max=0,min=INT_MAX,tmp,i;
        scanf("%d",&n);
     for(i=0;i<n;i++)
     {
        scanf("%d",&tmp);
          if(max<tmp)
          {
            max=tmp;
            c1=1;
          }
          else
          if(max==tmp)
          c1++;
          if(min>tmp)
          {
            min = tmp;
            c2=1;
          }
          else
          if(min==tmp)
          c2++;
     }
     printf("%d %d\n",max-min,c1*c2);
     return 0;
}


#include<stdio.h>
#include<limits.h>
int main()
{
    int count ,a[100000]={0},n,max=0,min=INT_MAX,tmp,i;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
        scanf("%d",&tmp);
          a[tmp] ++;
          if(max<tmp)
          max=tmp;
          if(min>tmp)
          min = tmp;
     }
     printf("%d %d\n",max-min,a[max]*a[min]);
     return 0;
}


#include<stdio.h>
int main()
{
    int n;
unsigned    long long int max=0,a[200005],min=1000000007,cnt1=0,cnt2=0;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%llu",&a[i]);
            if(max<a[i])
            max=a[i];
            if(min>a[i])
            min=a[i];

    }
    printf("%llu ",max-min);
        for(i=0;i<n;i++)
        {
            if(max==a[i])
            cnt1++;
            if(min==a[i])
            cnt2++;
        }if(max==min)
        cnt2=1;

        else if(cnt1==n)
        printf("%llu\n",n*(n-1)/2);
        else printf("%llu\n",cnt1*cnt2);

        return 0;
}


#include<stdio.h>
int main()
{
    int n;
unsigned    long long int max=0,a[200005],min=1000000007,cnt1=0,cnt2=0;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
            if(max<a[i])
            max=a[i];
            if(min>a[i])
            min=a[i];

    }
    printf("%llu ",max-min);
    if(max!=min){
        for(i=0;i<n;i++)
        {
            if(max==a[i])
            cnt1++;
            if(min==a[i])
            cnt2++;
        }
        if(cnt1==0 || cnt2==0)
        printf("1\n");
        else printf("%llu\n",cnt1*cnt2);
    }else
    printf("1\n");
        return 0;
}


#include<stdio.h>
#include<limits.h>
int main()
{
    int count ,a[100000],n,max=0,min=INT_MAX,tmp,i;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
        scanf("%d",&tmp);
          a[tmp] ++;
          if(max<tmp)
          max=tmp;
          if(min>tmp)
          min = tmp;
     }
     printf("%d %d\n",max-min,a[max]*a[min]);
     return 0;
}


#include<stdio.h>
int main()
{
	int n;
unsigned	long long int max=0,a[200005],min=1000000007,cnt1=0,cnt2=0;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
			if(max<a[i])
			max=a[i];
			if(min>a[i])
			min=a[i];

	}
	printf("%llu ",max-min);
	if(max!=min){
		for(i=0;i<n;i++)
		{
			if(max==a[i])
			cnt1++;
			if(min==a[i])
			cnt2++;
		}
		if(cnt1==0 || cnt2==0)
		printf("1\n");
		else printf("%llu\n",cnt1*cnt2);
	}else
	printf("%llu\n",n*(n-1)/2);
		return 0;
}


#include<stdio.h>
#include<limits.h>
int main()
{
    int count ,a[200005]={0},n,max=0,min=INT_MAX,tmp,i;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
        scanf("%d",&tmp);
          a[tmp] ++;
          if(max<tmp)
          max=tmp;
          if(min>tmp)
          min = tmp;
     }
     printf("%d %d\n",max-min,a[max]*a[min]);
     return 0;
}


#include<stdio.h>
int main()
{
    int n;
unsigned    long long int max=0,a[200005],min=1000000007,cnt1=0,cnt2=0;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%llu",&a[i]);
            if(max<a[i])
            max=a[i];
            if(min>a[i])
            min=a[i];

    }
    printf("%llu ",max-min);
        for(i=0;i<n;i++)
        {
            if(max==a[i])
            cnt1++;
            if(min==a[i])
            cnt2++;
        }

        if(max==min)
        printf("%llu\n",cnt1*(cnt1-1)/2);
        else printf("%llu\n",cnt1*cnt2);

        return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int c1=0,c2=0,n,max=0,min=INT_MAX,tmp,i;
        cin>>n;
     for(i=0;i<n;i++)
     {
          cin>>tmp;
          if(max<tmp)
          {
            max=tmp;
            c1=1;
          }
          else
          if(max==tmp)
          c1++;
          if(min>tmp)
          {
            min = tmp;
            c2=1;
          }
          else
          if(min==tmp)
          c2++;
     }
     cout<<max-min<<" "<<c1*c2;
     return 0;
}


#include<stdio.h>
#include<limits.h>
int main()
{
    int count ,a[100005]={0},n,max=0,min=INT_MAX,tmp,i;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
        scanf("%d",&tmp);
          a[tmp] ++;
          if(max<tmp)
          max=tmp;
          if(min>tmp)
          min = tmp;
     }
     printf("%d %d\n",max-min,a[max]*a[min]);
     return 0;
}


#include<stdio.h>
int main()
{
    int n;
   unsigned long long int max=0,a[200005],min=1000000007,cnt1=0,cnt2=0;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%llu",&a[i]);
            if(max<a[i])
            max=a[i];
            if(min>a[i])
            min=a[i];

    }
    printf("%llu ",max-min);
        for(i=0;i<n;i++)
        {
            if(max==a[i])
            cnt1++;
            if(min==a[i])
            cnt2++;
        }
        if(cnt1==0 || cnt2==0)
        printf("1\n");
        else printf("%llu\n",cnt1*cnt2);
        return 0;
}


#include<stdio.h>
int a[200001];
int cmp(const void*t1,const void*t2)
{
	return *(int*)t1-*(int*)t2;
}
int main()
{
      int m,n,i,j;
      int m1=0;
      int k1,k2;
      __int64 num1=0,num2=0;
      __int64 num;
      scanf("%d",&m);
	  for(i=0;i<m;++i)
	  {
		  scanf("%d",&a[i]);
	  }
	  qsort(a,m,sizeof(a[0]),cmp);
	  m1=a[m-1]-a[0];
	  k1=a[0],k2=a[m-1];
	  int tt=1;
	  if(k1==k2)
      {
          printf("%d %d",k1,1);
      }
      else{
	  for(i=0;i<m;++i)
      {
          if(a[i]==k1)
          {
              ++num1;
          }
          else if(a[i]==k2)
          {
              ++num2;
          }
      }
      num=num1*num2;
      printf("%d %I64d\n",m1,num);}
	  return 0;
}


#include<stdio.h>
int a[200001];
int cmp(const void*t1,const void*t2)
{
	return *(int*)t1-*(int*)t2;
}
int main()
{
      int m,n,i,j;
      int m1=0;
      int k1,k2;
      __int64 num1=0,num2=0;
      __int64 num;
      scanf("%d",&m);
	  for(i=0;i<m;++i)
	  {
		  scanf("%d",&a[i]);
	  }
	  qsort(a,m,sizeof(a[0]),cmp);
	  m1=a[m-1]-a[0];
	  k1=a[0],k2=a[m-1];
	  if(k1==k2)
      {
          printf("%d %I64d\n",m1,m*(m-1)/2);
      }
      else{
	  for(i=0;i<m;++i)
      {
          if(a[i]==k1)
          {
              ++num1;
          }
          else if(a[i]==k2)
          {
              ++num2;
          }
      }
      num=num1*num2;
      printf("%d %I64d\n",m1,num);}
	  return 0;
}


#include<stdio.h>
int a[200001];
int cmp(const void*t1,const void*t2)
{
	return *(int*)t1-*(int*)t2;
}
int main()
{
      int m,n,i,j;
      int m1=0;
      int k1,k2;
      __int64 num1=0,num2=0;
      __int64 num;
      scanf("%d",&m);
	  for(i=0;i<m;++i)
	  {
		  scanf("%d",&a[i]);
	  }
	  qsort(a,m,sizeof(a[0]),cmp);
	  m1=a[m-1]-a[0];
	  k1=a[0],k2=a[m-1];
	  for(i=0;i<m;++i)
      {
          if(a[i]==k1)
          {
              ++num1;
          }
          else if(a[i]==k2)
          {
              ++num2;
          }
      }
      num=num1*num2;
      printf("%d %I64d\n",m1,num);
	  return 0;
}


#include<stdio.h>
int a[200001];
int cmp(const void*t1,const void*t2)
{
	return *(int*)t1-*(int*)t2;
}
int main()
{
      int m,n,i,j;
      int m1=0;
      int k1,k2;
      int num=0;
      scanf("%d",&m);
	  for(i=0;i<m;++i)
	  {
		  scanf("%d",&a[i]);
	  }
	  qsort(a,m,sizeof(a[0]),cmp);
	  m1=a[m-1]-a[0];
	  k1=a[0],k2=a[m-1];
	  for(i=0;i<m;++i)
      {
          for(j=i+1;j<m;++j)
          {
              if(a[i]==k1&&a[j]==k2)
              {
                  ++num;
              }
          }

      }
      printf("%d %d\n",m1,num);
	  return 0;
}


#include<stdio.h>
int a[200001];
int cmp(const void*t1,const void*t2)
{
	return *(int*)t1-*(int*)t2;
}
int main()
{
      int m,n,i,j;
      int m1=0;
      int k1,k2;
      __int64 num1=0,num2=0;
      __int64 num;
      scanf("%d",&m);
	  for(i=0;i<m;++i)
	  {
		  scanf("%d",&a[i]);
	  }
	  qsort(a,m,sizeof(a[0]),cmp);
	  m1=a[m-1]-a[0];
	  k1=a[0],k2=a[m-1];
	  if(k1==k2)
      {
          printf("%d %d\n",k1,m);
      }
      else{
	  for(i=0;i<m;++i)
      {
          if(a[i]==k1)
          {
              ++num1;
          }
          else if(a[i]==k2)
          {
              ++num2;
          }
      }
      num=num1*num2;
      printf("%d %I64d\n",m1,num);}
	  return 0;
}


#include<stdio.h>
int a[200001];
int cmp(const void*t1,const void*t2)
{
	return *(int*)t1-*(int*)t2;
}
int main()
{
      int m,n,i,j;
      int m1=0;
      int k1,k2;
      __int64 num1=0,num2=0;
      __int64 num;
      scanf("%d",&m);
	  for(i=0;i<m;++i)
	  {
		  scanf("%d",&a[i]);
	  }
	  qsort(a,m,sizeof(a[0]),cmp);
	  m1=a[m-1]-a[0];
	  k1=a[0],k2=a[m-1];
	  if(k1==k2)
      {
          printf("%d %d\n",k1,m1);
      }
      else{
	  for(i=0;i<m;++i)
      {
          if(a[i]==k1)
          {
              ++num1;
          }
          else if(a[i]==k2)
          {
              ++num2;
          }
      }
      num=num1*num2;
      printf("%d %I64d\n",m1,num);}
	  return 0;
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

#define FOR(a,b,i) for(i = a, i<b, i++)

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    int topcount=0;
    int bottomcount=0;

    for (i=0; i<n; i++) {
        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    int numberways;

    if (difference>0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %d",difference,numberways);
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    long int topcount=0;
    long int bottomcount=0;

    for (i=0; i<n; i++) {
        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    long int numberways;

    if (difference!=0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %ld",difference,numberways);

    return 0;
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    long long int topcount=0;
    long long int bottomcount=0;

    for (i=0; i<n; i++) {

        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    long long int numberways;

    if (difference!=0) {
        numberways=(topcount*bottomcount);
    }//end if

    if (difference==0) {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %I64d",difference,numberways);

  /*  if (difference==999999999) {
        printf("\n %ld %ld",topcount, bottomcount);
    }
    */
    return 0;
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    long int topcount=0;
    long int bottomcount=0;

    for (i=0; i<n; i++) {

        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    long int numberways;

    if (difference!=0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %ld",difference,numberways);

    if (difference==999999999) {
        printf("\n %ld %ld",topcount, bottomcount);
    }

    return 0;
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    long int topcount=0;
    long int bottomcount=0;

    for (i=0; i<n; i++) {
        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    long int numberways;

    if (difference>0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %ld",difference,numberways);

    return 0;
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    int topcount=0;
    int bottomcount=0;

    for (i=0; i<n; i++) {
        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    int numberways;

    if (difference>0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %d",difference,numberways);
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    int topcount=0;
    int bottomcount=0;

    for (i=0; i<n; i++) {
        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    int numberways;

    if (difference>0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %d",difference,numberways);

    return 0;
}


//
//  main.c
//  CF459B
//
//  Created by Mark Sellke on 8/17/14.
//  Copyright (c) 2014 MarkC. All rights reserved.
//

#include <stdio.h>

#define FOR(a,b,i) for(i = a, i<b, i++)

int max(int a, int b);
int min(int a, int b);

int main(int argc, const char * argv[])
{
    int i,n;

    scanf("%d\n",&n);

    int input;
    int top=0;
    int bottom=1e9 + 1;

    int topcount=0;
    int bottomcount=0;

    for (i=0; i<n; i++) {
        scanf("%d ",&input);

        if (input>top) {
            top=input;
            topcount=1;
        } //end if

        else if(input==top){

            topcount++;

        }//end else

        if (input<bottom) {
            bottom=input;
            bottomcount=1;
        }//end if

        else if (input==bottom) {

            bottomcount++;

        }//end else

    } //end for

    int difference = top-bottom;
    int numberways;

    if (difference>0) {
        numberways=topcount*bottomcount;
    }//end if

    else {

        numberways=((topcount)*(topcount-1))/2;
    }//end else

    printf("%d %d",difference,numberways);
}

int max(int a, int b) {
    if (a>b) {
        return a;
    }
    else{
        return b;
    }
} //end max

int min(int a, int b) {

    return (a+b-max(a, b));

}//end min


#include<stdio.h>
#include<stdlib.h>
int comp(const void* a, const void* b)
{
  return *(int *)a - *(int *)b;
}
int main()
{
  __int64 n;
  scanf("%I64d",&n);
  __int64 i,a[n],b=0,c=0;
  for(i=0;i<n;i++)
  {
    scanf("%I64d",&a[i]);
  }
  qsort(a,n,sizeof(__int64),comp);
  i=n-1;
  while (a[i]==a[n-1]){
    b++;
    i--;
  }
  i=0;
  while(a[i] == a[0] && i!=n-b)
  {
    c++;
    i++;
  }
  printf("%I64d %I64d",a[n-1]-a[0],b*c);
}


#include<stdio.h>
#include<stdlib.h>
int comp(const void* a, const void* b)
{
  return *(int *)a - *(int *)b;
}
int main()
{
  __int64 n;
  scanf("%I64d",&n);
  __int64 i,a[n],b=0,c=0;
  for(i=0;i<n;i++)
  {
    scanf("%I64d",&a[i]);
  }
  qsort(a,n,sizeof(__int64),comp);
  i=n-1;
  while (a[i]==a[n-1]){
    b++;
    i--;
  }
  i=0;
  while(a[i] == a[0])
  {
    c++;
    i++;
  }
  if(a[0] == a[n-1])
  printf("%I64d %I64d",0,(n*n-1)/2);
  else
  printf("%I64d %I64d",a[n-1]-a[0],b*c);
}


#include<stdio.h>
#include<stdlib.h>
int comp(const void* a, const void* b)
{
  return *(int *)a - *(int *)b;
}
int main()
{
  int n;
  scanf("%d",&n);
  int i,a[n],b=0,c=0;
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),comp);
  i=n-1;
  while (a[i]==a[n-1]){
    b++;
    i--;
  }
  i=0;
  while(a[i] == a[0])
  {
    c++;
    i++;
  }
  printf("%d %d",a[n-1]-a[0],b*c);
}


#include<stdio.h>
#include<stdlib.h>
int comp(const void* a, const void* b)
{
  return *(int *)a - *(int *)b;
}
int main()
{
  __int64 n;
  scanf("%I64d",&n);
  __int64 i,a[n],b=0,c=0;
  for(i=0;i<n;i++)
  {
    scanf("%I64d",&a[i]);
  }
  qsort(a,n,sizeof(__int64),comp);
  i=n-1;
  while (a[i]==a[n-1]){
    b++;
    i--;
  }
  i=0;
  while(a[i] == a[0])
  {
    c++;
    i++;
  }
  printf("%I64d %I64d",a[n-1]-a[0],b*c);
}


#include<stdio.h>

int main() {
  long long int n,dif;
  scanf("%lld",&n);
  long long int i,j,a[n],temp;
  for(i=0;i<n;i++)
  scanf("%lld ",&a[i]);
  long long int max,min;
  max=a[0];
  min=a[0];
  long long int x=0;
  long long int y=0;
  for(i=1;i<n;i++)
  {
      if(max<a[i])
      {
            max=a[i];
      }
      if(min>a[i])
      {
          min=a[i];
      }
  }
  for(i=0;i<n;i++)
  {
      if(max==a[i])
      {
          x++;
      }
      if(min==a[i])
      {
          y++;
      }
  }
  if(max!=min)
  printf("%lld %lld",max-min,x*y);
  else if(max==min)
  printf("%lld %lld",max-min,((n*(n-1))/2));
}


#include<stdio.h>

int main() {
  long long int n,dif;
  scanf("%lld",&n);
  long long int i,j,a[n],temp;
  for(i=0;i<n;i++)
  scanf("%lld ",&a[i]);
  for(i=0;i<n;i++)
  for(j=i+1;j<n;j++)
  if(a[i]>a[j])
  {temp=a[i];
  a[i]=a[j];
  a[j]=temp; }
  dif=a[n-1]-a[0];
  printf("%d",dif);
  long long int x=1;
  long long int y=1;
  for(i=1;i<n;i++)
  {
      if(a[0]==a[i])
      {
          x++;
      }
  }
  for(j=0;j<(n-1);j++)
  {
      if(a[n-1]==a[j])
      {
          y++;
      }
  }
  printf(" %lld",x*y);
}


#include<stdio.h>

int main() {
  long long int n,dif;
  scanf("%lld",&n);
  long long int i,j,a[n],temp;
  for(i=0;i<n;i++)
  scanf("%lld ",&a[i]);
  long long int max,min;
  max=a[0];
  min=a[0];
  long long int x=0;
  long long int y=0;
  for(i=1;i<n;i++)
  {
      if(max<a[i])
      {
            max=a[i];
      }
      if(min>a[i])
      {
          min=a[i];
      }
  }
  for(i=0;i<n;i++)
  {
      if(max==a[i])
      {
          x++;
      }
      if(min==a[i])
      {
          y++;
      }
  }
  printf("%lld",x*y);
}


#include<stdio.h>

int main() {
  long long int n,dif;
  scanf("%lld",&n);
  long long int i,j,a[n],temp;
  for(i=0;i<n;i++)
  scanf("%lld ",&a[i]);
  for(i=0;i<n;i++)
  for(j=i+1;j<n;j++)
  if(a[i]>a[j])
  {temp=a[i];
  a[i]=a[j];
  a[j]=temp; }
  dif=a[n-1]-a[0];
  printf("%d",dif);
  long long int x=1;
  long long int y=1;
  for(i=1;i<n;i++)
  {
      if(a[0]==a[i])
      {
          x++;
      }
  }
  for(j=0;j<(n-1);j++)
  {
      if(a[n-1]==a[i])
      {
          y++;
      }
  }
  printf(" %lld",x*y);
}


#include<stdio.h>

int main() {
  long long int n,dif;
  scanf("%lld",&n);
  long long int i,j,a[n],temp;
  for(i=0;i<n;i++)
  scanf("%lld ",&a[i]);
  long long int max,min;
  max=a[0];
  min=a[0];
  long long int x=0;
  long long int y=0;
  for(i=1;i<n;i++)
  {
      if(max<a[i])
      {
            max=a[i];
      }
      if(min>a[i])
      {
          min=a[i];
      }
  }
  for(i=0;i<n;i++)
  {
      if(max==a[i])
      {
          x++;
      }
      if(min==a[i])
      {
          y++;
      }
  }
  printf("%lld %lld",max,x*y);
}


#include <bits/stdc++.h>
using namespace std;

//0 — black, 1 — red, 2 — blue
#define MAXLEN 705
#define MOD 1000000007

int len, pairing[MAXLEN];
long long dp[MAXLEN][MAXLEN][3][3] = {0};
char str[MAXLEN];

void dfs(int l, int r)
{
    if (l + 1 == r)
    {
        dp[l][r][0][1] = dp[l][r][0][2] = dp[l][r][1][0] = dp[l][r][2][0] = 1;
        return;
    }
    if (pairing[l] == r)
    {
        dfs(l + 1, r - 1);
        for (int i = 0; i <= 2; i++)
            for (int j = 0; j <= 2; j++)
            {
                if (j != 1)
                    dp[l][r][0][1] = (dp[l][r][0][1] + dp[l + 1][r - 1][i][j]) % MOD;
                if (j != 2)
                    dp[l][r][0][2] = (dp[l][r][0][2] + dp[l + 1][r - 1][i][j]) % MOD;
                if (i != 1)
                    dp[l][r][1][0] = (dp[l][r][1][0] + dp[l + 1][r - 1][i][j]) % MOD;
                if (i != 2)
                    dp[l][r][2][0] = (dp[l][r][2][0] + dp[l + 1][r - 1][i][j]) % MOD;
            }
        return;
    }
    dfs(l, pairing[l]), dfs(pairing[l] + 1, r); //注意不是 dfs(pairing[r], r) ，反例如 ()()()
    for (int i = 0; i <= 2; i++)
        for (int j = 0; j <= 2; j++)
            for (int k = 0; k <= 2; k++)
                for (int h = 0; h <= 2; h++)
                {
                    if (j != 0 && j == k) //紧挨着的两个括号都上过色且颜色一样
                        continue;
                    dp[l][r][i][h] = (dp[l][r][i][h] + dp[l][pairing[l]][i][j] * dp[pairing[l] + 1][r][k][h] % MOD) % MOD;
                }
}

int main()
{
    scanf("%705s", str);
    len = strlen(str);
    stack<int> sta;
    for (int i = 0; i < len; i++)
        if (str[i] == '(')
            sta.push(i);
        else
        {
            pairing[sta.top()] = i;
            pairing[i] = sta.top();
            sta.pop();
        }
    dfs(0, len - 1);
    int ans = 0;
    for (int i = 0; i <= 2; i++)
        for (int j = 0; j <= 2; j++)
            ans = (ans + dp[0][len - 1][i][j]) % MOD;
    printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//0 — black, 1 — red, 2 — blue
#define MAXLEN 705
#define MOD 1000000007

int len, pairing[MAXLEN];
long long dp[MAXLEN][MAXLEN][3][3];
char str[MAXLEN];

void dfs(int l, int r)
{
    if (l + 1 == r)
    {
        dp[l][r][0][1] = dp[l][r][0][2] = dp[l][r][1][0] = dp[l][r][2][0] = 1;
        return;
    }
    if (pairing[l] == r)
    {
        dfs(l + 1, r - 1);
        for (int i = 0; i <= 2; i++)
            for (int j = 0; j <= 2; j++)
            {
                if (j != 1)
                    dp[l][r][0][1] = (dp[l][r][0][1] + dp[l + 1][r - 1][i][j]) % MOD;
                if (j != 2)
                    dp[l][r][0][2] = (dp[l][r][0][2] + dp[l + 1][r - 1][i][j]) % MOD;
                if (i != 1)
                    dp[l][r][1][0] = (dp[l][r][1][0] + dp[l + 1][r - 1][i][j]) % MOD;
                if (i != 2)
                    dp[l][r][2][0] = (dp[l][r][2][0] + dp[l + 1][r - 1][i][j]) % MOD;
            }
        return;
    }
    dfs(l, pairing[l]), dfs(pairing[r], r);
    for (int i = 0; i <= 2; i++)
        for (int j = 0; j <= 2; j++)
            for (int k = 0; k <= 2; k++)
                for (int h = 0; h <= 2; h++)
                {
                    if (j != 0 && j == k) //紧挨着的两个括号都上过色且颜色一样
                        continue;
                    dp[l][r][i][h] = (dp[l][r][i][h] + dp[l][pairing[l]][i][j] * dp[pairing[r]][r][k][h] % MOD) % MOD;
                }
}

int main()
{
    scanf("%705s", str);
    len = strlen(str);
    stack<int> sta;
    for (int i = 0; i < len; i++)
        if (str[i] == '(')
            sta.push(i);
        else
        {
            pairing[sta.top()] = i;
            pairing[i] = sta.top();
            sta.pop();
        }
    dfs(0, len - 1);
    int ans = 0;
    for (int i = 0; i <= 2; i++)
        for (int j = 0; j <= 2; j++)
            ans = (ans + dp[0][len - 1][i][j]) % MOD;
    printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
#define int long long
using namespace std;
const int mod=998244535;
char a[1001];
int len,mat[1001],d[1001][1001][3][3],ans;
stack<int>s;
inline void dp(int i,int j){
	if (i+1==j){for (register int k=1;k<=2;k++) d[i][j][k][0]=d[i][j][0][k]=1;return;}
	if (mat[i]==j)
	{
		dp(i+1,j-1);
		for (register int u=0;u<=2;u++)
			for (register int v=0;v<=2;v++)
			{
				if (u!=1) d[i][j][1][0]+=d[i+1][j-1][u][v],d[i][j][1][0]%=mod;
				if (v!=1) d[i][j][0][1]+=d[i+1][j-1][u][v],d[i][j][0][1]%=mod;
				if (u!=2) d[i][j][2][0]+=d[i+1][j-1][u][v],d[i][j][2][0]%=mod;
				if (v!=2) d[i][j][0][2]+=d[i+1][j-1][u][v],d[i][j][0][2]%=mod;
			}
		return ;
	}
	int p=mat[i];
	dp(i,p);dp(p+1,j);
	for (register int m=0;m<=2;m++)
	  for (register int n=0;n<=2;n++)
		for (register int u=0;u<=2;u++)
		  for (register int v=0;v<=2;v++)
			if (!((u==1&&v== 1)||(u==2&&v==2)))
			d[i][j][m][n]+=d[i][p][m][u]*d[p+1][j][v][n],d[i][j][m][n]%=mod;
}
inline void use()
{
	cin>>a;
	len=strlen(a)-1;
	for (register int i=0;i<=len;i++)
		if (a[i]=='(') s.push(i);
		else
		{
			mat[i]=s.top();
			mat[s.top()]=i;
			s.pop();
		}
	dp(0,len);ans=0;
	for (register int i=0;i<=2;i++)
		for (register int j=0;j<=2;j++)
			ans+=d[0][len][i][j],ans%=mod;
	cout<<ans<<endl;
}
signed main()
{
	int t;
	scanf("%lld",&t);
	while(t--) use();
}


#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
#define int long long
using namespace std;
const int mod=998244535;
char a[1001];
int len,mat[1001],d[1001][1001][3][3],ans;
stack<int>s;
inline void dp(int i,int j){
	if (i+1==j){for (register int k=1;k<=2;k++) d[i][j][k][0]=d[i][j][0][k]=1;return;}
	if (mat[i]==j)
	{
		dp(i+1,j-1);
		for (register int u=0;u<=2;u++)
			for (register int v=0;v<=2;v++)
			{
				if (u!=1) d[i][j][1][0]+=d[i+1][j-1][u][v],d[i][j][1][0]%=mod;
				if (v!=1) d[i][j][0][1]+=d[i+1][j-1][u][v],d[i][j][0][1]%=mod;
				if (u!=2) d[i][j][2][0]+=d[i+1][j-1][u][v],d[i][j][2][0]%=mod;
				if (v!=2) d[i][j][0][2]+=d[i+1][j-1][u][v],d[i][j][0][2]%=mod;
			}
		return ;
	}
	int p=mat[i];
	dp(i,p);dp(p+1,j);
	for (register int m=0;m<=2;m++)
	  for (register int n=0;n<=2;n++)
		for (register int u=0;u<=2;u++)
		  for (register int v=0;v<=2;v++)
			if (!((u==1&&v== 1)||(u==2&&v==2)))
			d[i][j][m][n]+=d[i][p][m][u]*d[p+1][j][v][n],d[i][j][m][n]%=mod;
}
inline void use()
{
	cin>>a;
	len=strlen(a)-1;
	for (register int i=0;i<=len;i++)
		if (a[i]=='(') s.push(i);
		else
		{
			mat[i]=s.top();
			mat[s.top()]=i;
			s.pop();
		}
	dp(0,len);ans=0;
	for (register int i=0;i<=2;i++)
		for (register int j=0;j<=2;j++)
			ans+=d[0][len][i][j],ans%=mod;
	cout<<ans<<endl;
}
signed main()
{
	/*int t;
	scanf("%lld",&t);
	while(t--) */use();
}


#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
#define int long long
using namespace std;
const int mod=1e9+7;
char a[1001];
int len,mat[1001],d[1001][1001][3][3],ans;
stack<int>s;
inline void dp(int i,int j){
	if (i+1==j){for (register int k=1;k<=2;k++) d[i][j][k][0]=d[i][j][0][k]=1;return;}
	if (mat[i]==j)
	{
		dp(i+1,j-1);
		for (register int u=0;u<=2;u++)
			for (register int v=0;v<=2;v++)
			{
				if (u!=1) d[i][j][1][0]+=d[i+1][j-1][u][v],d[i][j][1][0]%=mod;
				if (v!=1) d[i][j][0][1]+=d[i+1][j-1][u][v],d[i][j][0][1]%=mod;
				if (u!=2) d[i][j][2][0]+=d[i+1][j-1][u][v],d[i][j][2][0]%=mod;
				if (v!=2) d[i][j][0][2]+=d[i+1][j-1][u][v],d[i][j][0][2]%=mod;
			}
		return;
	}
	int p=mat[i];
	dp(i,p);dp(p+1,j);
	for (register int m=0;m<=2;m++)
	  for (register int n=0;n<=2;n++)
		for (register int u=0;u<=2;u++)
		  for (register int v=0;v<=2;v++)
			if (!((u==1&&v==1)||(u==2&&v==2)))
			d[i][j][m][n]+=d[i][p][m][u]*d[p+1][j][v][n],d[i][j][m][n]%=mod;
}
inline void use()
{
	cin>>a;
	len=strlen(a)-1;
	for (register int i=0;i<=len;i++)
		if (a[i]=='(') s.push(i);
		else
		{
			mat[i]=s.top();
			mat[s.top()]=i;
			s.pop();
		}
	dp(0,len);ans=0;
	for (register int i=0;i<=2;i++)
		for (register int j=0;j<=2;j++)
			ans+=d[0][len][i][j],ans%=mod;
	cout<<ans<<endl;
}
signed main()
{
	/*int t;
	scanf("%lld",&t);
	for (int w=1;w<=t;w++) */use();
}


#include<bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
char c[1010];
int nxt[1010];
stack<int> st;
ll dp[1010][1010][3][3];
void dg(int l,int r){
	if(l+1==r){
		dp[l][r][0][2]=dp[l][r][2][0]=dp[l][r][1][0]=dp[l][r][0][1]=1;
	}
	else if(nxt[l]==r){
		dg(l+1,r-1);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(i==k && i!=0 || j==ll && j!=0) continue;
						if(i==0 && j==0 || i!=0 && j!=0) continue;
						dp[l][r][i][j]=(dp[l][r][i][j]+dp[l+1][r-1][k][ll])%998244535;
					}
				}
			}
		}
	}
	else{
		dg(l,nxt[l]);
		dg(nxt[l]+1,r);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(k!=0 && k==ll) continue;
						dp[l][r][i][j]=(dp[l][r][i][j]+dp[l][nxt[l]][i][k]*dp[nxt[l]+1][r][ll][j])%998244535;
					}
				}
			}
		}
	}
}
int main(){
	int nn;
	cin>>nn;
	while(nn--){
		memset(nxt,0,sizeof(nxt));
		memset(dp,0,sizeof(dp));
		cin>>c+1;
		int len=strlen(c+1);
		for(int i=1;i<=len;i++){
			if(c[i]=='(') st.push(i);
			else{
				nxt[st.top()]=i;
				st.pop();
			}
		}
		dg(1,len);
		ll ans=dp[1][len][0][0]+dp[1][len][0][1]+dp[1][len][0][2]+dp[1][len][1][0]+dp[1][len][1][1]+dp[1][len][1][2]+dp[1][len][2][0]+dp[1][len][2][1]+dp[1][len][2][2];
		cout<<ans%998244535<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
char c[1010];
int nxt[1010];
stack<int> st;
ll dp[1010][1010][3][3];
void dg(int l,int r){
	if(l+1==r){
		dp[l][r][0][2]=dp[l][r][2][0]=dp[l][r][1][0]=dp[l][r][0][1]=1;
	}
	else if(nxt[l]==r){
		dg(l+1,r-1);

		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(i==k && i!=0 || j==ll && j!=0) continue;
						if(i==j || i==1 && j==2 || i==2 && j==1) continue;
						dp[l][r][i][j]+=dp[l+1][r-1][k][ll];
					}
				}
			}
		}
	}
	else{
		dg(l,nxt[l]);
		dg(nxt[l]+1,r);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(k!=0 && k==ll) continue;
						dp[l][r][i][j]+=dp[l][nxt[l]][i][k]*dp[nxt[l]+1][r][ll][j];
					}
				}
			}
		}
	}
}
int main(){
	cin>>c+1;
	int len=strlen(c+1);
	for(int i=1;i<=len;i++){
		if(c[i]=='(') st.push(i);
		else{
			nxt[st.top()]=i;
			st.pop();
		}
	}
	dg(1,len);
	cout<<dp[1][len][0][0]+dp[1][len][0][1]+dp[1][len][0][2]+
	dp[1][len][1][0]+dp[1][len][1][1]+dp[1][len][1][2]+
	dp[1][len][2][0]+dp[1][len][2][1]+dp[1][len][2][2]<<endl;
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
char c[1010];
int nxt[1010];
stack<int> st;
ll dp[1010][1010][3][3];
void dg(int l,int r){
	if(l+1==r){
		dp[l][r][0][2]=dp[l][r][2][0]=dp[l][r][1][0]=dp[l][r][0][1]=1;
	}
	else if(nxt[l]==r){
		dg(l+1,r-1);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(i==k && i!=0 || j==ll && j!=0) continue;
						if(i==0 && j==0 || i!=0 && j!=0) continue;
						dp[l][r][i][j]=(dp[l][r][i][j]+dp[l+1][r-1][k][ll])%998244535;
					}
				}
			}
		}
	}
	else{
		dg(l,nxt[l]);
		dg(nxt[l]+1,r);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(k!=0 && k==ll) continue;
						dp[l][r][i][j]=(dp[l][r][i][j]+dp[l][nxt[l]][i][k]*dp[nxt[l]+1][r][ll][j])%998244535;
					}
				}
			}
		}
	}
}
int main(){
	cin>>c+1;
	int len=strlen(c+1);
	for(int i=1;i<=len;i++){
		if(c[i]=='(') st.push(i);
		else{
			nxt[st.top()]=i;
			st.pop();
		}
	}
	dg(1,len);
	ll ans=dp[1][len][0][0]+dp[1][len][0][1]+dp[1][len][0][2]+dp[1][len][1][0]+dp[1][len][1][1]+dp[1][len][1][2]+dp[1][len][2][0]+dp[1][len][2][1]+dp[1][len][2][2];
	cout<<ans%998244535<<endl;
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
char c[1010];
int nxt[1010];
stack<int> st;
ll dp[1010][1010][3][3];
const ll mod=1e9+7;
void dg(int l,int r){
	if(l+1==r){
		dp[l][r][0][2]=dp[l][r][2][0]=dp[l][r][1][0]=dp[l][r][0][1]=1;
	}
	else if(nxt[l]==r){
		dg(l+1,r-1);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(i==k && i!=0 || j==ll && j!=0) continue;
						if(i==0 && j==0 || i!=0 && j!=0) continue;
						dp[l][r][i][j]=(dp[l][r][i][j]+dp[l+1][r-1][k][ll])%mod;
					}
				}
			}
		}
	}
	else{
		dg(l,nxt[l]);
		dg(nxt[l]+1,r);
		for(int i=0;i<=2;i++){
			for(int j=0;j<=2;j++){
				for(int k=0;k<=2;k++){
					for(int ll=0;ll<=2;ll++){
						if(k!=0 && k==ll) continue;
						dp[l][r][i][j]=(dp[l][r][i][j]+dp[l][nxt[l]][i][k]*dp[nxt[l]+1][r][ll][j])%mod;
					}
				}
			}
		}
	}
}
int main(){
	cin>>c+1;
	int len=strlen(c+1);
	for(int i=1;i<=len;i++){
		if(c[i]=='(') st.push(i);
		else{
			nxt[st.top()]=i;
			st.pop();
		}
	}
	dg(1,len);
	ll ans=dp[1][len][0][0]+dp[1][len][0][1]+dp[1][len][0][2]+dp[1][len][1][0]+dp[1][len][1][1]+dp[1][len][1][2]+dp[1][len][2][0]+dp[1][len][2][1]+dp[1][len][2][2];
	cout<<ans%mod<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
typedef long long ll;
const int N = 710;
const ll mod = 1e9 + 7;
bool g[N][N];
//g[i][j]代表i，j是否匹配
ll dp[N][N][3][3];
//dp[i][j][k][l]代表区间[i,j]，i染颜色k，j染颜色l的方案数
//0: 不染色；1：红色；2：蓝色
int n;
ll ans;
char s[N];
stack<int> stk;
int match[N];
void work(ll &x, ll y) {
	x = (x + y) % mod;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) {
		if (s[i] == '(') stk.push(i);
		else g[stk.top()][i] = 1, match[stk.top()] = i, stk.pop();
		dp[i][i][0][0] = 1;
		dp[i][i][1][1] = 1;
		dp[i][i][2][2] = 1;
	}
	for (int len = 2; len <= n; len++) {
		for (int i = 1; i + len - 1 <= n; i++) {
			int j = i + len - 1;
			if (g[i][j]) {
				if (len > 2) {
					for (int l = 0; l < 3; l++) {
						for (int k = 0; k < 3; k++) {
							if (k != 1) work(dp[i][j][0][1], dp[i + 1][j - 1][l][k]);
							if (k != 2) work(dp[i][j][0][2], dp[i + 1][j - 1][l][k]);
							if (l != 1) work(dp[i][j][1][0], dp[i + 1][j - 1][l][k]);
							if (l != 2) work(dp[i][j][2][0], dp[i + 1][j - 1][l][k]);
						}
					}
				} else {
					dp[i][j][1][0] = 1;
					dp[i][j][2][0] = 1;
					dp[i][j][0][1] = 1;
					dp[i][j][0][2] = 1;
				}
			} else {
				for (int l = 0; l < 3; l++) {
					for (int k = 0; k < 3; k++) {
						for (int p = 0; p < 3; p++) {
							for (int q = 0; q < 3; q++) {
								if (p == q && p != 0) continue;
								work(dp[i][j][l][k], dp[i][match[i]][l][p] * dp[match[i] + 1][j][q][k] % mod);
							}
						}
					}
				}
			}
		}
	}
	for (int l = 0; l < 3; l++) {
		for (int k = 0; k < 3; k++) {
			work(ans, dp[1][n][l][k]);
		}
	}
	printf("%lld", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
const int N = 710;
const int mod = 1e9 + 7;
bool g[N][N];
//g[i][j]代表i，j是否匹配
int dp[N][N][3][3];
//dp[i][j][k][l]代表区间[i,j]，i染颜色k，j染颜色l的方案数
//0: 不染色；1：红色；2：蓝色
int n;
int ans;
char s[N];
stack<int> stk;
int match[N];
void work(int &x, int y) {
	x = (x + y) % mod;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) {
		if (s[i] == '(') stk.push(i);
		else g[stk.top()][i] = 1, match[stk.top()] = i, stk.pop();
		dp[i][i][0][0] = 1;
		dp[i][i][1][1] = 1;
		dp[i][i][2][2] = 1;
	}
	for (int len = 2; len <= n; len++) {
		for (int i = 1; i + len - 1 <= n; i++) {
			int j = i + len - 1;
			if (g[i][j]) {
				if (len > 2) {
					for (int l = 0; l < 3; l++) {
						for (int k = 0; k < 3; k++) {
							if (k != 1) work(dp[i][j][0][1], dp[i + 1][j - 1][l][k]);
							if (k != 2) work(dp[i][j][0][2], dp[i + 1][j - 1][l][k]);
							if (l != 1) work(dp[i][j][1][0], dp[i + 1][j - 1][l][k]);
							if (l != 2) work(dp[i][j][2][0], dp[i + 1][j - 1][l][k]);
						}
					}
				} else {
					dp[i][j][1][0] = 1;
					dp[i][j][2][0] = 1;
					dp[i][j][0][1] = 1;
					dp[i][j][0][2] = 1;
				}
			} else if (match[i]) {
				for (int l = 0; l < 3; l++) {
					for (int k = 0; k < 3; k++) {
						for (int p = 0; p < 3; p++) {
							for (int q = 0; q < 3; q++) {
								if (p == q && p != 0) continue;
								work(dp[i][j][l][k], dp[i][match[i]][l][p] * dp[match[i] + 1][j][q][k] % mod);
							}
						}
					}
				}
			}
		}
	}
	for (int l = 0; l < 3; l++) {
		for (int k = 0; k < 3; k++) {
			work(ans, dp[1][n][l][k]);
		}
	}
	printf("%d", ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
using namespace std;
typedef long long ll;
const int N = 710;
const ll mod = 1e9 + 7;
bool g[N][N];
//g[i][j]����i��j�Ƿ�ƥ��
ll dp[N][N][3][3];
//dp[i][j][k][l]��������[i,j]��iȾ��ɫk��jȾ��ɫl�ķ�����
//0: ��Ⱦɫ��1����ɫ��2����ɫ
int n;
ll ans;
char s[N];
stack<int> stk;
int match[N];
void work(ll &x, ll y) {
	x = (x + y) % mod;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) {
		if (s[i] == '(') stk.push(i);
		else g[stk.top()][i] = 1, match[stk.top()] = i, stk.pop();
		dp[i][i][0][0] = 1;
		dp[i][i][1][1] = 1;
		dp[i][i][2][2] = 1;
	}
	for (int len = 2; len <= n; len++) {
		for (int i = 1; i + len - 1 <= n; i++) {
			int j = i + len - 1;
			if (s[i] != '(' || s[j] != ')') continue;
			if (g[i][j]) {
				if (len > 2) {
					for (int l = 0; l < 3; l++) {
						for (int k = 0; k < 3; k++) {
							if (k != 1) work(dp[i][j][0][1], dp[i + 1][j - 1][l][k]);
							if (k != 2) work(dp[i][j][0][2], dp[i + 1][j - 1][l][k]);
							if (l != 1) work(dp[i][j][1][0], dp[i + 1][j - 1][l][k]);
							if (l != 2) work(dp[i][j][2][0], dp[i + 1][j - 1][l][k]);
						}
					}
				} else {
					dp[i][j][1][0] = 1;
					dp[i][j][2][0] = 1;
					dp[i][j][0][1] = 1;
					dp[i][j][0][2] = 1;
				}
			} else {
				for (int l = 0; l < 3; l++) {
					for (int k = 0; k < 3; k++) {
						for (int p = 0; p < 3; p++) {
							for (int q = 0; q < 3; q++) {
								if (p == q && p != 0) continue;
								work(dp[i][j][l][k], dp[i][match[i]][l][p] * dp[match[i] + 1][j][q][k] % mod);
							}
						}
					}
				}
			}
		}
	}
	for (int l = 0; l < 3; l++) {
		for (int k = 0; k < 3; k++) {
			work(ans, dp[1][n][l][k]);
		}
	}
	printf("%lld", ans);
	return 0;
}