#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 100005;
const int MOD = 1e9 + 7;
const double pi = acos(-1);
bool vis[100005];
int a[100005], d[100005];
int main() {
  int n, t = 0;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = n - 1; i >= 0; --i) {
    if (!vis[a[i]]) ++t;
    d[i] = t;
    vis[a[i]] = 1;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n - 1; ++i) {
    if (!vis[a[i]]) {
      ans += d[i + 1];
      vis[a[i]] = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
