#include <bits/stdc++.h>
using namespace std;
const long long cls = 1e9 + 7;
const int maxn = 111111;
const long double eps = 1e-8;
const double PI = acos(-1.0);
const long long inf = 0x3f3f3f3f3f3f;
int a[100010], vis[100010], dp[100010];
int main() {
  int n;
  scanf("%d", &n);
  dp[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &a[i]);
    if (!vis[a[i]]) {
      vis[a[i]] = 1;
      dp[i] = dp[i - 1] + 1;
    } else {
      dp[i] = dp[i - 1];
    }
  }
  long long ans = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = n; i >= 1; i--) {
    if (!vis[a[i]]) {
      vis[a[i]] = 1;
      ans += dp[i - 1];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
