#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int a[maxn], rec[maxn];
set<int> p;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--) {
    p.insert(a[i]);
    rec[i] = p.size();
  }
  p.clear();
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (p.find(a[i]) != p.end()) continue;
    p.insert(a[i]);
    res += rec[i + 1];
  }
  printf("%lld", res);
}
