#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<vector<vector<long long>>> vvvl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound




int main(){

    int n;
    cin>>n;
    vl a(n);
    rep(i,n) cin>>a[i];


    ll sum=0;

    rep(i,n) sum+=a[i]*a[i];

    ll tmp=0;

    rep(i,n) tmp+=a[i];

    tmp=tmp*tmp;


    cout<<n*sum-tmp<<endl;





}
#include<stdio.h>
#include<queue>
#include<vector>
#include<string.h>
#include<iostream>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
#define int long long
#define ll long long
#define speed(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int maxn=2e5+10;
const int inf=0x3f3f3f3f;
const int INF=1ll<<62;


inline int rd() {
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}

int gcd(int a,int b) {
	return b? gcd(b,a%b):a;
}

int n;

signed main() {
    n=rd();
	int ans=0;
    for(int i=1;i<=1000000;i++){
    	int ceng=1;
    	while(pow(10,ceng)<=i)ceng++;
    	int res=pow(10,ceng)*i+i;
//    	cout<<res<<endl;
    	if(res>n)break;
    	ans=i;
	}
	printf("%lld\n",ans);
	return 0;
}



//5 3 12