#include <bits/stdc++.h>
using namespace std;
int a[1000001][2], ls[500001], sz[500001], b[500001], c[500001], num[500001],
    D[500001], n, m, K, i, j, k, l, len, t, T;
int fa[1000001], S[1000001];
vector<int> d[500001], d2[500001], d3[500001];
bool bz[500001], Bz[500001];
long long ans;
int gf(int t) {
  if (fa[t] == t) return t;
  fa[t] = gf(fa[t]);
  return fa[t];
};
void New(int x, int y) {
  ++len;
  a[len][0] = y;
  a[len][1] = ls[x];
  ls[x] = len;
}
void dfs(int t) {
  int i;
  num[t] = l;
  for (i = ls[t]; i; i = a[i][1])
    if (c[a[i][0]] == c[t]) {
      if (!b[a[i][0]])
        b[a[i][0]] = 3 - b[t], dfs(a[i][0]);
      else if (b[a[i][0]] != 3 - b[t])
        bz[c[t]] = 1;
    }
}
void swap(int &x, int &y) {
  int z = x;
  x = y;
  y = z;
}
void js(int x, int y) {
  int i, j, k, l, X1, X2, Y1, Y2;
  for (i = 0; i <= sz[x] - 1; i++)
    l = d[x][i], l = num[l], fa[l * 2 - 1] = l * 2 - 1, fa[l * 2] = l * 2,
    S[l * 2 - 1] = l * 2, S[l * 2] = l * 2 - 1;
  l = d2[y].size();
  for (i = 0; i <= l - 1; i++)
    k = d2[y][i], k = num[k], fa[k * 2 - 1] = k * 2 - 1, fa[k * 2] = k * 2,
    S[k * 2 - 1] = k * 2, S[k * 2] = k * 2 - 1;
  for (i = 0; i <= l - 1; i++) {
    j = d3[y][i], k = d2[y][i];
    j = num[j] * 2 + (b[j] - 2), k = num[k] * 2 + (b[k] - 2);
    j = gf(j), k = gf(k);
    if (j == k) {
      --ans;
      return;
    } else {
      X1 = j, X2 = S[j];
      Y1 = S[k], Y2 = k;
      if (gf(X1) != gf(Y1)) fa[fa[X1]] = fa[Y1];
      if (gf(X2) != gf(Y2)) fa[fa[X2]] = fa[Y2];
      X1 = gf(X1), X2 = gf(X2);
      S[X1] = X2, S[X2] = X1;
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (i = 1; i <= n; i++) scanf("%d", &c[i]), d[c[i]].push_back(i);
  for (i = 1; i <= m; i++) scanf("%d%d", &j, &k), New(j, k), New(k, j);
  l = 0;
  for (i = 1; i <= n; i++)
    if (!b[i]) b[i] = 1, ++l, dfs(i);
  l = 0;
  for (i = 1; i <= K; i++) sz[i] = d[i].size(), l += !bz[i];
  ans = 1ll * l * (l - 1) / 2;
  for (i = 1; i <= K; i++)
    if (!bz[i]) {
      for (j = 0; j <= sz[i] - 1; j++) {
        T = d[i][j];
        for (k = ls[T]; k; k = a[k][1])
          if (c[a[k][0]] != i && !bz[c[a[k][0]]]) {
            d2[c[a[k][0]]].push_back(a[k][0]);
            d3[c[a[k][0]]].push_back(T);
          }
      }
      t = 0;
      for (j = 0; j <= sz[i] - 1; j++) {
        T = d[i][j];
        for (k = ls[T]; k; k = a[k][1])
          if (c[a[k][0]] != i && !bz[c[a[k][0]]] && !Bz[c[a[k][0]]]) {
            if (sz[i] < sz[c[a[k][0]]] ||
                sz[i] == sz[c[a[k][0]]] && i < c[a[k][0]])
              js(i, c[a[k][0]]);
            D[++t] = c[a[k][0]], Bz[c[a[k][0]]] = 1;
          }
      }
      for (k = 1; k <= t; k++) Bz[D[k]] = 0, d2[D[k]].clear(), d3[D[k]].clear();
    }
  printf("%lld\n", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
