#include <bits/stdc++.h>
using namespace std;
int a[100005];
int head[100005], nex[100005];
int num[100005];
int vis[100005];
int main() {
  int n;
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = n; i >= 1; i--) {
    if (vis[a[i]] == 0) num[i]++;
    num[i] += num[i + 1];
    vis[a[i]]++;
    nex[i] = head[a[i]];
    head[a[i]] = i;
  }
  long long ans = 0;
  for (i = 0; i <= 100000; i++)
    if (vis[i] > 1) ans++;
  for (i = n; i >= 1; i--) {
    if (nex[i] == 0) {
      ans += num[i] - 1;
    } else {
      ans = ans + num[i] - num[nex[i]];
    }
  }
  printf("%lld", ans);
  return 0;
}
