Reading integers from a file and counting the length of a descending subsequence
int main() returns an int so instead of exit(0); write return 0; at the end of main, it is more natural. exit is more something you would use to panically exit a program. 

When you write the file xxx.out, you don't check if opening the file succeeded, it always good to check return values of all runtime functions like you do when you read the other file.

Initialize all variables when you declare them to avoid any surprises. You have in some cases declared the variables where you use them, that is good. You should do that with all variable declarations instead of at top of main.

Check return value of fscanf() to see if it correctly got a number. I personally prefer fgets/sscanf when reading from file/stdin but that is me.

Maybe you could separate the functionality into some smaller functions e.g. readFile, writeFile and calculateTotal. It is a good habit to learn because programs have a tendency to grow with time, although for this particular case it may be overkill.

Another good habit is to write "why" comments, but I guess in this particular case it is quite self-evident what it does, although maybe a mention of the file format expected in the header of the program would be helpful for another programmer. :)

You could add some error messages to stderr when something is wrong instead of silently quitting, it makes troubleshooting easier e.g. 

fprintf(stderr, "invalid size %d", size);