// CodeForces (C++).cpp: определяет точку входа для консольного приложения.
//

//#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <cstdlib>

#define ll long long

using namespace std;

inline bool IsMemberOfArray(int t, int* a, int n)
{
	for (int i = 0; i < n; i++)
		if (a[i] == t)
			return true;
	return false;
}

int main()
{
	int n, a[3], k = 0;

	a[0] = a[1] = a[2] = -1;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;

		if (IsMemberOfArray(t, a, 3))
			continue;
		if (k < 3)
			a[k++] = t;
		else
		{
			cout << "NO";
			//system("pause");
			return 0;
		}
	}
	if (n < 3)
	{
		cout << "YES";
		//system("pause");
		return 0;
	}

	int min = 0;
	int max = 0;

	for (int i = 1; i < 3; i++)
	{
		if (a[i] > a[max])
			max = i;
		if (a[i] < a[min])
			min = i;
	}

	if (a[min] + a[max] == a[3 - min - max]*2)
		cout << "YES";
	else
		cout << "NO";

	//system("pause");
	return 0;
}


// CodeForces (C++).cpp: определяет точку входа для консольного приложения.
//

//#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <cstdlib>

#define ll long long

using namespace std;

inline bool IsMemberOfArray(int t, int* a, int n)
{
	for (int i = 0; i < n; i++)
		if (a[i] == t)
			return true;
	return false;
}

int main()
{
	int n, a[3], k = 0;

	a[0] = a[1] = a[2] = -1;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;

		if (IsMemberOfArray(t, a, 3))
			continue;
		if (k < 3)
			a[k++] = t;
		else
		{
			cout << "NO";
			//system("pause");
			return 0;
		}
	}
	if (n < 3 || k < 3)
	{
		cout << "YES";
		//system("pause");
		return 0;
	}

	int min = 0;
	int max = 0;

	for (int i = 1; i < 3; i++)
	{
		if (a[i] > a[max])
			max = i;
		if (a[i] < a[min])
			min = i;
	}

	if (a[min] + a[max] == a[3 - min - max]*2)
		cout << "YES";
	else
		cout << "NO";

	//system("pause");
	return 0;
}


// CodeForces (C++).cpp: определяет точку входа для консольного приложения.
//

#include "stdafx.h"
#include <iostream>
#include <math.h>
#include <cstdlib>

#define ll long long

using namespace std;

inline bool IsMemberOfArray(int t, int* a, int n)
{
	for (int i = 0; i < n; i++)
		if (a[i] == t)
			return true;
	return false;
}

int main()
{
	int n, a[3], k = 0;

	a[0] = a[1] = a[2] = -1;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;

		if (IsMemberOfArray(t, a, 3))
			continue;
		if (k < 3)
			a[k++] = t;
		else
		{
			cout << "NO";
			//system("pause");
			return 0;
		}
	}
	if (n < 3)
	{
		cout << "YES";
		//system("pause");
		return 0;
	}

	int min = 0;
	int max = 0;

	for (int i = 1; i < 3; i++)
	{
		if (a[i] > a[max])
			max = i;
		if (a[i] < a[min])
			min = i;
	}

	if (a[min] + a[max] == a[3 - min - max]*2)
		cout << "YES";
	else
		cout << "NO";

	//system("pause");
	return 0;
}


n = int(input())
arr = list(set(map(int, input().split())))
arr.sort()

mid = (arr[0] + arr[-1]) // 2
d = mid - arr[0]

if all(abs(arr[i] - mid) == d or arr[i] == mid for i in range(len(arr))):
    print("YES")
else:
    print("NO")


n = int(input())
arr = list(set(map(int, input().split())))
arr.sort()

if len(arr) <= 2 or (len(arr) == 3 and arr[1] - arr[0] == arr[2] - arr[1]):
    print("YES")
else:
    print("NO")


n=int(input())
l=list(set([int(x) for x in input().split()]))

print('YES' if len(l)<=2 else 'YES' if l[2]-l[1]==l[1]-l[0] and len(l)==3 else 'NO')


n=int(input())
l=sorted(set(map(int, input().split())))
print('YES' if len(l)<=2 or (l[2]-l[1]==l[1]-l[0] and len(l)==3) else 'NO')


n=int(input())
l=sorted(set([int(x) for x in input().split()]))
print('YES' if len(l)<=2 or (l[2]-l[1]==l[1]-l[0] and len(l)==3) else 'NO')


n=int(input())
l=list(set([int(x) for x in input().split()]))
l.sort()

print('YES' if len(l)<=2 else 'YES' if l[2]-l[1]==l[1]-l[0] and len(l)==3 else 'NO')


n=int(input())
l=list(set([int(x) for x in input().split()]))

if len(l)==3:
  l.sort()

print('YES' if len(l)<=2 else 'YES' if l[2]-l[1]==l[1]-l[0] and len(l)==3 else 'NO')


n=int(input())
l = input()
l = [int(i) for i in l.split()]
if len(set(l))>3 :
    print("NO")
else:
    b = sorted(set(l))
    if n==2:
        print("YES")

    elif abs(b[0] - b[1]) ==abs(b[1]-b[2]):
        print("YES")
    else:
        print("NO")


n=int(input())
l = input()
l = [int(i) for i in l.split()]
if n%2==0:
    print("NO")
else:
    l = set(l)

    t=0
    x=0
    for i in l :
        if t==n//2-1:
            x=i
            break
        t+=1
    if n==1:print("YES")
    elif n==2:
        print("NO")
    elif len(l)>3:
        print("NO")
    elif x-list(l)[0] == list(l)[2]-x:
        print("YES")


n=int(input())
l = input()
l = [int(i) for i in l.split()]
if n%2==0 and n==2:
    print("NO")
else:
    l = set(l)

    t=0
    x=0
    for i in l :
        if t==n//2-1:
            x=i
            break
        t+=1
    if n==1:print("YES")
    elif n==2:
        print("YES")
    elif len(l)>3:
        print("NO")
    elif x-list(l)[0] == list(l)[2]-x:
        print("YES")


n=int(input())
l = input()
l = [int(i) for i in l.split()]
if n%2==0 and n!=2:
    print("NO")
else:
    l = set(l)

    t=0
    x=0
    for i in l :
        if t==n//2-1:
            x=i
            break
        t+=1
    if n==1:print("YES")
    elif n==2:
        print("YES")
    elif len(l)>3:
        print("NO")
    elif x-list(l)[0] == list(l)[2]-x:
        print("YES")


n=int(input())
l = input()
l = [int(i) for i in l.split()]
if n%2==0:
    print("NO")
else:
    l = set(l)

    t=0
    x=0
    for i in l :
        if t==n//2-1:
            x=i
            break
        t+=1
    if n==1:print("YES")
    elif n==2:
        print("YES")
    elif len(l)>3:
        print("NO")
    elif x-list(l)[0] == list(l)[2]-x:
        print("YES")


n=int(input())
l = input()
l = [int(i) for i in l.split()]
if len(set(l))>3 :
    print("NO")
else:
    b = sorted(set(l))
    if len(b)==1 or len(b)==2:
        print("YES")
    elif n==2:
        print("YES")

    elif abs(b[0] - b[1]) ==abs(b[1]-b[2]):
        print("YES")
    else:
        print("NO")


input()
s='YES'
a=[]
for i in list(map(int,input().split())):
    if not i in a:
        if len(a)<4:
            a=a+[i]
        else:
            s='NO'
            break
print(s)


input()
s='YES'
a=[]
for i in list(map(int,input().split())):
    if not i in a:
        if len(a)<4:
            a=a+[i]
        else:
            s='NO'
            break
a.sort()
if len(a)==3:
    if a[1]-a[0]==a[2]-a[1]:
        print(s)
    else:
        print('NO')
elif len(a)==2:
    print('YES')
elif len(a)==1:
    print('YES')
else:
    print('NO')


input()
s='YES'
a=[]
for i in list(map(int,input().split())):
    if not i in a:
        if len(a)<4:
            a=a+[i]
        else:
            s='NO'
            break
a.sort()
if len(a)=3:
    if a[1]-a[0]==a[2]-a[1]:
        print(s)
    else:
        print('NO')
elif len(a)=1:
    print('YES')
else:
    print('NO')


input()
s='YES'
a=[]
for i in list(map(int,input().split())):
    if not i in a:
        if len(a)<4:
            a=a+[i]
        else:
            s='NO'
            break
a.sort()
if a[1]-a[0]==a[2]-a[1]:
    print(s)
else:
    print('NO')


input()
s='YES'
a=[]
for i in list(map(int,input().split())):
    if not i in a:
        if len(a)<4:
            a=a+[i]
        else:
            s='NO'
            break
a.sort()
if len(a)==3:
    if a[1]-a[0]==a[2]-a[1]:
        print(s)
    else:
        print('NO')
elif len(a)==1:
    print('YES')
else:
    print('NO')


n=int(input())
a=list(map(int,input().split()))
x=list(set(a))
if len(x)==3 and x[1]-x[0]==x[2]-x[1]:
    print('YES')
else:
    print('NO')


n=int(input())
a=list(map(int,input().split()))
x=list(set(a))
if (len(x)==3 and x[1]-x[0]==x[2]-x[1]) or len(x)<3:
    print('YES')
else:
    print('NO')


n=int(input())
a=list(map(int,input().split()))
x=list(set(a))
x.sort()
if len(x)==3 :
    if 2*x[1] ==x[0]+x[2]:
        print('YES')
    else:
        print('NO')
elif len(x)<3:
    print('YES')
else:
    print('NO')


n=int(input())
a=list(map(int,input().split()))
x=list(set(a))
x.sort()
if len(x)==3 :
    if 2*x[1] ==x[0]+x[2]:
        print('YES')
    else:
        print('N0')
elif len(x)<3:
    print('YES')
else:
    print('NO')


n=int(input())
a=list(map(int,input().split()))
x=list(set(a))
x.sort()
if len(x)==3 and x[0]<x[1]<x[2]:
    if 2*x[1] ==x[0]+x[2]:
        print('YES')
elif len(x)<3:
    print('YES')
else:
    print('NO')


#from dust i have come dust i will be

n=int(input())
a=list(map(int,input().split()))

t=0
for i in range(n):
    t+=a[i]

t=t//n
cnt=0

for i in range(n):
    if a[i]>t:
        a[i+1]+=abs(a[i]-t)
        cnt+=(abs(a[i]-t))

    elif a[i]<t:
        a[i+1]-=abs(a[i]-t)
        cnt+=(abs(a[i]-t))

print(cnt)


n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(n):
	k+=a[i]
aver=k//n
h=0
x=0
y=1
s=0
for i in range(n):
  s += aver - a[i]
  h += abs(s)
print(h)


n = int(input())
a = [int(i) for i in input().split()]
av = sum(a) // len(a)
ans = 0
s = 0
for i in a:
    s += i - av
    ans += abs(s)
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
av = sum(a) // len(a)
ans = 0
for i in a:
    ans += abs(i - av)
print(ans)


n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(n):
	k+=a[i]
aver=k//n
h=0
x=0
y=1
while max(a)!=aver and min(a)!=aver:
	if a[x]<aver:
		d=aver-a[x]
		h+=d
		a[x]+=d
		a[y]-=d
	if a[x]>aver:
		d=a[x]-aver
		h+=d
		a[x]-=d
		a[y]+=d
	x+=1
	y+=1
print(h)


n=int(input())
a=list(map(int,input().split()))
k=0
for i in range(n):
	k+=a[i]
aver=k//n
h=0
x=0
y=1
while max(a)!=aver and min(a)!=aver:
	if a[x]<aver:
		while (a[x]<aver and a[y]>0):
			a[x]+=1
			a[y]-=1
			h+=1
	if a[x]>aver:
		while (a[x]>aver):
			a[x]-=1
			a[y]+=1
			h+=1
	x+=1
	y+=1
print(h)


from sys import stdin as cin,stdout as cout
from math import factorial as f
from itertools import combinations as comb
n = int(cin.readline())

a = list(map(int,cin.readline().split()))

k = int(sum(a)/n)
sum = 0
for x in a:
  sum+= abs(x-k)
print(sum)


from sys import stdin as cin,stdout as cout
from math import factorial as f
from itertools import combinations as comb
n = int(cin.readline())

a = list(map(int,cin.readline().split()))

k = int(sum(a)/n)
sum = 0
for i in range(n-1):
  sum+= abs(a[i]-k)
  a[i+1]= a[i+1]-(k-a[i])

print(sum)


n = int(input())
a = [int(i) for i in  input().split()]

S = sum(a)
final = S // n

result = 0
for i in range(len(a) - 1):
    result += abs(a[i] - final)
    a[i + 1] += a[i] - final

print(result)


n = int(input())
a = [int(i) for i input().split()]

S = sum(a)
final = S // n

result = 0
for i in range(len(a)) - 1:
    result += abs(a[i] - final)
    a[i + 1] += a[i] - final

print(result)


n = int(input())
a = [int(i) for i in input().split()]
s = 0
for i in a:
    s += i
m = s // n
ans = 0
for i in range(n - 1):
    ans += abs(m - a[i])
    if a[i] < m:
        a[i + 1] -= m - a[i]
    else:
        a[i + 1] += a[i] - m
print(ans)


n=int(input())
a=list(map(int,input().split()))

need=sum(a)//n

ans=0

from math import *

for i in range(n-1):
	if(a[i]<=need):
		a[i+1]-=need-a[i]
	else:
		a[i+1]+=a[i]-need
	ans+=abs(a[i]-need)

print(ans)


from math import *

for _ in range(int(input())):
	f,b,x,y=map(int,input().split())

	if((abs(x-y))%gcd(f,b)==0):
		print("YES")
	else:
		print("NO")


n = int(input())
t = list(map(int, input().split()))
s, k = 0, sum(t) // n
t = [i - k for i in t]
for i in range(n - 1):
    s += abs(t[i])
    t[i + 1] += t[i]
print(s)


n = int(input())

a = [int(i) for i in input().split()]

av = sum(a) // len(a)

ans = 0

s = 0

for i in a:

    s += i - av

    ans += abs(s)

print(ans)

# Made By Mostafa_Khaled


import itertools

n = int(input())

a = map(int, input().split())
a = list(itertools.accumulate(a))

need_one = a[-1] // n

ans = 0
for i in range(len(a) - 1):
	ans += abs((i + 1) * need_one - a[i])

print(ans)


n=int(input())
lst=[*map(int,input().split())]
item=sum(lst)//n
if n==1:
    from sys import exit
    print(0);exit()
less,more,leng1,leng2=[],[],0,0
for i,x in enumerate(lst):
    if x<item:less.append(i);leng1+=1
    if x>item:more.append(i);leng2+=1
i,j=0,0
x,y=less[i],more[j]
res=0
while i<leng1 and j<leng2:
    x,y=less[i],more[j]
    elem1=lst[x]
    elem2=lst[y]
    diff1=item-elem1
    diff2=elem2-item
    if diff2>diff1:
        res+=(abs(x-y)*diff1)
        lst[y]-=diff1
        i+=1
    elif diff2<diff1:
        res+=(abs(x-y)*diff2)
        lst[x]+=diff2
        j+=1
    else:
        res+=(abs(x-y)*diff1)
        i,j=i+1,j+1
print(res)


n=int(input())
lst=[*map(int,input().split())]
item=sum(lst)//n
from sys import exit
if n==1:print(0);exit()
less,more,leng1,leng2=[],[],0,0
for i,x in enumerate(lst):
    if x<item:less.append(i);leng1+=1
    if x>item:more.append(i);leng2+=1
if leng1==0 and leng2==0:print(0);exit()
i,j=0,0
x,y=less[i],more[j]
res=0
while i<leng1 and j<leng2:
    x,y=less[i],more[j]
    elem1=lst[x]
    elem2=lst[y]
    diff1=item-elem1
    diff2=elem2-item
    if diff2>diff1:
        res+=(abs(x-y)*diff1)
        lst[y]-=diff1
        i+=1
    elif diff2<diff1:
        res+=(abs(x-y)*diff2)
        lst[x]+=diff2
        j+=1
    else:
        res+=(abs(x-y)*diff1)
        i,j=i+1,j+1
print(res)


n=int(input())
a=list(map(int,input().split()))

t=0
for i in range(n):
    t+=a[i]

t=t//n
cnt=0

for i in range(n):
    if a[i]>t:
        a[i+1]+=abs(a[i]-t)
        cnt+=(abs(a[i]-t))

    elif a[i]<t:
        a[i+1]-=abs(a[i]-t)
        cnt+=(abs(a[i]-t))

print(cnt)


n = int(input())
xs = list(map(int, input().split()))
u = sum(xs)//n

moves = 0
for i in range(n-1):
    moves += abs(u-xs[i])
    xs[i+1] += xs[i]-u

print(moves)


n = int(input())
xs = list(map(int, input().split()))
u = sum(xs)//n

moves = 0
ac = 0
for x in xs[:-1]:
    x += ac
    moves += abs(u-x)
    ac = x-u

print(moves)


n = int(input())
xs = list(map(int, input().split()))
u = sum(xs)/n

moves = 0
ac = 0
for x in xs[:-1]:
    x += ac
    moves += abs(u-x)
    ac = x-u

print(int(moves))


n = int(input())
xs = list(map(int, input().split()))
u = sum(xs)/n

moves = 0
ac = 0
for x in xs[:-1]:
    x += ac
    moves += abs(u-x)
    ac = x-u

print(moves)


n = int(input())
xs = list(map(int, input().split()))
u = sum(xs)//n

moves = 0
#foo
for i in range(n-1):
    moves += abs(u-xs[i])
    xs[i+1] += xs[i]-u

print(moves)


n=gets.to_i
xs=gets.split.map(&:to_i)
m=xs.inject(:+)/n

k,r=0,0

for i in (0...n)
  k+=xs[i]-m
  r+=k.abs
end

p r


n = input();
n = int(n);

a = list(map(int,raw_input().split()));

k = sum(a)/n;
moves = 0;

for i in range(n):
	if(a[i] > k):
		a[i+1]+=a[i]-k;
		moves+=a[i]-k;
	elif(a[i] < k):
		a[i+1]-=k-a[i];
		moves+=k-a[i];

print moves;


import math
test = int(raw_input().strip())
ls = map(int,raw_input().strip().split())
tot = sum(ls)/test
t = 0
for i in xrange(test):
    t+=abs(tot-ls[i])
print t


import math
test = int(raw_input().strip())
ls = map(int,raw_input().strip().split())
tot = sum(ls)/test
t = 0
for i in xrange(test-1):
    if ls[i]>=tot:
        t+=ls[i]-tot
        ls[i+1]+=(ls[i]-tot)
    else:
        t+=tot-ls[i]
        ls[i+1]-=(tot-ls[i])
print t


n = int(raw_input())
a = map(int, raw_input().split())
avg = sum(a) / n
ans = 0
for i in a:
    ans += abs(avg - i)
print ans


n = int(raw_input())
a = map(int, raw_input().split())
avg = sum(a) / n
ans = 0
cur = 0
for i in a:
    ans += abs(i + cur - avg)
    cur = i + cur - avg
print ans


n = int(raw_input())
num = (raw_input()).split()
sum = 0
ans = 0
for key in num:
    sum=sum+int(key)
sum = sum//n
if n > 1:
    for key in num:
        if int(key) < sum:
            ans = ans+sum-int(key)
        elif int(key) > sum:
            ans = ans+int(key)-sum

print ans


n = int(raw_input())
num = (raw_input()).split()
sum = 0
ans = 0
for key in num:
    sum=sum+int(key)
sum = sum//n
#print sum
if n > 1:
    for i in range(len(num)):
        if int(num[i]) < sum:
            ans = ans+sum-int(num[i])
            num[i+1] = str(int(num[i+1]-(sum-int(num[i]))))
        elif sum < int(num[i]):
            ans = ans+int(num[i])-sum
            num[i+1]=str(int(num[i+1])+(int(num[i])-sum))

print ans


n = int(raw_input())
num = (raw_input()).split()
sum = 0
ans = 0
for key in num:
    sum=sum+int(key)
sum = sum//n
#print sum
if n > 1:
    for i in range(len(num)):
        if int(num[i]) < sum:
            ans = ans+sum-int(num[i])
            num[i+1] = str(int(num[i+1])-(sum-int(num[i])))
        elif sum < int(num[i]):
            ans = ans+int(num[i])-sum
            num[i+1]=str(int(num[i+1])+(int(num[i])-sum))

print ans


n = int(raw_input())
ar = [int(c) for c in raw_input().split()]
target = sum(ar) / n
ans = 0
for i in xrange(n-1):
	move = target - ar[i]
	ar[i], ar[i+1] = ar[i] + move, ar[i+1] - move
	ans += abs(move)
print ans


n=input()
a=map(int,raw_input().split())
k=sum(a)
d=k/n
t=0
for i in range(n-1):
  t+=abs(a[i]-d)
  a[i+1]+=a[i]-d
print t


n,a=input(),map(int,raw_input().split())
ave=sum(a)/n
a=map(lambda x: [x[0],x[1]-ave], enumerate(a))
neg=filter(lambda x:x[1]<0,a)
pos=filter(lambda x:x[1]>0,a)
i = j = ans = 0
while i < len(neg):
	s=neg[i][1]+pos[j][1]
	if s<0:
		ans += abs(neg[i][0]-pos[j][0])*pos[j][1]
		neg[i][1]+=pos[j][1]
		j += 1
	else:
		ans -= abs(neg[i][0]-pos[j][0])*neg[i][1]
		pos[j][1]+=neg[i][1]
		i += 1
		if not s: j += 1
print ans


from sys import stdin
n=stdin.readline()
ans = 0
a = stdin.readline().strip().split()
n=int(n)
for i in a:
 ans+=int(i)
ans/=n
total = 0
for i in a:
 x = int(i)
 if x<ans:
  total+=ans-x
print 2*total


from sys import stdin
n=int(stdin.readline())
a=stdin.readline().strip().split()
b=[]
for i in a:
 b.append(int(i))
b.append(0)
ans = 0
s = 0
for i in b:
 s+=i
s= s/n
for i in xrange(n):
 if b[i]<s:
  ans+=s-b[i]
  b[i+1]-=s-b[i]
 else:
  ans+=b[i]-s
  b[i+1]+=b[i]-s
print ans


n = int(raw_input())
data = map(int, raw_input().split())
perOne = sum(data) / n
ans = 0
for i in xrange(n - 1):
  if data[i] > perOne:
    gap = data[i] - perOne
    ans += gap
    data[i + 1] += gap
  else:
    gap = perOne - data[i]
    ans += gap
    data[i + 1] -= gap
print ans


n = int(raw_input())
data = map(int, raw_input().split())
perOne = sum(data) / n
ans = 0
for i in xrange(n - 1):
  if data[i] > perOne:
    gap = data[i] - perOne
    ans += gap
    data[i + 1] += perOne
  else:
    gap = perOne - data[i]
    ans += gap
    data[i + 1] -= gap
print ans


n = int(raw_input())
a = map(int, raw_input().split())
k = sum(a)/n
need = 0
moves = 0
for i in range(n-1):
    if a[i] != k:
        need = k-a[i]
        a[i+1] -= need
        moves += abs(need)
print moves


n = int(raw_input())
a = map(int, raw_input().split())
s = sum(a)
s/=n
ans = 0
for i in a:
    if i<s:
        ans += s-i
print ans


n = int(raw_input())
matches = map(int, raw_input().split())
target = sum(matches)/n
ans = 0

for i in xrange(n):
	j = i
	while matches[i] != target:
		if matches[i] < target:
			diff = min(matches[j]-target, target-matches[i])
			matches[i] += diff
			matches[j] -= diff
		else:
			diff = min(matches[i]-target, target-matches[j])
			matches[i] -= diff
			matches[j] += diff
		ans += diff*abs(i-j)
		j += 1

print ans


n = int(raw_input())

a = map(int,raw_input().split())

avg = sum(a)/len(a)

ans = []

for i in range(len(a)):
	ans.append(avg-a[i])
count = 0
for i in range(len(ans)-1):
	count += abs(ans[i])

	ans[i+1] = ans[i] + ans[i+1]
	ans[i] = 0
print count


n = int(raw_input())

a = map(int,raw_input().split())

avg = sum(a)/len(a)

ans = []

for i in range(len(a)):
	ans.append(avg-a[i])
count = 0
for i in range(len(ans)-1):
	count += abs(ans[i])

	ans[i+1] = ans[i] + ans[i+1]
	ans[i] = 0
print abs(count)


n = int(input())
a = map(int, raw_input().split())
average = sum(a) / n;
answer = 0;
pre = 0
for i in xrange(n):
	if pre > 0:
		answer += pre;
		if pre > a[i]:
			pre -= a[i];
			a[i] = 0;
		else :
			a[i] -= pre
			pre = 0;
	if a[i] > average:
		answer += a[i] - average;
		a[i+1] += a[i] - average;
	else :
		pre += average - a[i];

print answer


n = int(input())
a = map(int, raw_input().split())
average = sum(a) / n;
answer = 0;
pre = 0
for i in xrange(n):
	if a[i] == average:
		continue;
	if pre > 0:
		if pre > a[i]:
			pre -= a[i];
			answer += a[i]
			a[i] = 0;
			pre += pre;
		else :
			answer += pre;
			a[i] -= pre
			pre = 0;
	if a[i] > average:
		answer += a[i] - average;
		a[i+1] += a[i] - average;
	else :
		pre += average - a[i];

print answer


n = int(input())
a = map(int, raw_input().split())
average = sum(a) / n;
answer = 0;
pre = 0
for i in xrange(n):
	if a[i] == average:
		continue;
	if pre > 0:
		answer += pre;
		if pre > a[i]:
			pre -= a[i];
			a[i] = 0;
		else :
			a[i] -= pre
			pre = 0;
	if a[i] > average:
		answer += a[i] - average;
		a[i+1] += a[i] - average;
	else :
		pre += average - a[i];

print answer


n = int(raw_input())
array = map(int, raw_input().split())
total = sum(array)
one = total / n

result = 0

for i in range(n):
	if array[i] < one:
		result += one - array[i]
		array[i+1] -= one - array[i]
	elif array[i] > one:
		result += array[i] - one
		array[i+1] += array[i] - one
print result


n = int(raw_input())
array = map(int, raw_input().split())
total = sum(array)
one = total / n

result = 0

for i in range(n-1):
	if array[i] < one:
		result += one - array[i]
		array[i+1] -= one - array[i]
	elif array[i] > one:
		result += array[i] - one
		array[i+1] += one - array[i]
print result


n = int(raw_input())
array = map(int, raw_input().split())
total = sum(array)
one = total / n

result = 0

for i in range(n):
	if array[i] < one:
		result += one - array[i]
		array[i+1] -= one - array[i]
	elif array[i] > one:
		result += array[i] - one
		array[i+1] += one - array[i]
print result


n=input()
l=map(int,raw_input().split())
a=sum(l)/n
c=d=0
for i in l:i-=d;d=a-i;c+=abs(d)
print c


n=int(raw_input())
a=map(int,raw_input().split())
tot=0
res=sum(a)/n
for i in range(n-1):
    tt=a[i]-res
    a[i+1]+=tt
    tot+=abs(tt)
print tot


n=int(raw_input())
l=[int(x) for x in raw_input().split()]
chk=sum(l)/n
ans=0
for i in range(n):
    ans+=abs(chk-l[i])
print ans


n=int(raw_input())
l=[int(x) for x in raw_input().split()]
av=sum(l)/n
ans=chk=0
for i in range(n):
    #ans+=abs(sum(l[:i+1])-av*i+1)
    ans+=abs(sum(l[:i+1])-av*i)
print ans


n=int(raw_input())
l=map(int,raw_input().split())
chk=0
for i in l:
    chk+=i
chk/=n
cnt=ans=0
for i in l:
    if i!=chk:
        cnt+=(i-chk)
    ans+=abs(cnt)
print ans


n=int(raw_input())
l=map(int,raw_input().split())
chk=0
for i in l:
    chk+=i
chk/=n
cnt=ans=0
for i in l:
    print cnt,chk
    if i!=chk:
        cnt+=(i-chk)
    ans+=abs(cnt)
print ans


n=int(raw_input())
l=[int(x) for x in raw_input().split()]
av=sum(l)/n
ans=chk=0
for i in range(n):
    #ans+=abs(sum(l[:i+1])-av*i+1)
    ans+=abs(sum(l[:i+1])-av*i+1)-1
print ans


n = input()
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

bn = len(n3) # number of box
# Just use list
sp = [ii-sum(n3)/bn for ii in n3]
scum = sp[:]
for i in range(1,len(scum)):
    scum[i] = scum[i]+scum[i-1]
scum = [abs(cc) for cc in scum]
print sum(scum)


# -*- coding: utf-8 -*-
import numpy as np
n = input() #The first line contains integer n (1 ≤ n ≤ 50000).
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

# testcase
#n = 6
#n3 = [6,6,0,0,6,6]

# testcase
#n = 6
#n3 = [6,6,6,0,0,0]

# There is sth wrong with the test case
#n = 6
#n3 = [6,3,8,7,4,2]

bn = len(n3) # number of box
sp = np.array([ii-sum(n3)/bn for ii in n3]) # surplus
#print 'sp=',sp
cumsum_sp = np.cumsum(sp)
times = np.sum(np.abs(cumsum_sp))
#print 'cumsum_sp=',cumsum_sp
print times


n = input()
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

bn = len(n3) # number of box
av = sum(n3)/bn
# Just use list
sp = [ii-av for ii in n3]
scum = list()
scum.append(sp[0])
for i in range(1,len(sp)):
    scum.append(sp[i]+scum[-1])
print sum([abs(cc) for cc in scum])

# Time value exceed on test 6


n = input()
n3 = raw_input().split() # The second line contains n non-negative numbers
n2 = map(int, n3) #print type(n3)
np = range(1,len(n2)+1)
nmean = sum(n2)/len(n2)
n3 = [np[i]*(n2[i]-nmean) for i in range(6)]
print abs(sum(n3))


# -*- coding: utf-8 -*-
n = input() #The first line contains integer n (1 ≤ n ≤ 50000).
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

# testcase
#n = 6
#n3 = [0,0,0,6,6,6]

bn = len(n3) # number of box
print 'bn=',bn
sp = [ii-sum(n3)/bn for ii in n3] # surplus
print 'sp=',sp
times = 0
if max(sp)>0:
    print 'start'
    #times = 0
#else:
    indices = [i for i, x in enumerate(sp) if x == max(sp)]
    print 'indices = ',indices
    if min(indices)>n/2-1:
        ms = indices[-1]
    else:
        ms = indices[0]
    # Need to find index closest to edge

    #ms = sp.index(min([abs(ssp-n/2) for ssp in sp]))
    #ms = sp.index(max(sp)) #position of maximum surplus
    sl = sum(sp[:ms]) # sum of left
    sr = sum(sp[ms+1:]) # sum of right
    print 'ms,sl,sr=',ms,sl,sr
    if (sr>sl):
        sp = sp[::-1]

        indices = [i for i, x in enumerate(sp) if x == max(sp)]
        if min(indices)>n/2-1:
            ms = indices[-1]
        else:
            ms = indices[0]

        #ms = sp.index(max(sp))
        sl,sr = sr,sl

    # right hand side more needed (more negative)
    transfer = min(sp[ms],sr)
    sp[ms] += transfer
    sp[ms+1] -= transfer
    times += abs(transfer)
    print 'sp=',sp
    for d in range(ms+1,bn-1):
        transfer = sp[d]
        sp[d] -= transfer
        sp[d+1] += transfer
        times += abs(transfer)
        print 'sp=',sp
    # And then the right hand side
    for d in range(ms,0,-1):
        transfer = sp[d]
        sp[d] -= transfer
        sp[d-1] += transfer
        times += abs(transfer)
        print 'sp=',sp
print times


n = input()
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

bn = len(n3) # number of box
av = sum(n3)/bn

cum = 0
acum = 0
for nn in n3:
    cum += (nn-av)
    acum += abs(cum)

print acum


# -*- coding: utf-8 -*-
import numpy as np
n = input() #The first line contains integer n (1 ≤ n ≤ 50000).
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

bn = len(n3) # number of box
sp = np.array([ii-sum(n3)/bn for ii in n3]) # surplus
cumsum_sp = np.cumsum(sp)
times = np.sum(np.abs(cumsum_sp))
print times

# testcase
#n = 6
#n3 = [6,6,0,0,6,6]

# testcase
#n = 6
#n3 = [6,6,6,0,0,0]

# There is sth wrong with the test case
#n = 6
#n3 = [6,3,8,7,4,2]


# -*- coding: utf-8 -*-
n = input() #The first line contains integer n (1 ≤ n ≤ 50000).
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

bn = len(n3) # number of box
sp = [ii-sum(n3)/bn for ii in n3] # surplus
times = 0
if max(sp)>0:

    #times = 0
#else:
    ms = sp.index(max(sp)) #position of maximum surplus
    sl = sum(sp[:ms]) # sum of left
    sr = sum(sp[ms+1:]) # sum of right

    if (sr>sl):
        sp = sp[::-1]
        ms = sp.index(max(sp))
        sl,sr = sr,sl

    # right hand side more needed (more negative)
    transfer = min(sp[ms],sr)
    sp[ms] += transfer
    sp[ms+1] -= transfer
    times += abs(transfer)
    for d in range(ms+1,bn-1):
        transfer = sp[d]
        sp[d] -= transfer
        sp[d+1] += transfer
        times += abs(transfer)
    # And then the right hand side
    for d in range(ms,0,-1):
        transfer = sp[d]
        sp[d] -= transfer
        sp[d-1] += transfer
        times += abs(transfer)
print times


# -*- coding: utf-8 -*-
n = input() #The first line contains integer n (1 ≤ n ≤ 50000).
n2 = raw_input().split() # The second line contains n non-negative numbers
n3 = map(int, n2) #print type(n3)

# testcase
#n = 6
#n3 = [0,0,0,6,6,6]

bn = len(n3) # number of box
#print 'bn=',bn
sp = [ii-sum(n3)/bn for ii in n3] # surplus
#print 'sp=',sp
times = 0
if max(sp)>0:
    #print 'start'
    #times = 0
#else:
    indices = [i for i, x in enumerate(sp) if x == max(sp)]
    #print 'indices = ',indices
    if min(indices)>n/2-1:
        ms = indices[-1]
    else:
        ms = indices[0]
    # Need to find index closest to edge

    #ms = sp.index(min([abs(ssp-n/2) for ssp in sp]))
    #ms = sp.index(max(sp)) #position of maximum surplus
    sl = sum(sp[:ms]) # sum of left
    sr = sum(sp[ms+1:]) # sum of right
    #print 'ms,sl,sr=',ms,sl,sr
    if (sr>sl):
        sp = sp[::-1]

        indices = [i for i, x in enumerate(sp) if x == max(sp)]
        if min(indices)>n/2-1:
            ms = indices[-1]
        else:
            ms = indices[0]

        #ms = sp.index(max(sp))
        sl,sr = sr,sl

    # right hand side more needed (more negative)
    transfer = min(sp[ms],sr)
    sp[ms] += transfer
    sp[ms+1] -= transfer
    times += abs(transfer)
    #print 'sp=',sp
    for d in range(ms+1,bn-1):
        transfer = sp[d]
        sp[d] -= transfer
        sp[d+1] += transfer
        times += abs(transfer)
        #print 'sp=',sp
    # And then the right hand side
    for d in range(ms,0,-1):
        transfer = sp[d]
        sp[d] -= transfer
        sp[d-1] += transfer
        times += abs(transfer)
        #print 'sp=',sp
print times


n = input()
a = map(int, raw_input().split())
m = sum(a) / n
ans = 0
for i in xrange(n-1):
    if a[i] != m:
        ans += 1
        a[i+1] -= m - a[i]
print ans


n = input()
a = map(int, raw_input().split())
m = sum(a) / n
ans = 0
for i in xrange(n-1):
    if a[i] != m:
        ans += abs(m - a[i])
        a[i+1] -= m - a[i]
print ans


n = input()
a = map(int, raw_input().split())
m = sum(a) / n
ans = 0
for i in xrange(n-1):
    if a[i] != m:
        ans += m - a[i]
        a[i+1] -= m - a[i]
print ans


no = int(raw_input())
arr = map(int , raw_input().split())
total = sum(arr)
each = total/no
count = 0
for  i in range(no - 1 ):
	if(arr[i] == each):
		continue
	elif(arr[i] <each):
		defi = (each - arr[i])
		count += defi
		arr[i+1] -= defi
		arr[i] = each
	else:
		extra = arr[i] - each
		count += extra
		arr[i+1] += extra
		arr[i] = each
print count


n=int(raw_input())
arr=map(int, raw_input().split())
div=sum(arr)/n
count=0
for i in xrange(n-1):
    if(arr[i]==div):
        continue
    if(arr[i]<div):
        count+=(div-arr[i])
        temp=arr[i]
        arr[i]+=(div-arr[i])
        arr[i+1]-=(div-temp)
    if(arr[i]>div):
        count+=(arr[i]-div)
        temp=arr[i]
        arr[i]-=(arr[i]-div)
        arr[i+1]+=(temp-div)
print count


n,a = int(raw_input()),map(int, raw_input().split())
avg = sum(a)/n
diff=steps=0
for i in range(n-1):
    if a[i] != avg:
        diff = avg-a[i]
        a[i+1] -= diff
        steps += abs(diff)
print steps


n = input()
a = map(int,raw_input().split())
m = sum(a)/n
res = 0
for i in range(n-1):
    d = m - a[i]
    a[i] += d
    a[i+1] -= d
    res += abs(d)
print res


__author__ = 'Yoones'

res = 0

n = int(raw_input())

lst = map(int, raw_input().split(' '))

targ = sum(lst) / n

for i in range(len(lst)):
    if lst[i] > targ:
        dif = lst[i] - targ
        lst[i] -= dif
        lst[i + 1] += dif
        res += dif
    elif lst[i] < targ:
        dif = targ - lst[i]
        lst[i] += dif
        lst[i + 1] -= dif
        res += dif

print res


n, b, moves, moving = int(raw_input()), map(int, raw_input().split()), 0, 0
avg = sum(b) / n
for bi in b:
	moving += bi - avg
	moves += abs(moving)
print moves


n=input()
l=map(int,raw_input().split())
a=sum(l)/n
c=d=0
for i in l:i-=d;d=a-i;c+=abs(d)
print c


#!/usr/bin/python
N=input()
a=map(int, raw_input().split())
Sum=0
for i in a:
	Sum+=i
Sum=Sum/N
ans=0
for i in range(N/2):
			a[i+1]=a[i+1]+(a[i]-Sum)
			ans+=abs(a[i]-Sum)
			a[N-i-2]=a[N-i-2]+a[N-i-1]-Sum
			ans+=abs(a[N-i-1]-Sum)
print ans


n = int(raw_input())

a = map(int,raw_input().split())

avg = sum(a)/len(a)

ans = []

for i in range(len(a)):
	ans.append(avg-a[i])
count = 0
print ans
for i in range(len(ans)-1):
	count += abs(ans[i])

	ans[i+1] = ans[i] + ans[i+1]
	ans[i] = 0
print abs(count)


n = int(raw_input())

a = map(int,raw_input().split())

avg = sum(a)/len(a)

ans = []

for i in range(len(a)):
	ans.append(avg-a[i])
count = 0
for i in range(len(ans)-1):
	count += ans[i]

	ans[i+1] = ans[i] + ans[i+1]
	ans[i] = 0
print count


n = int(raw_input())

a = map(int,raw_input().split())

avg = sum(a)/len(a)

ans = []

for i in range(len(a)):
	ans.append(avg-a[i])
count = 0
for i in range(len(ans)-1):
	count += ans[i]

	ans[i+1] = ans[i] + ans[i+1]
	ans[i] = 0
print abs(count)


n = int(raw_input())

a = map(int,raw_input().split())

avg = sum(a)/len(a)

ans = []

for i in range(len(a)):
	ans.append(avg-a[i])
count = 0
for i in range(len(ans)-1):
	count += abs(ans[i])

	ans[i+1] = ans[i] + ans[i+1]
	ans[i] = 0
print abs(count)


n=input()
s=map(int,raw_input().split())
ans=0
t=sum(s)/n
cur=0
for i in s:
    ans+=abs(t-i+cur)
    cur=t-i+cur
    print ans
print ans


n=input()
s=map(int,raw_input().split())
ans=0
t=sum(s)/n
cur=0
for i in s:
    ans+=abs(t-i+cur)
    cur=t-i+cur
print ans


using System;
using System.Collections;
using System.Collections.Generic;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		long sum=0;
		long[] SA=new long[N];
		for(int i=0;i<N;i++){
			sum+=A[i];
			if(i==0)SA[i]=A[0];
			if(i>0)SA[i]=SA[i-1]+A[i];
		}

		long trgt=sum/N;

		long ans=0;
		for(long i=0;i<N;i++){
			ans+=Math.Abs((i+1)*trgt-SA[i]);
		}
		Console.WriteLine("{0}",ans);

	}
	long N;
	long[] A;
	public Sol(){
		N=rl();
		A=rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}


n=input()
a=map(int, raw_input().split())
mean=sum(a)/n
print sum(abs(i-mean) for i in a)


n=input()
a=map(int,raw_input().split())
l=sum(a)/n
c,d=0,0
for i in a:
    i-=d
    d=l-i
    c+=abs(d)
print c


#include<stdio.h>
#include<string.h>
int main(void)
{
	char a[10000];
	long long int i,length,n;
	scanf("%lld",&n);
	while(n--)
	{
		scanf("%s",&a);
		length=strlen(a);
		if(length<=10)
			printf("%s\n",a);
		else
			printf("%c%lld%c\n",a[0],length-2,a[length-1]);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
void main()
{
	int n;
	char x[100]={0};
	scanf("%d", &n);
	while(n--)
	{
		char x[100]={0};
		scanf("%s", x);
		strlen(x) <= 10?printf("%s\n", x):printf("%c%d%c\n", x[0], strlen(x)-2, x[strlen(x)-1]);
	}
}


#include <iostream>
using namespace std;

int main()
{
    char st[105];
    int n,len;
    scanf("%d",&n);
    while (n--)
    {
        scanf("%s",&st);
        len=strlen(st);
        if (len>10)
        {
            printf("%c%d%c\n",st[0],len-2,st[len-1]);
        }
        else printf("%s\n",st);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
void main()
{
	int n;
	char x[100];
	scanf("%d", &n);
	while(n--)
	{
		scanf("%s", x);
		strlen(x) <= 10?printf("%s\n", x):printf("%c%d%c\n", x[0], strlen(x)-2, x[strlen(x)-1]);
	}
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
	int time=0;
	cin>>time;
	while(time--)
	{
		string s;
		cin>>s;
		if(s.length()>10)
			cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
		else
			cout<<s<<endl;
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
void main()
{
	int n;
	char x[101]={0};
	scanf("%d", &n);
	while(n--)
	{
		scanf("%s", x);//printf("%d", strlen(x));
		strlen(x) <= 10?printf("%s\n", x):printf("%c%d%c\n", x[0], strlen(x)-2, x[strlen(x)-1]);
	}
}


#include <iostream>

using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1];

			else
			for (i = 0; str[i] != 0; i++)
				cout << str[i];
		}

		return 0;
	}


#include <iostream>

using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else
			for (i = 0; str[i] != 0; i++)
				cout << str[i];
				cout<<endl;
		}

		return 0;
	}


#include <iostream>
using namespace std;
int main();
{
    char str[105]={};
    int i,j,n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin.getline(str,105);
        if(strlen(str)>10)
        cout<<str[0]<<strlen(str)-2<<str[strlen(str)-1]<<endl;
        else
        cout<<str<<endl;
    }
    return 0;
}


#include <iostream>

using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else
			for (i = 0; str[i] != 0; i++)
				cout << str[i]<<endl;
		}

		return 0;
	}


#include <iostream>
using namespace std;
int main()
{
		char str[110] = {};
		int i, n;
		cin >> n;
		for (i = 0; i <= n; i++)
		{
			cin.getline(str, 110);
			if (strlen(str)>10)
				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1] << endl;
			else
				cout << str << endl;
		}

		return 0;

}


#include <iostream>
using namespace std;
int main();
{
    char str[105]={};
    int i,j,n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        if(strlen(str)>10)
        cout<<str[0]<<strlen(str)-2<<str[strlen(str)-1]<<endl;
        else
        cout<<str<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else
			for (i = 0; str[i] != 0; i++)
				cout << str[i];
				cout <<endl;
		}

		return 0;
	}


#include <iostream>
using namespace std;
int main()
{
    char str[105];
    int i,count=0;
    for(i=0;str[i]!=0;i++);
    if(i-1>10)
    {
        cout<<str[0];
        for(i=1;str[i]!=0;i++)
        count++;
        cout<<count-1<<str[i-1];
    }
    else
    for(i=0,str[i]!=0;i++)
    cout<<str[i];
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    char str[110]={};
    int i,n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin.getline(str,110);
        if(strlen(str)>10)
        cout<<str[0]<<strlen(str)-2<<str[strlen(str)-1]<<endl;
        else
        cout<<str<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else

				cout << str;
		}

		return 0;
	}


#include <iostream>
using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else

				cout << str;
				cout<<endl;
		}

		return 0;
	}


#include <iostream>
using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else
            {
				cout << str;
				cout<<endl;
            }
		}

		return 0;
	}


#include <iostream>
using namespace std;
	int main()
	{
		char str[105] = {};
		int i, count = 0;
		cin.getline(str, 105);
		for (i = 0; str[i] != 0; i++);
		if (i - 1>10)
		{
			cout << str[0];
			for (i = 1; str[i] != 0; i++)
				count++;
			cout << count - 1 << str[i - 1];
		}
		else
		for (i = 0; str[i] != 0; i++)
			cout << str[i];

		return 0;
	}


#include <iostream>
using namespace std;
	int main()
	{
		char str[105] = {};
		int i,j=0,n, count = 0;
		cin >> n;
		for (j = 0; j <n; j++)
		{

			cin.getline(str, 105);

			if (strlen(str)>10)

				cout << str[0] << strlen(str) - 2 << str[strlen(str) - 1]<<endl;

			else

				cout << str;
				cout<<endl;
		}

		return 0;
	}

→Judgement Protocol


#include <iostream>
using namespace std;
int main()
{
    char str[110]={};
    int i,j,n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin.getline(str,110);
        if(strlen(str)>10)
        cout<<str[0]<<strlen(str)-2<<str[strlen(str)-1]<<endl;
        else
        cout<<str<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					result += c + '\n';
					goto a;
				}
				break;
			}
		}
		result += c[0] + to_string(int(j - 2)) + c[j - 1]+'\n';
	a: continue;
	}
	cout << result;
}


#include <iostream>
using namespace std;

void main()
{
	int n;
	cin >> n;
	char *c = new char[];
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					for (int l = 0; c[l] != NULL; l++)
					{
						cout << c[l];
					}
					goto a;
				}
				break;
			}
		}
		cout << c[0] << j - 2 << c[j-1];
	a: continue;
	}
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					result += c + '\n';
					goto a;
				}
				break;
			}
		}
		//result += c[0] + to_string(j - 2) + c[j - 1]+'\n';
	a: continue;
	}
	cout << result;
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c;
	string result;
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					result += c + '\n';
					goto a;
				}
				break;
			}
		}
		result += c[0] + to_string(j - 2) + c[j - 1]+'\n';
	a: continue;
	}
	std::cout << result;
}


#include <iostream>
#include <string>
using namespace std;
void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		if (c.length() < 11)
		{

			cout << c << endl;
		}
		else
		{
			cout << c[0] << c.length() - 2 << c[c.length() - 1] << endl;
		}
	}
}


#include <iostream>
#include <string>
using namespace std;
void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		if (c.length() < 11)
		{

			cout << c;
		}
		else
		{
			if (c.length() == 11)
			{

				cout << c[0] << '9' << c[c.length() - 1];
			}
			else
			{

				cout << c[0] << c.length() - 2 << c[c.length() - 1];
			}
		}
	}
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c;
	string result;
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					result += c + '\n';
					goto a;
				}
				break;
			}
		}
		result += c[0] + to_string(j - 2) + c[j - 1]+'\n';
	a: continue;
	}
	cout << result;
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					result += c + '\n';
					goto a;
				}
				break;
			}
		}
		result += c[0] + to_string(j - 2) + c[j - 1]+'\n';
	a: continue;
	}
	cout << result;
}


/*#include <iostream>
#include <string>
using namespace std;

void main()
{
	string a = "";
	cin >> a;
	string b = a;
	for (int i = 1; i < a.length(); i++)
	{
		if ()
	}
	putchar(toupper(a[0]));
	for (int i = 1; i < a.length(); i++)
	{
		putchar(tolower(a[i]));
	}
}*/

#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		if (c.length() < 11)
		{
			cout << c;
		}
		else
			cout << c[0] << c.length() - 2 << c[c.length()-1];
	}
}


/*#include <iostream>
#include <string>
using namespace std;

void main()
{
	string a = "";
	cin >> a;
	string b = a;
	for (int i = 1; i < a.length(); i++)
	{
		if ()
	}
	putchar(toupper(a[0]));
	for (int i = 1; i < a.length(); i++)
	{
		putchar(tolower(a[i]));
	}
}*/

#include <iostream>
#include <string>
using namespace std;
#define SSTR( x ) dynamic_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		if (c.length() < 11)
		{
			result += c + '\n';
		}
		else
		{
			if (c.length() == 11)
			{
				result += c[0] +'9'+ c[c.length() - 1];
			}
			else
			{
				result += c[0];
				result += char((c.length() - 2 - (c.length() - 2) % 10) / 10 + 48);
				result += char((c.length() - 2) % 10 + 48);
				result += c[c.length() - 1];
				result += '\n';
			}
		}
	}
	cout << result;
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c;
	string result;
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					result += c + '\n';
					goto a;
				}
				break;
			}
		}
		result += c[0] + to_string(_Longlong(j - 2)) + c[j - 1] + '\n';
	a: continue;
	}
	cout << result;
}


#include <iostream>
#include <string>
using namespace std;

void main()
{
	int n;
	cin >> n;
	string c;
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		int j;
		for (j = 0; j < 100; j++)
		{
			if (c[j] == NULL)
			{
				if (j <= 9)
				{
					for (int l = 0; c[l] != NULL; l++)
					{
						cout << c[l];
					}
					goto a;
				}
				break;
			}
		}
		cout << c[0] << j - 2 << c[j-1];
	a: continue;
	}
}


/*#include <iostream>
#include <string>
using namespace std;

void main()
{
	string a = "";
	cin >> a;
	string b = a;
	for (int i = 1; i < a.length(); i++)
	{
		if ()
	}
	putchar(toupper(a[0]));
	for (int i = 1; i < a.length(); i++)
	{
		putchar(tolower(a[i]));
	}
}*/

#include <iostream>
#include <string>
using namespace std;
#define SSTR( x ) dynamic_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
void main()
{
	int n;
	cin >> n;
	string c = "";
	string result = "";
	for (int i = 0; i < n; i++)
	{
		cin >> c;
		if (c.length() < 11)
		{
			result += c + '\n';
		}
		else
		{
			if (c.length() == 11)
			{
				result += c[0];
				result += '9';
				result += c[c.length() - 1];
			}
			else
			{
				result += c[0];
				result += char((c.length() - 2 - (c.length() - 2) % 10) / 10 + 48);
				result += char((c.length() - 2) % 10 + 48);
				result += c[c.length() - 1];
				result += '\n';
			}
		}
	}
	cout << result;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;

	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		i++;
		//cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=11){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		//cout<<cont<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>

#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		    //cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<11){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;

	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		i++;
		//cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont>=12)
	{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}
	else{
		for(i=0;i<cont;i++){
			cout<<palabra[i];
		}
		cout<<endl;
	}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
		cin>>palabra;
		i=0;cont=0;
		//cout<<cont<<endl;
		while ((palabra[i]!='\0')&&(i<=100)){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
			i++;
			//cout<<cont<<endl;
		}
		//cout<<cont<<endl;
		if(cont<=10){
			for(i=0;i<cont;i++){
				cout<<palabra[i];
			}
			cout<<endl;
		}else{
			i=cont-1;
			cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
		}

	}
	return 0;
}


#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[1000];
	cin>>n;
	for(j=0;j<n;j++){
		cin>>palabra;
		i=0;cont=0;
		while ((palabra[i]!='\0')){
			cont++;
			i++;
		}
		if(cont<=10){
			for(i=0;i<cont;i++){
				cout<<palabra[i];
			}
			cout<<endl;
		}else{
			i=cont-1;
			cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
		}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		//cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=11){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')&&(palabra[i]!='\n\n')){
			cout<<cont<<endl;
			cout<<palabra[i]<<endl;
			cont++;
			cout<<cont<<endl;
		    i++;
		cout<<cont<<endl;
	}
	cout<<cont<<endl;
	if(cont<=11){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;

	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		i++;
		//cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<12){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>

#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		    //cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=12){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>

#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		    //cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<12){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>

#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		    //cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=10){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[101];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,101,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		    //cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=10){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	for(j=0;j<=n;j++){
		cin>>palabra;
		i=0;cont=0;
		while ((palabra[i]!='\0')&&(i<100)){
			cont++;
			i++;
		}
		if(cont<=10){
			for(i=0;i<cont;i++){
				cout<<palabra[i];
			}
			cout<<endl;
		}else{
			i=cont-1;
			cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
		}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')&&(palabra[i]!='\n\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		    i++;
		    //cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=11){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			cont++;
		    i++;
	}
	if(cont<=10){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	string palabra[100];
	cin>>n;
	//cout<<n<<endl;
	for(j=0;j<=n;j++){
		cin>>palabra;
		i=0;cont=0;
		//cout<<cont<<endl;
		while ((palabra[i]!='\0')&&(i<100)){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
			i++;
			//cout<<cont<<endl;
		}
		//cout<<cont<<endl;
		if(cont<=10){
			for(i=0;i<cont;i++){
				cout<<palabra[i];
			}
			cout<<endl;
		}else{
			i=cont-1;
			cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
		}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int i,j,n,cont;
	char palabra[100];
	cin>>n;
	//cout<<n<<endl;

	for(j=0;j<=n;j++){
	fgets(palabra,100,stdin);
	i=0;cont=0;
	//cout<<cont<<endl;
	while ((palabra[i]!='\0')&&(palabra[i]!=' ')&&(palabra[i]!='\n')){
			//cout<<cont<<endl;
			//cout<<palabra[i]<<endl;
			cont++;
			//cout<<cont<<endl;
		i++;
		//cout<<cont<<endl;
	}
	//cout<<cont<<endl;
	if(cont<=11){
		for(i=0;i<cont;i++){
		cout<<palabra[i];
		}
		cout<<cont<<endl;
	}else{
		i=cont-1;
		cout<<palabra[0]<<cont-2<<palabra[i]<<endl;
	}

	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[101][101];
	int num;
	scanf("%d",&num);ff;
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);ff;
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>=12){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[100][100];
	int num;
	scanf("%d",&num);ff;
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);ff;
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>11){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	printf("\n");
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[100][100];
	int num;
	scanf("%d",&num);
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>=11){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[101][101];
	int num;
	scanf("%d",&num);
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>=11){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[100][100];
	int num;
	scanf("%d",&num);ff;
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);ff;
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>=12){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	printf("\n");
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[100][100];
	int num;
	scanf("%d",&num);ff;
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);ff;
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>=12){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[100][100];
	int num;
	scanf("%d",&num);ff;
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);ff;
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>11){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define ff fflush(stdin)

int main(){
	char a[100][100];
	int num;
	scanf("%d",&num);
	for(int i = 0; i < num ; i++){
		scanf("%s",a[i]);
	}
	for(int i=0;i< num ; i++){
		if(strlen(a[i])>=12){
			printf("%c%d%c\n",a[i][0],strlen(a[i])-2,a[i][strlen(a[i])-1]);
		}
		else {
			printf("%s\n",a[i]);
		}
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define f fflush(stdin)

int main(){
	char text[100][100];
	char asd[10]="Asd";
	int ctr;
	int total=0;
	int tengah=0;
	scanf("%d",&ctr);f;
	for(int i=0;i<ctr;i++){
		scanf("%s",text[total]);f;
		total++;
	}
	for(int i=0;i<total;i++){
		if(strlen(text[i])>10){
		for(int j=1;j<(strlen(text[i])-1);j++){
			tengah++;
		}
		printf("%c%d%c\n",text[i][0],tengah,text[i][strlen(text[i])-1]);
		tengah=0;
		}
		else{
			printf("%s\n",text[i]);
		}
	}

	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    string s;
    char a, b;
    int n;
    n=s.length();
    a=s.at(0);
    b=s.at(s.length()-1);
    cout<<a<<n<<b;
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n, length=0;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        length=a[i].length();
        if (length<=10)
            cout<<a[i]<<endl;
        else if (length>10)
            cout<<a[i].at(0)<<length<<a[i].at[length-1]<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int l;
    for (int i=0; i<n; i++)
    {
        l=a[i].length();
        if (l<=10)
        cout<<a[i]<<endl;
        else
        cout<<a[i].at(0)<<l<<a[i].at(l-1)<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    string s;
    char a, b;
    int n, size, i=0;
    cin>>n;
    while (i<n)
    {
        cin>>s;
        size=s.length();
        if (size>10)
        {
            a=s.at(0);
            b=s.at(s.length()-1);
            cout<<a<<size<<b<<endl;
        }
        else
        {
            cout<<s<<endl;
        }
        i++;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        if (a[i].length()<=10)
            cout<<a[i]<<endl;
        else if (a[i]>10)
            cout<<a[i].at(0)<<a[i].length()<<a[i].at[(a[i].length())-1]<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n, length=0;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        length=a[i].length();
        if (length<=10)
            cout<<a[i]<<endl;
        else if (length>10)
            cout<<a[i].at(0)<<length-2<<a[i].at(length-1)<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n, length=0;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        length=a[i].length();
        if (length<=10)
            cout<<a[i]<<endl;
        else if (a[i]>10)
            cout<<a[i].at(0)<<length<<a[i].at[length-1]<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    string s;
    char a, b;
    int n, size, i=0;
    cin>>n;
    while (i<n)
    {
        cin>>s;
        size=s.length();
        if (size>10)
        {
            a=s.at(0);
            b=s.at(s.length()-1);
            cout<<a<<size-2<<b<<endl;
        }
        else
        {
            cout<<s<<endl;
        }
        i++;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n, length=0;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        length=a[i].length();
        if (length<=10)
            cout<<a[i]<<endl;
        else if (length>10)
            cout<<a[i].at(0)<<length<<a[i].at(length-3)<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n, length=0;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        length=a[i].length();
        if (length<=10)
            cout<<a[i]<<endl;
        else if (length>10)
            cout<<a[i].at(0)<<length<<a[i].at(length-1)<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        if (a[i].length<=10)
            cout<<a[i]<<endl;
        else if (a[i]>10)
            cout<<a[i].at(0)<<a[i].length()<<a[i].at[a[i].length()-1]<<endl;
    }
}


#include <iostream>
#include <string>
using namespace std;

int main ()
{
    int n, l=0;
    string a[100];
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    for (int i=0; i<n; i++)
    {
        l=a[i].length();
        if (l<=10)
            cout<<a[i]<<endl;
        else if (l>10)
            cout<<a[i].at(0)<<l<<a[i].at(l-1)<<endl;
    }
}


            #include <iostream>
            #include <string>
            using namespace std;

            int main()
            {
            	int i = 0;
            	string a;
            	loop1: cin >> a;
            	if (a=="4")
            	{
            	    goto loop1;
            	}
            	int n = a.length();
            	if (n>10)
            	{
            		cout << a[0] << n - 2 << a[n-1]<<endl;
            		i++;
            		if (i <5)
            		{
            			return 0;
            		}
            		else
            		{
            			goto loop1;
            		}
            	}
            	else
            	{
            		cout << a<<endl;
            		i++;
            		if (i < 5)
            		{
            			return 0;
            		}
            		else
            		{
            			goto loop1;
            		}

            	}
            	return 0;
            }


        #include <iostream>
        #include <string>
        using namespace std;

        int main()
        {
            int i=0;
        	string a;
        	loop1 :cin >> a;
        	int n = a.length();
        	if (n>10)
        	{
        		cout << a[0] << n - 2 << a[n-1];
        		goto loop1;
        		i++;
        		if(i==4)
        		{
        		    return 0;
        		}
        	}
        	else
        	{
        		cout << a;
        		goto loop1;
        		i++;
        		if(i==4)
        		{
        		    return 0;
        		}
        	}
        	return 0;
        }


            #include <iostream>
            #include <string>
            using namespace std;

            int main()
            {
            	int i = 0;
            	string a;
            	loop1: cin >> a;
            	if (a=="4")
            	{
            	    goto loop1;
            	}
            	int n = a.length();
            	if (n>10)
            	{
            		cout << a[0] << n - 2 << a[n-1]<<endl;
            		i++;
            		if (i ==4)
            		{
            			return 0;
            		}
            		else
            		{
            			goto loop1;
            		}
            	}
            	else
            	{
            		cout << a<<endl;
            		i++;
            		if (i == 4)
            		{
            			return 0;
            		}
            		else
            		{
            			goto loop1;
            		}

            	}
            	return 0;
            }


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string a;
	cin >> a;
	int n = a.length();
	if (n>10)
	{
		cout << a[0] << n - 2 << a[n-1];
	}
	else
	{
		cout << a;
	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	int i = 0;
	string a;
	loop1: cin >> a;
	int n = a.length();
	if (n>10)
	{
		cout << a[0] << n - 2 << a[n-1];
		i++;
		if (i ==5)
		{
			return 0;
		}
		else
		{
			goto loop1;
		}
	}
	else
	{
		cout << a;
		i++;
		if (i == 5)
		{
			return 0;
		}
		else
		{
			goto loop1;
		}

	}
	return 0;
}


        #include <iostream>
        #include <string>
        using namespace std;

        int main()
        {
        	int i = 0;
        	string a;
        	loop1: cin >> a;
        	if (a=="4")
        	{
        	    goto loop1;
        	}
        	int n = a.length();
        	if (n>10)
        	{
        		cout << a[0] << n - 2 << a[n-1]<<endl;
        		i++;
        		if (i ==5)
        		{
        			return 0;
        		}
        		else
        		{
        			goto loop1;
        		}
        	}
        	else
        	{
        		cout << a;
        		i++;
        		if (i == 5)
        		{
        			return 0;
        		}
        		else
        		{
        			goto loop1;
        		}

        	}
        	return 0;
        }


    #include <iostream>
    #include <string>
    using namespace std;

    int main()
    {
        int i=0;
    	string a;
    	loop1 :cin >> a;
    	int n = a.length();
    	if (n>10)
    	{
    		cout << a[0] << n - 2 << a[n-1];
    		goto loop1;
    		i++;
    		if(i==4)
    		{
    		    break;
    		}
    	}
    	else
    	{
    		cout << a;
    		goto loop1;
    		i++;
    		if(i==4)
    		{
    		    break;
    		}
    	}
    	return 0;
    }


                #include <iostream>
                #include <string>
                using namespace std;

                int main()
                {
                	int j,i =0;;
                	string a;
                	cin>>j;
                	loop1: cin >> a;
                	int n = a.length();
                	if (n>10)
                	{
                		cout << a[0] << n - 2 << a[n-1]<<endl;
                		i++;
                		if (i ==j)
                		{
                			return 0;
                		}
                		else
                		{
                			goto loop1;
                		}
                	}
                	else
                	{
                		cout << a<<endl;
                		i++;
                		if (i == j)
                		{
                			return 0;
                		}
                		else
                		{
                			goto loop1;
                		}

                	}
                	return 0;
                }


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string a;
	loop1 :cin >> a;
	int n = a.length();
	if (n>10)
	{
		cout << a[0] << n - 2 << a[n-1];
		goto loop1;
	}
	else
	{
		cout << a;
		goto loop1;
	}
	return 0;
}


    #include <iostream>
    #include <string>
    using namespace std;

    int main()
    {
    	int i = 0;
    	string a;
    	loop1: cin >> a;
    	if (a=="4")
    	{
    	    goto loop1;
    	}
    	int n = a.length();
    	if (n>10)
    	{
    		cout << a[0] << n - 2 << a[n-1];
    		i++;
    		if (i ==5)
    		{
    			return 0;
    		}
    		else
    		{
    			goto loop1;
    		}
    	}
    	else
    	{
    		cout << a;
    		i++;
    		if (i == 5)
    		{
    			return 0;
    		}
    		else
    		{
    			goto loop1;
    		}

    	}
    	return 0;
    }


        #include <iostream>
        #include <string>
        using namespace std;

        int main()
        {
        	int i = 0;
        	string a;
        	loop1: cin >> a;
        	if (a=="4")
        	{
        	    goto loop1;
        	}
        	int n = a.length();
        	if (n>10)
        	{
        		cout << a[0] << n - 2 << a[n-1]<<endl;
        		i++;
        		if (i ==5)
        		{
        			return 0;
        		}
        		else
        		{
        			goto loop1;
        		}
        	}
        	else
        	{
        		cout << a<<endl;
        		i++;
        		if (i == 5)
        		{
        			return 0;
        		}
        		else
        		{
        			goto loop1;
        		}

        	}
        	return 0;
        }


#include <iostream>
using namespace std;
int main()
{
    int n;
    char str[100];
    cin >> n;
    while(n>0){
        n--;
        cin >> str;
        if(strlen(str)>10)
            cout << str[0] << strlen(str)-2 << str[strlen(str)-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
    }
   return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int j=0,n;
    char str[100];
    cin >> n;
    while (j<n){
        cin >> str;
        if(strlen(str)>10)
            cout << str[0] << strlen(str)-2 << str[strlen(str)-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
        j++;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int j=0,n,temp;
    char str[100];
    cin >> n;
    while (j<n){
        cin >> str;
        temp=strlen(str);
        if(temp>=10)
            cout << str[0] << temp-2 << str[temp-1];
        else
            puts(str);
        j++;
        cout << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,temp;
    char str[100];
    cin >> n;
     do{
        cin >> str;
        temp=strlen(str);
        if(temp>10)
            cout << str[0] << temp-2 << str[temp-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
        n--;
    }while (n!=0);
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int j=0,n;
    char str[100];
    cin >> n;
    while (j<n){
        cin >> n;
        if(strlen(str)>10)
            cout << str[0] << strlen(str)-2 << str[strlen(str)-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
        j++;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int j=0,n,temp;
	char str[100];
	cin >> n;
	while (j<n){
		cin >> str;
		temp=strlen(str);
		if(temp>10)
			cout << str[0] << temp-2 << str[temp-1];
		else
			puts(str);
		j++;
		cout<<endl;
	}
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n;
    char str[100];
    cin >> n;
    for(;n>0;n--){
        cin >> str;
        if(strlen(str)>10)
            cout << str[0] << strlen(str)-2 << str[strlen(str)-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
    }

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int j=0,n,temp;
    char str[100];
    cin >> n;
    while (j<n){
        cin >> str;
        temp=strlen(str);
        if(temp>10)
            cout << str[0] << temp-2 << str[temp-1];
        else
            puts(str);
        j++;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int j=0,n,temp;
    char str[100];
    cin >> n;
    while (j<n){
        cin >> str;
        temp=strlen(str);
        if(temp>10)
            cout << str[0] << temp-2 << str[temp-1];
        else
            puts(str);
        j++;
        cout<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
  int n,i,j=0;
  char str[100];
   cin>>n;
   for(i=0;i<n;i++){
       cin >> str;
       if(strlen(str)>10)
           cout<< str[0] << strlen(str)-2 << str[strlen(str)-1]<<endl;
       else
           cout<<str<<endl;
   }
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,i,temp;
    char str[100];
    cin >> n;
    for(i=0;i<n;i++){
        cin >> str;
        temp=strlen(str);
        if(temp>10)
            cout << str[0] << temp-2 << str[temp-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
    }

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,temp;
    char str[100];
    cin >> n;
    for(;n>0;n--){
        cin >> str;
        temp=strlen(str);
        if(temp>10)
            cout << str[0] << temp-2 << str[temp-1]<<endl;
        else{
            puts(str);
            cout<<endl;}
    }

    return 0;
}


#include <iostream>
#include<string.h>
using namespace std;
int main()
{
  int n,i;
  char str[101];
   cin>>n;
   for(i=0;i<n;i++){
       cin >> str;
       if(strlen(str)>10)
           cout<< str[0] << strlen(str)-2 << str[strlen(str)-1]<<endl;
       else
           cout<<str<<endl;
   }
    return 0;
}


#include <iostream>

#include<string>

using namespace std ;
int main ()
{
char text[100] ; int test_cas , len;

cin>>test_cas;

for (int i = 0 ; i < test_cas ; i++){

    cin>>text;

    len = strlen (text) ;

    if (len < 10)
    {

    cout<<text<<"\n";

    }
     if (len >= 10)
    {

    cout<<text[0]<<len-2<<text[len - 1]<<"\n";

    }
}
return 0 ;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, s;
    cin >> n;

    int taxi = 0;
    int sum4 = 0;
    int sum3 = 0;
    int sum2 = 0;
    int sum1 = 0;
    int rest = 0;
    int m;

    for (int i=0; i<n; i++)
    {
        cin >> s;
        if(s == 4)
            sum4 ++;
        else if(s == 3)
            sum3 ++;
        else if(s == 2)
            sum2 ++;
        else if(s == 1)
            sum1 ++;
    }

    taxi += sum4;
    taxi += sum2*2 / 4; rest += sum2*2 % 4;

    m = max(sum3, sum1) - min(sum3, sum1);
    if(max(sum3, sum1) == sum3)
    {
        taxi += (sum1+((sum3-m)*3)) / 4;
        taxi += m;
    }

    else if(max(sum3, sum1) == sum1)
    {
        taxi += ((sum1-m)+(sum3*3)) / 4;
        rest += m;
    }

    taxi += ceil(rest / (1.0*4));

    cout << taxi << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;

    int taxi = 0;
    int x_2 = 0;
    int x_1 = 0;
    int s[n];

    for (int i=0; i<n; i++)
    {
        cin >> s[i];
        if(s[i] == 4)
        {
            taxi ++;
            s[i] = 0;
        }
    }

    for (int i=1; i<n; i++)
        for (int j=0; j<sqrt(n); j++)
        {
            if(s[j] + s[j+i]  == 4)
            {
                taxi ++;
                s[j] = 0;
                s[j+i] = 0;
            }
        }

    for (int i=0; i<n; i++)
        {
            if(s[i] == 1)
            {
                x_1 ++;
            }
            else if (s[i] == 2)
            {
                x_2 += 2;
            }
            else if(s[i] == 3)
            {
                taxi ++;
            }
        }

    cout << taxi + ceil((x_1 + x_2) / (1.0*4)) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, t = 0;
    cin >> n;

    int s[100005];

    for (int i=0; i<n; i++)
        cin >> s[i];

    for (int i=0; i<n; i++)
        t += s[i];

    cout << ceil((1.0)*t/4) << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;

    int taxi = 0;
    int sum4 = 0, rest4 = 0;
    int sum3 = 0, rest3 = 0;
    int sum2 = 0, rest2 = 0;
    int sum1 = 0, rest1 = 0;
    int m;
    int s[n];

    for (int i=0; i<n; i++)
    {
        cin >> s[i];
        if(s[i] == 4)
            sum4 ++;
        else if(s[i] == 3)
            sum3 ++;
        else if(s[i] == 2)
            sum2 ++;
        else if(s[i] == 1)
            sum1 ++;

    }

    taxi += sum4;
    taxi += sum2*2 / 4; rest2 += sum2*2 % 4;
    m = max(sum3, sum1) - min(sum3, sum1);
    if(max(sum3, sum1) == sum3)
    {
        taxi += sum1+(sum3*3) / 4;
        rest3 += m*3;
    }

    else if(max(sum3, sum1) == sum1)
    {
        taxi += sum1+(sum3*3) / 4;
        rest2 += m;
    }

    taxi += rest3 / 3;
    taxi += ceil(rest2 / 1.0*4);

    cout << taxi << endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp1=0,temp2=0;
   for(int i=0;i<n;i++){ cin>>x[i]; }
   for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }
   if(temp1%4==0)
   {
       temp1/=temp1;
    N_taxis+=temp1;
   }
   else if(temp1%4!=0)
   {
        temp1/=temp1;
    N_taxis+=temp1+1;
   }
   if(temp2%4==0)
    {
         temp2/=temp2;
    N_taxis+=temp2;
    }
   else if(temp2%4!=0)
   {
        temp2/=temp2;
    N_taxis+=temp2+1;
   }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }

    if(n==2&&(x[0]+x[1]==3)||n==3&&(x[0]+x[1]+x[2]==4)){
        cout<<1<<endl;

    }
    else{

    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;
    }
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3%=4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4%=4;
        temp2/=4;
        N_taxis+=temp2;
    }

    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+1<<endl;
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

   if(temp3+temp4==0)
    cout<<N_taxis<<endl;
   else if(temp3+temp4>4)
    cout<<N_taxis+2<<endl;
    else if(temp3+temp4<=4)
        cout<<N_taxis+1<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0,n3=0,ii=0;
   for(int i=0;i<n;i++){
        cin>>x[i];
        if(i>0&&x[i]==3){
            n3=x[ii];
            x[ii]=3;
            x[i]=n3;
            ii++;
            }
    }
    int ch=1;
   for(int i=0;i<n&&x[i]==3&&ch;i++)
   {
       ch=0;
       int ch0=1;
           for(int j=i+1;j<n&&ch0;j++)
           {
               if(x[j]==1)
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
                    ch=1;
                    ch0=0;
               }

           }
   }

   temp=0;
   for(int i=0;i<n;i++){
        if(x[i]==1||x[i]==2||x[i]==4){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }

    }
    else if(x[i]==3){
        ++N_taxis;
    }
   }
    if(temp%4==0){
    temp/=4;
    N_taxis+=temp;
      }
    else if(temp%4!=0){
        temp/=4;
        N_taxis+=temp+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,twos=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
        else if(x[i]==2)
            twos++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp<=2)
    {
        if(twos==1)
        {
            NTaxis=twos+threes;
            cout<<NTaxis<<endl;
        }
        else if(threes>0)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+2<<endl;
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3%=4;
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4%=4;
        temp2/=4;
        N_taxis+=temp2+1;
    }
    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+1<<endl;
   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp=0;
   for(int i=0;i<n;i++){cin>>x[i]; }
   for(int i=0;i<n;i++)
   {
      // if(x[i]==4){++N_taxis; x[i]=0; }
       //else
       //{
           temp=4-x[i];
           for(int j=i+1;j<n&&x[i]!=0&&x[i]!=4;j++)
           {
               if(temp==x[j])
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
               }
           }
       //}
   }

   temp=0;
   for(int i=0;i<n;i++)
    {
        if(x[i]==3||x[i]==4){
           ++N_taxis;
           x[i]=0;
        }
        else if(x[i]==1||x[i]==2){
            temp+=x[i];
        //if(temp==4){
            //++N_taxis;
           // temp=0;
          //  }
    }
    }
    if(temp%4==0){
    temp/=4;
    N_taxis+=temp;
    //if(temp!=0)
      //  ++N_taxis;
      }
    else if(temp%4!=0){
        temp/=4;
        N_taxis+=temp+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
          temp+=x[i];
          else{
            temp=0;
            break;
            }
    }
       if(temp%4==0&&temp!=0)
    {
        temp/=4;
        N_taxis+=temp;
         cout<<N_taxis<<endl;
    return 0;

    }
    else if(temp%4!=0&&temp!=0)
    {
        temp/=4;
        N_taxis+=temp+1;
         cout<<N_taxis<<endl;
    return 0;

    }

    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp2/=4;
        N_taxis+=temp2+1;
    }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
   int n;
   cin>>n;
   int x[n],N1=0,N2=0,N3=0,N4=0,N=0,temp=0;

   for(int i=0;i<n;i++)
   {
       cin>>x[i];
       if(x[i]==4)
        N4++;
       else if(x[i]==2)
        N2++;
       else if(x[i]==1)
        N1++;
       else
        N3++;
   }
   N+=N4;
   if(N3>=N1){
    N+=N3;
   }else{
    N+=N3;
    N1-=N3;
   }
   temp=N1+N2*2;
   if(temp<=4){
    N+=N1+N2*2;
   }else if(temp>4&&temp%4==0){
    N+=temp/4;
   }else{
    temp/=4+1;
    N+=temp;
   }
   cout<<N<<endl;

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
       if(n==2&&(x[0]+x[1]==3)||n==3&&(x[0]+x[1]+x[2]==4)){
        cout<<1<<endl;

    }
    else{
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3%=4;
        temp1/=4;
        N_taxis+=temp1+1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4%=4;
        temp2/=4;
        N_taxis+=temp2+1;
    }
    if(temp3==0&&temp4==0)
     cout<<N_taxis<<endl;
   else if(temp3==1&&temp4==2)
    cout<<N_taxis+1<<endl;
   else if(temp4==2&&temp3==3)
    cout<<N_taxis+1<<endl;
    }
   return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp<2)
    {
        if(threes>0)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n=0,N_taxis=0;
    cin>>n;
    int x[n],temp1=0,temp2=0,temp3=0,temp4=0;
    for(int i=0;i<n;i++){ cin>>x[i]; }
    for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }

    if(temp1%4==0)
    {
        temp1/=4;
        N_taxis+=temp1;
    }
    else if(temp1%4!=0)
    {
        temp3=temp1%4;
        temp1/=4;
        N_taxis+=temp1;
    }
    if(temp2%4==0)
    {
        temp2/=4;
        N_taxis+=temp2;
    }
    else if(temp2%4!=0)
    {
        temp4=temp2%4;
        temp2/=4;
        N_taxis+=temp2;
    }

   if(temp3+temp4==0)
    cout<<N_taxis<<endl;
    if(temp3+temp4>4)
    cout<<N_taxis+2<<endl;
    if(temp3+temp<=4)
        cout<<N_taxis+1<<endl;

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp<=2)
    {
        if(threes>0)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,N_taxis=0;
   cin>>n;
   int x[n],temp1=0,temp2=0;
   for(int i=0;i<n;i++){ cin>>x[i]; }
   for(int i=0;i<n;i++)
    {
    if(x[i]==1||x[i]==3)
    {
        temp1+=x[i];
    }
    else
    {
        temp2+=x[i];
    }
    }
   if(temp1%4==0)
   {
    N_taxis+=temp1;
   }
   else if(temp1%4!=0)
   {
    N_taxis+=temp1+1;
   }
   if(temp2%4==0)
    {
    N_taxis+=temp2;
    }
   else if(temp2%4!=0)
   {
    N_taxis+=temp2+1;
   }

   cout<<N_taxis<<endl;

   return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,twos=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
        else if(x[i]==2)
            twos++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp<=2)
    {
        if(twos==1)
        {
            NTaxis=twos+threes;
            cout<<NTaxis<<endl;
        }
       else  if(threes>0&&threes>=ones)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
       else if(threes==1&&ones==2)
       {
           cout<<2<<endl;
       }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n],ones=0,twos=0,threes=0,temp=0,NTaxis=0;

    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]==1)
            ones++;
        else if(x[i]==3)
            threes++;
        else if(x[i]==2)
            twos++;
    }

    for(int i=0;i<n;i++)
    {
        if(x[i]!=3)
        {
            temp+=x[i];
        }
    }

    if(temp>3&&temp%4==0)
    {
        NTaxis+=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4>2)
    {
        temp+=4;
        NTaxis=temp/4+threes;
        cout<<NTaxis<<endl;
    }

    else if(temp>2&&temp%4<2)
    {
        if(threes>0)
        {
            NTaxis=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }

    else if(temp>2&&temp%4==2)
    {
        if(ones==0)
        {
            temp+=4;
            NTaxis+=temp/4+threes;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes>=2)
        {
            NTaxis=threes+temp/4;
            cout<<NTaxis<<endl;
        }
        else if(ones>1&&threes==1)
        {
            NTaxis=temp/4+2;
            cout<<NTaxis<<endl;
        }
        else
        {
            temp+=4;
            NTaxis=temp/4;
            cout<<NTaxis<<endl;
        }
    }
    else if(temp<=2)
    {
        if(twos==1)
        {
            NTaxis=twos+threes;
            cout<<NTaxis<<endl;
        }
       else  if(threes>0)
        {
            NTaxis=threes;
            cout<<NTaxis<<endl;
        }
        else
        {
            cout<<1<<endl;
        }
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
   int n=0,temp,N_taxis=0;
    cin>>n);
   int x[n];
   for(int i=0;i<n;i++){cin>>x[i]; }
   for(int i=0;i<n;i++)
   {
       if(x[i]==4){++N_taxis; x[i]=0; }
       else
       {
           temp=4-x[i];
           for(int j=i+1;j<n&&x[i]!=0;j++)
           {
               if(temp==x[j])
               {
                   ++N_taxis;
                   x[i]=0;
                   x[j]=0;
               }
           }
       }
   }

   temp=0;
   for(int i=0;i<n;i++)
    {
        if(x[i]==3){
           ++N_taxis;
           x[i]=0;
        }
        else if(x[i]==1||x[i]==2){
            temp+=x[i];
        if(temp==4){
            ++N_taxis;
            temp=0;
            }
    }
    }
    if(temp!=0)
        ++N_taxis;

   cout<<N_taxis<<endl;

   return 0;
}