/*****************************************************************
** NumberStats - program to demonstrate arrays
**
** Numbers are read from the stdin until EOF is detected.  The
** numbers are stored in a array called 'numbers'.  Then, some
** basic statistics are computed, such as N (the number of
** numbers), the minimum, the maximum, the mean, and the
** standard deviation. The results are outputted to the console.
**
** Note: A constant MAX is defined to be the size of 'numbers'.
** The number of entries must be <= MAX.  A variable called 'size'
** is used to hold the actual number of entries.  Note that size
** is not the same as numbers.length (which equals the size of
** the array).
**
** (c) Scott MacKenzie, 2000                             
******************************************************************/
import java.io.*;
import java.util.*;

public class NumberStats
{
   private static final int MAX = 100; // maximum number of numbers

   public static void main(String[] args) throws IOException
   {
      BufferedReader stdin =
         new BufferedReader(new InputStreamReader(System.in), 1);

      double[] numbers = new double[MAX];
      int size = 0;

      // input data and put into array
      String line;
      while ((line = stdin.readLine()) != null)
      {
         // prepare to tokenize line
         StringTokenizer st = new StringTokenizer(line, " ,\t");

         // process tokens in line
         while (st.hasMoreTokens())
         {
            String s = st.nextToken();
            numbers[size] = Double.parseDouble(s);
            size++;
         }
      } 

      // output some statistics on the data
      System.out.println("N = " + size);
      System.out.println("Minimum = " + min(numbers, size));
      System.out.println("Maximum = " + max(numbers, size));
      System.out.println("Mean = " + mean(numbers, size));
      System.out.println("Standard deviation = " + sd(numbers, size));
   }

   // find the minimum value in an array
   public static double min(double[] n, int length)
   {
      double min = n[0];
      for (int j = 1; j < length; j++)
         if (n[j] < min)
            min = n[j];
      return min;
   }

   // find the maximum value in a array
   public static double max(double[] n, int length)
   {
      double max = n[0];
      for (int j = 1; j < length; j++)
         if (n[j] > max)
            max = n[j];
      return max;
   }

   // calculate the mean of the values in an array
   public static double mean(double n[], int length)
   {
      double mean = 0.0;
      for (int j = 0; j < length; j++)
         mean += n[j];   
      return mean / length;
   }

   // calculate the standard deviation of values in an array
   public static double sd(double[] n, int length)
   {
      double m = mean(n, length);
      double t = 0.0;
      for (int j = 0; j < length; j++)
         t += (m - n[j]) * (m - n[j]);
      return Math.sqrt(t / (length - 1.0));
   }

}

