#include <bits/stdc++.h>
int main() {
  int i, j, n, f, sum1, sum2, temp;
  char a[55];
  while (scanf("%d ", &n) == 1) {
    for (i = 0; i < n; i++) scanf("%c", &a[i]);
    f = 0;
    for (i = 0; i < n; i++) {
      if (!(a[i] == '4' || a[i] == '7')) {
        f = 1;
      }
    }
    if (f == 1) {
      printf("NO\n");
      continue;
    }
    for (i = 0, sum1 = 0; i < (n / 2); i++) {
      temp = a[i] - '0';
      sum1 += temp;
    }
    for (j = i, sum2 = 0; j < n; j++) {
      temp = a[j] - '0';
      sum2 += temp;
    }
    if (sum1 == sum2)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
