#include <bits/stdc++.h>
using namespace std;
long long n, m, ans;
long long dis[405];
long long s[250005], t[250005], c[250005];
vector<int> vis[405];
long long dp[405][405][2];
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &dis[i]);
  for (int i = 1; i <= m; i++) {
    int r;
    scanf("%lld%lld%lld%d", &s[i], &t[i], &c[i], &r);
    r = min((long long)r + 1, t[i] - s[i]);
    vis[r].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) dp[i][j][1] = dis[j] - dis[i];
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++)
      for (int j = i; j <= n; j++) dp[i][j][0] = dp[i][j][1];
    for (int i = 0; i < vis[k].size(); i++)
      ans = max(ans, c[vis[k][i]] * dp[s[vis[k][i]]][t[vis[k][i]]][0]);
    for (int i = 1; i <= n; i++) {
      int temp = i;
      for (int j = i + 1; j <= n; j++) {
        while (dp[i][temp][0] < dis[j] - dis[temp]) temp++;
        dp[i][j][1] = min(dp[i][temp][0], dis[j] - dis[temp - 1]);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
