#include <bits/stdc++.h>
using namespace std;
int arr[100009], mark[100009], vis[100009];
map<pair<int, int>, int> mp;
map<pair<int, int>, int>::iterator ii;
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%d", &arr[i]);
  memset(mark, 0, sizeof mark);
  for (i = 0; i < n; ++i) mark[arr[i]] += 1;
  int cnt = 0;
  for (i = 1; i <= 100000; ++i)
    if (mark[i] != 0) ++cnt;
  long long ans = 0;
  memset(vis, -1, sizeof vis);
  for (i = 0; i < n; ++i) {
    int val = arr[i];
    mark[val]--;
    if (mark[val] == 0) cnt--;
    if (vis[val] == -1) {
      vis[val] = 1;
      ans = ans + (long long)cnt;
    }
  }
  printf("%lld\n", ans);
}
