#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int n;
int a[maxn];
map<int, int> myp;
bool vis[maxn];
int main() {
  scanf("%d", &n);
  long long cnt = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (myp[a[i]] == 0) cnt++;
    myp[a[i]]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (myp[a[i]] == 1) cnt--;
    myp[a[i]]--;
    if (vis[a[i]]) continue;
    vis[a[i]] = 1;
    ans += cnt;
  }
  printf("%I64d\n", ans);
  return 0;
}
