#include <stdio.h>                                                                                                                                                                                                                
#include <stdlib.h>                                                                                                                                                                                                               
                                                                                                                                                                                                                                  
int cmp(const void *a, const void *b)                                                                                                                                                                                             
{                                                                                                                                                                                                                                 
        int x = *((int *)a);                                                                                                                                                                                                      
        int y = *((int *)b);                                                                                                                                                                                                      
                                                                                                                                                                                                                                  
        if (x < y) {                                                                                                                                                                                                               
                return -1;                                                                                                                                                                                                        
        } else if (x == y) {                                                                                                                                                                                                      
                return 0;                                                                                                                                                                                                         
        } else {                                                                                                                                                                                                                  
                return 1;                                                                                                                                                                                                         
        }                                                                                                                                                                                                                         
}                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                  
int main(void)                                                                                                                                                                                                                    
{                                                                                                                                                                                                                                  
        int num, *list, i;                                                                                                                                                                                                         
                                                                                                                                                                                                                                   
        scanf("%d", &num);                                                                                                                                                                                                         
        list = calloc(sizeof(int), num);                                                                                                                                                                                           
        for (i = 0; i < num; i++) {                                                                                                                                                                                                
                scanf("%d", &list[i]);                                                                                                                                                                                            
        }                                                                                                                                                                                                                         
        qsort(list, num, sizeof(int), cmp);                                                                                                                                                                                       
                                                                                                                                                                                                                                  
        printf("%d\n", list[num - 1] - list[0]);                                                                                                                                                                                  
        return 0;                                                                                                                                                                                                                 
}

Measured memory_bytes: 128