#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
  long long N,Sum,Ans,count;
  cin >> N;
  int A[N];
  count =1;
  Sum =0;
  Ans =0;
  
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);

  for(int j=0;j<N;j++){
    if(A[j]==A[j+1]){
      count++;
    }else{
      Sum += count*count;
      count=1;
    }
  }
  Ans = (N*N-Sum)/2; 
  cout << Ans;
  return 0;
}
#include<bits/stdc++.h>

using namespace std;

#define PI 3.14159265
#define sqr(x) ((x)*(x))
#define vi vector<int>
#define vll vector<long long>
#define vull vector<unsigned long long>
#define all(v) ((v).begin()), ((v).end())
#define rev(v) ((v).rbegin()), ((v).rend())
#define rep(i, st, en) for(int i = st; i < en; i++)
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long int ulli;

//int prefix[MAX];
//ll sieve_size;
//bitset<10000010>bs;
//vll p;
//void sieve(ll upperbound) {
//    sieve_size = upperbound + 1;
//    bs.set();
//    bs[0] = bs[1] = false;
//    for (ll i = 2; i < sieve_size; i++) {
//        if (bs[i]) {
//            for (ll j = i * i; j < sieve_size; j += i) bs[j] = false;
//            p.push_back(i);
//        }
//    }
//    prefix[0] = prefix[1] = 0;
//    for (int p = 2; p <= MAX; p++) {
//        prefix[p] = prefix[p - 1];
//        if (bs[p])
//            prefix[p]++;
//    }
//}

bool isPrime(ll n) {
    // Corner cases
    if (n <= 1) return false;
    if (n <= 3) return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

bool bySec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}

template<typename T>
void takeInput(vector<T>& v)
{
    for (auto& value: v)
        cin >> value;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    vi v(n);
    takeInput(v);
    int mx = INT_MIN;
    rep(i, 0, n){
        int x = v[i];
        rep(j, i, n){
            x = min(x, v[j]);
            mx = max(mx, x*(j-i+1));
        }
    }

    cout << mx;

    return 0;
}