#include <bits/stdc++.h>
using namespace std;
long long int n, d, l[100005], cev, f, elma[100005], el[100005], type;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &l[i]);
  for (int i = n; i >= 1; i--) {
    elma[l[i]] = i;
  }
  for (int i = n; i >= 1; i--) {
    if (elma[l[i]] == i) cev += type;
    if (el[l[i]] == 0) {
      type++;
      el[l[i]] = 1;
    }
  }
  printf("%lld", cev);
  return 0;
}
