#include <iostream>
#include <stdint.h>
using namespace std;

int main()
{
	long long minn = 1e18+1;
	long long n;
	cin>>n;
	for(uint64_t b = 0;(uint64_t)(1ULL<<b) <= n;b++)
	{
		// cout<<b<<" ";
		uint64_t second = (1ULL<<b);
		long long a = n / second;
		long long c = n % (a*second);
		if(a+b+c<minn) minn = a + b + c;
	}
	cout<<minn<<endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}
void OUTX2(){cout << endl;}
template<typename Head, typename... Tail>
void OUTX2(Head&& head, Tail&&... tail)
{
    cout << head << ' ';
    OUTX2(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define __LONG_LONG_MIN__ (-__LONG_LONG_MAX__ - 1)

//#define MOD 1000000007 // 10^9 + 7
//setprecision(10)

int main()
{
    ll N;
    INX(N);

    vll cnt(200, 0);
    vll A(N);
    for (ll i = 0; i < N; i++)
    {
        INX(A[i]);
        A[i] %= 200;
        cnt[A[i]]++;
    }
    
    ll result = 0;
    for (ll i = 0; i < 200; i++)
    {
        if(cnt[i] <= 1) continue;
        result += cnt[i] * (cnt[i] - 1) / 2;
    }
    OUTX(result);

    return 0;
}
