// Guide to Java
// Copyright 2014, by J.T. Streib and T. Soma

import java.util.*;

public class StandardDeviation {
 public static void main(String[] args){        
    //declaration of variables
    int[] data;
    double sigma;
      
    // input data
    data = getData();
      
    // compute standard deviation
    sigma = computeStdDev(data);

    // output standard deviation
    outputStdDev(sigma);
 }
  
 // input data
 public static int[] getData() {
    Scanner scanner = new Scanner(System.in);
    int size;
    int[] array;
     
    // input number of data
    System.out.print("Enter the number of data: ");
    size = scanner.nextInt();
     
    // create array
    array = new int[size];
     
    // initialize array
    for(int i=0; i<size; i++) {
       System.out.print("Enter the data " + (i+1) + ": ");
       array[i] = scanner.nextInt();  
    }
      
    return array;
 }
  
 // compute standard deviation
 public static double computeStdDev(int[] array) {
    double total, mean, variance, sigma;
      
    // calculate mean
    total = 0;
    for(int i=0; i<array.length; i++)
       total = total + array[i];
    mean = total/array.length;
              
    // square each of the differences and add them
    total = 0;
    for(int i=0; i<array.length; i++)
       total = total + Math.pow(array[i] - mean, 2);
      
    // find variance by dividing by number of items
    variance = total/array.length;
      
    // find standard deviation by taking square root of variance
    sigma = Math.sqrt(variance);

    return sigma;
 }
  
 // output standard deviation
 public static void outputStdDev(double sigma) {
    System.out.printf("Standard deviation: %.2f", sigma);
    System.out.println();
 }
}