fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, p;
  6. cin>>p;
  7. int min = 100;
  8. int max = -100;
  9. for (int i = 0; i < p; i++){
  10. cin>>n;
  11. if(n < min){
  12. min = n;
  13. }
  14. if(n > max){
  15. max = n;
  16. }
  17. }
  18. cout<<min + max;
  19. return 0;
  20. }
Success #stdin #stdout 0s 15232KB
stdin
4
1 2 3 4
stdout
5