fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. const long double PI = 3.14159265359;
  7.  
  8. void solve()
  9. {
  10. int n;
  11. cin >> n;
  12. vector<int> arr(n);
  13. for (auto &val : arr)
  14. cin >> val;
  15. if (count(arr.begin(), arr.end(), 9) == 0)
  16. cout << -1 << '\n';
  17. else
  18. cout << *min_element(arr.begin(), arr.end()) << '\n';
  19. }
  20.  
  21. signed main(void)
  22. {
  23. ios_base::sync_with_stdio(0);
  24. cin.tie(0);
  25. cout.tie(0);
  26. if (fopen("input.txt", "r"))
  27. {
  28. freopen("input.txt", "r", stdin);
  29. freopen("output.txt", "w", stdout);
  30. }
  31. int t = 1;
  32. // cin >> t;
  33. while (t--)
  34. {
  35. solve();
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5348KB
stdin
5
6 4 2 9 8
stdout
2