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

Measured memory_bytes: 128