unittest
{
	assert( [ "3", "1 2 3" ].parse.expand.solve == 1 );
	assert( [ "4", "2 5 2 5" ].parse.expand.solve == 0 );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto m = as.sum;		// 割って平均値にすると誤差が出るので割らない
	auto d = long.max;
	auto ans = 0L;
	foreach( i, a; as )
	{
		auto d2 = abs( m - a * as.length.signed );		// mを割らない代わりにaを掛ける
		if( d <= d2 ) continue;
		d = d2;
		ans = i;
	}
	return ans;
}
