#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 5;
int n, a[mxn], c[mxn];
bool vis[mxn];
int main() {
  scanf("%d", &n);
  for (int(i) = (int)(1); (i) <= (int)(n); ++(i)) scanf("%d", a + i);
  int cnt = 0;
  for (int(i) = (int)(n); (i) >= (int)(1); --(i)) {
    c[i] = c[i + 1] + (vis[a[i]] == 0);
    vis[a[i]] = 1;
  }
  long long ans = 0;
  memset(vis, 0, sizeof(vis));
  for (int(i) = (int)(1); (i) <= (int)(n); ++(i))
    if (!vis[a[i]]) {
      vis[a[i]] = 1;
      ans += c[i + 1];
    }
  return 0 * printf("%lld\n", ans);
}
