10
-405 -230 252 -393 -390 -259 97 163 81 -129
 3
10000 -10000 10000
 1
-10000
 20
-16 -23 29 44 -40 -50 -41 34 -38 30 -12 28 -44 -49 15 50 -28 38 -2 0

702.333333333333712
 10000.000000000016371
 0.000000000000000
 113.875000000000043

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n;
		cin>>n;
		double sum=0;
		vector<double> a(n),b(n);
		fi(0,n) 
		{
			cin>>a[i];
			sum+=a[i];
			b[i]=a[i];
		}
		sort(b.begin(),b.end());
		double value=sum/n;
		double ans=0;
		bool pos=false;
		sum=0;
		fi(0,n)
		{
			a[i]=a[i]-value;
			if(a[i]>0.0)
			{
				if(!pos)
				{
					sum=0;
				}
				pos=true;
				sum+=a[i];
			}
			else
			{
				if(pos)
				{
					sum=0;
				}
				pos=false;
				sum+=abs(a[i]);
			}
			ans=max(ans,sum);
		}
		cout<<setprecision(7)<<ans;
		
	}
}
