#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long crr[100003] = {0};
  long long brr[n];
  for (long long j = n - 1; j >= 0; j--) {
    if (j == n - 1)
      brr[j] = 0;
    else {
      if (crr[arr[j + 1]] == 1)
        brr[j] = brr[j + 1] + 1;
      else
        brr[j] = brr[j + 1];
    }
    crr[arr[j]]++;
  }
  memset(crr, 0, sizeof(crr));
  for (long long i = 0; i < n; i++) {
    crr[arr[i]]++;
    if (crr[arr[i]] > 1) brr[i] = 0;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) ans += brr[i];
  cout << ans;
}
