#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int, int>;
using PLL = pair<LL, LL>;
using UI = unsigned int;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int N = 5e5 + 10;
int n, m, k, tot, idx[N], c[N];
vector<int> V[N];
bool mk[N], ok[N];
int col[N];
unordered_set<int> ST[N];
unordered_map<LL, int> dep;
unordered_map<LL, LL> fa;
unordered_map<LL, bool> flag;
int edge[N][2];
LL encode(LL a, LL b) { return a << 20 | b; }
LL find_fa(LL p, int &v) {
  if (p == fa[p]) {
    return p;
  } else {
    fa[p] = find_fa(fa[p], v);
    v ^= flag[p];
    flag[p] = v;
    return fa[p];
  }
}
void join(LL a, LL b, int v) {
  if (dep[a] < dep[b]) {
    swap(a, b);
  }
  if (dep[a] == dep[b]) {
    ++dep[a];
  }
  fa[b] = a;
  flag[b] ^= v;
}
LL get_p(int x, int c, int &v) {
  LL p = encode(x, c);
  if (!fa.count(p)) {
    fa[p] = p;
    dep[p] = 1;
    flag[p] = 0;
    return p;
  } else {
    return find_fa(p, v);
  }
}
void failed(int x, int y) {
  if (x == y) {
    ok[x] = 0;
  } else {
    if (x > y) swap(x, y);
    ST[x].insert(y);
  }
}
void bfs(int x) {
  idx[x] = ++tot;
  queue<int> Q;
  Q.emplace(x);
  col[x] = 0;
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    for (int y : V[x]) {
      if (c[y] != c[x]) continue;
      if (col[y] != -1) {
        if (col[y] == col[x]) {
          ok[c[x]] = 0;
        }
      } else {
        idx[y] = idx[x];
        col[y] = col[x] ^ 1;
        Q.emplace(y);
      }
    }
  }
}
int main() {
  int x, y;
  memset(mk, 0, sizeof(mk));
  memset(col, -1, sizeof(col));
  scanf("%d %d %d", &n, &m, &k);
  for (int i = (1); i < (n + 1); ++i) {
    scanf("%d", c + i);
    mk[c[i]] = 1;
    ok[c[i]] = 1;
  }
  for (int i = (0); i < (m); ++i) {
    scanf("%d %d", &x, &y);
    V[x].emplace_back(y);
    V[y].emplace_back(x);
    edge[i][0] = x;
    edge[i][1] = y;
  }
  tot = 0;
  for (int i = (1); i < (n + 1); ++i) {
    if (col[i] == -1) {
      bfs(i);
    }
  }
  int u1, v1;
  LL u, v;
  for (int i = (0); i < (m); ++i) {
    x = edge[i][0];
    y = edge[i][1];
    if (idx[x] == idx[y]) {
      continue;
    }
    u1 = v1 = 0;
    u = get_p(idx[x], c[y], u1);
    v = get_p(idx[y], c[x], v1);
    u1 ^= col[x];
    v1 ^= col[y];
    if (u == v && u1 == v1) {
      failed(c[x], c[y]);
    }
    if (u != v) join(u, v, u1 ^ v1 ^ 1);
  }
  LL cnt = 0, cnt1 = 0;
  LL ans = 0;
  for (int i = (1); i < (k + 1); ++i) {
    if (!mk[i]) {
      ++cnt;
    } else {
      if (ok[i]) {
        ++cnt1;
        for (int x : ST[i]) {
          if (ok[x]) {
            --ans;
          }
        }
      }
    }
  }
  ans = ans + cnt * (cnt - 1) / 2;
  ans = ans + cnt1 * cnt;
  ans = ans + cnt1 * (cnt1 - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}
