Codeforces round #590 (div3)

Problem Link: Problem - A - Codeforces
my solution: K9ayrX - Online C++ Compiler & Debugging Tool - Ideone.com
my solution is running on other compilers but not accepting on codeforces , why?

its giving error like this given below:

Invocation failed [COMPILATION_ERROR]
Can’t compile file:
program.cpp
program.cpp(12): error C2131: expression did not evaluate to a constant
program.cpp(12): note: failure was caused by a read of a variable outside its lifetime
program.cpp(12): note: see usage of ‘n’
program.cpp(13): warning C4552: ‘>>’: operator has no effect; expected operator with side-effect
program.cpp(17): warning C4552: ‘<<’: operator has no effect; expected operator with side-effect
program.cpp(21): warning C4552: ‘<<’: operator has no effect; expected operator with side-effect

=====
Used: 0 ms, 0 KB

@ujjwalgupta303 at line number 17 in your code, for n==2, it will print a[2/2+1] which is a[2] which is inaccessible. I think the error is occuring there only .
Also the approach is wrong. The minimum value can be other than array elements as well.

I dont know he is taking the average!