You are saying min = sum - a[i] outside of the loop. After your second loop ends, it's condition, i < 10, is not true, so i = 10. So that line accesses a[10]. There is no a[10]. Valid indices for a are 0, ..., 9. Your program invokes undefined behavior.
It's also , not "stdio.h".
In general, if you are only going to need i inside the loop, in C++ and C99 you can say "for (int i = ... )", and the compiler will alert you if you are using i outside of the loop, because it won't be defined.