#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int M = 1e5 + 50;
map<int, int> vis, cnt;
int main() {
  int n;
  long long ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    int ch, tmp;
    scanf("%d", &ch);
    if (!vis[ch]) {
      vis[ch] = 1;
      cnt[ch] = vis.size() - 1;
      tmp = vis.size() - 1;
    } else {
      tmp = vis.size() - cnt[ch];
      cnt[ch] = vis.size();
    }
    ans += 1ll * tmp;
  }
  cout << ans;
}
