fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n,i,max=0,min=1000,a;
  5. scanf("%d",&n);
  6. for(i=1;i<=n;i++){
  7. scanf("%d",&a);
  8. if(a>max){
  9. max=a;
  10. }
  11. if(a<min){
  12. min=a;
  13. }
  14. }
  15. printf("%d",max-min);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0.01s 5276KB
stdin
6
3 0 8 7 5 9
stdout
9