#include <bits/stdc++.h>

using namespace std;

void solve(int64_t b) {
  int64_t answer = 0;
  for (int64_t a = 1; a <= 1000000; a++) {
    stringstream ss;
    ss << a << a;
    istringstream iss(ss.str());
    int64_t c;
    iss >> c;
    if (c <= b) {
      answer++;
    }
  }
  cout << answer << endl;
}

int main() {
  int64_t b;
  cin >> b;
  solve(b);
  return 0;
}

#pragma region template

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vld = vector<ld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
constexpr ll inf = 3001001000100100100LL;
#define endl '\n'

// clang-format off
#define _overload(_1, _2, _3, name, ...) name
#define  rep(...) _overload(__VA_ARGS__,  _rep,  _rep2,)(__VA_ARGS__)
#define repc(...) _overload(__VA_ARGS__, _repc, _repc2,)(__VA_ARGS__)
#define repr(...) _overload(__VA_ARGS__, _repr, _repr2,)(__VA_ARGS__)
#define  _rep(i,k,n) for(ll i=(k)  , i##_xxxx=(n); i < i##_xxxx; ++i)
#define _repc(i,k,n) for(ll i=(k)  , i##_xxxx=(n); i <=i##_xxxx; ++i)
#define _repr(i,k,n) for(ll i=(n-1), i##_xxxx=(k); i >=i##_xxxx; --i)
#define  _rep2(i,n)  _rep(i,0,n)
#define _repc2(i,n) _repc(i,1,n)
#define _repr2(i,n) _repr(i,0,n)
// rep [k,n)      repc[k,n]      repr[k,n)

#define all(o) begin(o), end(o)
template <typename C> ll sz(const C &c) { return static_cast<ll>(c.size()); }
template <class T> T udiv(T a, T b) {return (a + b - 1) / b;}
template <class T> T rdiv(T a, T b) {return (a + b / 2) / b;}
template <typename T, typename S> string join(const T &seq, S sep) { stringstream ss; bool f = false; for (auto c : seq) { ss << (f ? sep : "") << c; f = true;} return ss.str(); }
template <class T, class S, class... U> string join(const T &v, const S &sep, const U &...args) { stringstream ss; bool f = false; for (auto &&c : v) { if (f) ss << sep; f = true; ss << join(c, args...); } return ss.str(); }
template <typename T>               ostream &operator<<(ostream &os, const vector<T>             &v){ os << '[' << join(v, ",") << ']'; return os; }
template <typename T>               ostream &operator<<(ostream &os, const deque<T>              &v){ os << '[' << join(v, ",") << ']'; return os; }
template <typename T>               ostream &operator<<(ostream &os, const set<T>                &v){ os << '{' << join(v, ",") << '}'; return os; }
template <typename T , typename TH> ostream &operator<<(ostream &os, const unordered_set<T, TH>  &v){ os << '{' << join(v, ",") << '}'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV>          &mp){ os << '{'; for (auto v : mp) os << v.first << ":" << v.second << ','; os << '}'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2>         &pa){ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
#define debug(...) _debug(__LINE__, __VA_ARGS__)

void print_args(ostream& out) { out << '\n'; }
void print() { std::cout << '\n'; }
void _debug() { std::cerr << '\n'; }
template <class S, class... T> void print_args(ostream& out,const S& a,const T&... args) { out << ' ' << a; print_args(out, args...); }
template <class S, class... T> void  print(const S& a, const T&... args) { std::cout << a; print_args(std::cout, args...); }
template <class S, class... T> void _debug(const S& a, const T&... args) { std::cerr << "(L:" << std::setw(3) << a << ")"; print_args(std::cerr, args...); }
// clang-format on

struct setup_main {
    setup_main() {
        std::cin.tie(nullptr);
        // std::ios::sync_with_stdio(false); // atcoder-toolsとの共存不可
        std::cout << fixed << setprecision(15);
    }
} setup_main_;
#pragma endregion

void solve(ll N, vector<ll> A) {
    ll ans = 0;
    vl v(401, 0);
    rep(i, N) v[A[i] + 200]++;
    rep(i1, 401) rep(i2, 401) {
        ans += v[i1] * v[i2] * (i1 - i2) * (i1 - i2);
    }
    print(ans / 2);
}


signed main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    solve(N, move(A));
}
