#include <bits/stdc++.h>
int main() {
  int n;
  scanf("%d", &n);
  char *str = new char[n + 1];
  scanf("%s", str);
  int size = strlen(str);
  int sum1 = 0, sum2 = 0;
  bool f = true;
  for (int i = 0; i < size / 2; ++i) {
    if ((str[i] == '4' || str[i] == '7') &&
        (str[size - i - 1] == '4' || str[size - i - 1] == '7')) {
      sum1 += str[i] - '0';
      sum2 += str[size - i - 1] - '0';
    } else {
      f = false;
      break;
    }
  }
  if (sum1 == sum2 && f)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
